From 0a172d8bc1cbb39900b08fe4d0c67d0590ae8560 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 19 Oct 2023 00:29:03 +0200 Subject: [PATCH] add api.runOutsideOfSync() to backend script API, #4327 --- docs/backend_api/AbstractBeccaEntity.html | 42 +- docs/backend_api/BAttachment.html | 236 +++---- docs/backend_api/BAttribute.html | 200 +++--- docs/backend_api/BBranch.html | 200 +++--- docs/backend_api/BEtapiToken.html | 44 +- docs/backend_api/BNote.html | 370 +++++------ docs/backend_api/BOption.html | 44 +- docs/backend_api/BRecentNote.html | 44 +- docs/backend_api/BRevision.html | 588 +++++++++++++++++- docs/backend_api/BackendScriptApi.html | 246 ++++++-- ...cca_entities_abstract_becca_entity.js.html | 54 +- .../becca_entities_battachment.js.html | 3 +- docs/backend_api/becca_entities_bnote.js.html | 24 +- .../becca_entities_brevision.js.html | 62 ++ .../services_backend_script_api.js.html | 15 + src/services/backend_script_api.js | 15 + src/services/sync_mutex.js | 2 +- 17 files changed, 1572 insertions(+), 617 deletions(-) diff --git a/docs/backend_api/AbstractBeccaEntity.html b/docs/backend_api/AbstractBeccaEntity.html index 739d9d2ca..bc506e960 100644 --- a/docs/backend_api/AbstractBeccaEntity.html +++ b/docs/backend_api/AbstractBeccaEntity.html @@ -183,7 +183,7 @@
Source:
@@ -259,7 +259,7 @@
Source:
@@ -364,7 +364,7 @@
Source:
@@ -484,7 +484,7 @@ -

(protected) generateHash()

+

(protected) generateHash() → {string}

@@ -532,7 +532,7 @@
Source:
@@ -557,6 +557,24 @@ +
Returns:
+ + + + +
+
+ Type +
+
+ +string + + +
+
+ + @@ -568,7 +586,7 @@ -

(protected) generateIdIfNecessary()

+

(abstract, protected) getPojo()

@@ -616,7 +634,7 @@
Source:
@@ -700,7 +718,7 @@
Source:
@@ -784,7 +802,7 @@
Source:
@@ -938,7 +956,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -1022,7 +1040,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -1110,7 +1128,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
diff --git a/docs/backend_api/BAttachment.html b/docs/backend_api/BAttachment.html index 50e40c1e3..6682f46fd 100644 --- a/docs/backend_api/BAttachment.html +++ b/docs/backend_api/BAttachment.html @@ -205,7 +205,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -268,7 +268,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -336,7 +336,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -408,7 +408,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -476,7 +476,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -544,7 +544,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -612,7 +612,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -684,7 +684,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -752,7 +752,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -820,7 +820,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -888,7 +888,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -956,7 +956,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -1024,7 +1024,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -1105,7 +1105,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -1215,7 +1215,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -1388,7 +1388,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -1490,7 +1490,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -1544,7 +1544,7 @@ larger amounts of data and generally not accessible to the user. -

(protected) generateHash()

+

(protected) generateHash() → {string}

@@ -1597,7 +1597,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -1622,95 +1622,24 @@ larger amounts of data and generally not accessible to the user. - - - - +
Returns:
- - - - - -

(protected) generateIdIfNecessary()

- - - +
+
+ Type +
+
+ +string - - - - - - - - - - - -
- - - - - - - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - +
- - - - - - - - - - - - - - + @@ -1770,7 +1699,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -1875,7 +1804,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -1923,6 +1852,95 @@ larger amounts of data and generally not accessible to the user. + + + + + + +

(abstract, protected) getPojo()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + @@ -1982,7 +2000,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -2071,7 +2089,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -2155,7 +2173,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -2336,7 +2354,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -2425,7 +2443,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -2518,7 +2536,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -2815,7 +2833,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
diff --git a/docs/backend_api/BAttribute.html b/docs/backend_api/BAttribute.html index cc20d0db8..30096176e 100644 --- a/docs/backend_api/BAttribute.html +++ b/docs/backend_api/BAttribute.html @@ -268,7 +268,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -825,7 +825,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -935,7 +935,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -1060,7 +1060,7 @@ and relation (representing named relationship between source and target note)(protected) generateHash() +

(protected) generateHash() → {string}

@@ -1113,7 +1113,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -1138,95 +1138,24 @@ and relation (representing named relationship between source and target note)Returns: - - - - - -

(protected) generateIdIfNecessary()

- - - +
+
+ Type +
+
+ +string - - - - - - - - - - - -
- - - - - - - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - +
- - - - - - - - - - - - - - + @@ -1337,6 +1266,95 @@ and relation (representing named relationship between source and target note)(abstract, protected) getPojo() + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + @@ -1396,7 +1414,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -1590,7 +1608,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -1851,7 +1869,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -1940,7 +1958,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -2033,7 +2051,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
diff --git a/docs/backend_api/BBranch.html b/docs/backend_api/BBranch.html index 4e716ec2e..eee682cca 100644 --- a/docs/backend_api/BBranch.html +++ b/docs/backend_api/BBranch.html @@ -203,7 +203,7 @@ Always check noteId instead.
Source:
@@ -945,7 +945,7 @@ of deletion should not act as a clone.
Source:
@@ -1055,7 +1055,7 @@ of deletion should not act as a clone.
Source:
@@ -1384,7 +1384,7 @@ of deletion should not act as a clone. -

(protected) generateHash()

+

(protected) generateHash() → {string}

@@ -1437,7 +1437,7 @@ of deletion should not act as a clone.
Source:
@@ -1462,95 +1462,24 @@ of deletion should not act as a clone. - - - - +
Returns:
- - - - - -

(protected) generateIdIfNecessary()

- - - +
+
+ Type +
+
+ +string - - - - - - - - - - - -
- - - - - - - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - +
- - - - - - - - - - - - - - + @@ -1658,6 +1587,95 @@ of deletion should not act as a clone. + + + + + + +

(abstract, protected) getPojo()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + @@ -1717,7 +1735,7 @@ of deletion should not act as a clone.
Source:
@@ -1806,7 +1824,7 @@ of deletion should not act as a clone.
Source:
@@ -1965,7 +1983,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -2054,7 +2072,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -2147,7 +2165,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
diff --git a/docs/backend_api/BEtapiToken.html b/docs/backend_api/BEtapiToken.html index 6fce5b28a..854421157 100644 --- a/docs/backend_api/BEtapiToken.html +++ b/docs/backend_api/BEtapiToken.html @@ -205,7 +205,7 @@ from tokenHash and token.
Source:
@@ -694,7 +694,7 @@ from tokenHash and token.
Source:
@@ -804,7 +804,7 @@ from tokenHash and token.
Source:
@@ -929,7 +929,7 @@ from tokenHash and token. -

(protected) generateHash()

+

(protected) generateHash() → {string}

@@ -982,7 +982,7 @@ from tokenHash and token.
Source:
@@ -1007,6 +1007,24 @@ from tokenHash and token. +
Returns:
+ + + + +
+
+ Type +
+
+ +string + + +
+
+ + @@ -1018,7 +1036,7 @@ from tokenHash and token. -

(protected) generateIdIfNecessary()

+

(abstract, protected) getPojo()

@@ -1048,7 +1066,7 @@ from tokenHash and token.
Overrides:
@@ -1071,7 +1089,7 @@ from tokenHash and token.
Source:
@@ -1160,7 +1178,7 @@ from tokenHash and token.
Source:
@@ -1249,7 +1267,7 @@ from tokenHash and token.
Source:
@@ -1408,7 +1426,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -1497,7 +1515,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -1590,7 +1608,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
diff --git a/docs/backend_api/BNote.html b/docs/backend_api/BNote.html index f77a085e5..5fe97e3d1 100644 --- a/docs/backend_api/BNote.html +++ b/docs/backend_api/BNote.html @@ -270,7 +270,7 @@
Source:
@@ -1171,7 +1171,7 @@
Source:
@@ -1281,7 +1281,7 @@
Source:
@@ -1588,7 +1588,7 @@ See addLabel, addRelation for more specific methods.
Source:
@@ -1835,7 +1835,7 @@ See addLabel, addRelation for more specific methods.
Source:
@@ -2081,7 +2081,7 @@ returned.
Source:
@@ -2316,7 +2316,7 @@ returned.
Source:
@@ -2432,7 +2432,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -2653,7 +2653,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -2689,7 +2689,7 @@ In the future, this functionality might get more generic and some of the require -

(protected) generateHash()

+

(protected) generateHash() → {string}

@@ -2742,7 +2742,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -2767,95 +2767,24 @@ In the future, this functionality might get more generic and some of the require - - - - +
Returns:
- - - - - -

(protected) generateIdIfNecessary()

- - - +
+
+ Type +
+
+ +string - - - - - - - - - - - -
- - - - - - - - -
Overrides:
-
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - +
- - - - - - - - - - - - - - + @@ -2919,7 +2848,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -3025,7 +2954,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -3127,7 +3056,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -3229,7 +3158,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -3334,7 +3263,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -3436,7 +3365,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -3538,7 +3467,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -3712,7 +3641,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -3891,7 +3820,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -4099,7 +4028,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -4278,7 +4207,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -4457,7 +4386,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -4565,7 +4494,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -4667,7 +4596,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -4769,7 +4698,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -4871,7 +4800,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -4978,7 +4907,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -5068,7 +4997,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -5174,7 +5103,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -5281,7 +5210,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -5395,7 +5324,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -5553,7 +5482,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -5711,7 +5640,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -5881,7 +5810,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -6048,7 +5977,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -6154,7 +6083,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -6334,7 +6263,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6604,7 +6533,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6759,7 +6688,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6917,7 +6846,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7087,7 +7016,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7254,7 +7183,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7409,7 +7338,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7567,7 +7496,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7737,7 +7666,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7843,7 +7772,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7945,7 +7874,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7993,6 +7922,95 @@ This method can be significantly faster than the getAttribute() + + + + + + +

(abstract, protected) getPojo()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + @@ -8052,7 +8070,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8185,7 +8203,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8343,7 +8361,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8513,7 +8531,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8619,7 +8637,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8721,7 +8739,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8830,7 +8848,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9001,7 +9019,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9107,7 +9125,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9209,7 +9227,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9311,7 +9329,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9417,7 +9435,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9519,7 +9537,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9626,7 +9644,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9710,7 +9728,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9936,7 +9954,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -10038,7 +10056,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -10232,7 +10250,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -10461,7 +10479,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -10659,7 +10677,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -10857,7 +10875,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11055,7 +11073,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11161,7 +11179,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11311,7 +11329,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11417,7 +11435,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11511,7 +11529,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11617,7 +11635,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11723,7 +11741,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11829,7 +11847,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11984,7 +12002,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -12090,7 +12108,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -12198,7 +12216,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -12357,7 +12375,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -12446,7 +12464,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -12657,7 +12675,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -12837,7 +12855,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -13017,7 +13035,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -13110,7 +13128,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -13212,7 +13230,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -13314,7 +13332,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -13546,7 +13564,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -13825,7 +13843,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -14005,7 +14023,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -14165,7 +14183,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -14407,7 +14425,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -14618,7 +14636,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -14829,7 +14847,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
diff --git a/docs/backend_api/BOption.html b/docs/backend_api/BOption.html index 11696ebaf..d07862070 100644 --- a/docs/backend_api/BOption.html +++ b/docs/backend_api/BOption.html @@ -199,7 +199,7 @@
Source:
@@ -552,7 +552,7 @@
Source:
@@ -662,7 +662,7 @@
Source:
@@ -787,7 +787,7 @@ -

(protected) generateHash()

+

(protected) generateHash() → {string}

@@ -840,7 +840,7 @@
Source:
@@ -865,6 +865,24 @@ +
Returns:
+ + + + +
+
+ Type +
+
+ +string + + +
+
+ + @@ -876,7 +894,7 @@ -

(protected) generateIdIfNecessary()

+

(abstract, protected) getPojo()

@@ -906,7 +924,7 @@
Overrides:
@@ -929,7 +947,7 @@
Source:
@@ -1018,7 +1036,7 @@
Source:
@@ -1107,7 +1125,7 @@
Source:
@@ -1266,7 +1284,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -1355,7 +1373,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -1448,7 +1466,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
diff --git a/docs/backend_api/BRecentNote.html b/docs/backend_api/BRecentNote.html index d339e4657..927364aee 100644 --- a/docs/backend_api/BRecentNote.html +++ b/docs/backend_api/BRecentNote.html @@ -199,7 +199,7 @@
Source:
@@ -484,7 +484,7 @@
Source:
@@ -594,7 +594,7 @@
Source:
@@ -719,7 +719,7 @@ -

(protected) generateHash()

+

(protected) generateHash() → {string}

@@ -772,7 +772,7 @@
Source:
@@ -797,6 +797,24 @@ +
Returns:
+ + + + +
+
+ Type +
+
+ +string + + +
+
+ + @@ -808,7 +826,7 @@ -

(protected) generateIdIfNecessary()

+

(abstract, protected) getPojo()

@@ -838,7 +856,7 @@
Overrides:
@@ -861,7 +879,7 @@
Source:
@@ -950,7 +968,7 @@
Source:
@@ -1039,7 +1057,7 @@
Source:
@@ -1198,7 +1216,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -1287,7 +1305,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -1380,7 +1398,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
diff --git a/docs/backend_api/BRevision.html b/docs/backend_api/BRevision.html index e97dc907c..9353a04e8 100644 --- a/docs/backend_api/BRevision.html +++ b/docs/backend_api/BRevision.html @@ -200,7 +200,7 @@ It's used for seamless note versioning.
Source:
@@ -1165,7 +1165,7 @@ It's used for seamless note versioning.
Source:
@@ -1275,7 +1275,7 @@ It's used for seamless note versioning.
Source:
@@ -1400,7 +1400,7 @@ It's used for seamless note versioning. -

(protected) generateHash()

+

(protected) generateHash() → {string}

@@ -1453,7 +1453,7 @@ It's used for seamless note versioning.
Source:
@@ -1478,6 +1478,24 @@ It's used for seamless note versioning. +
Returns:
+ + + + +
+
+ Type +
+
+ +string + + +
+
+ + @@ -1489,7 +1507,7 @@ It's used for seamless note versioning. -

(protected) generateIdIfNecessary()

+

getAttachmentById() → {BAttachment|null}

@@ -1517,11 +1535,6 @@ It's used for seamless note versioning. -
Overrides:
-
- @@ -1542,7 +1555,7 @@ It's used for seamless note versioning.
Source:
@@ -1567,6 +1580,129 @@ It's used for seamless note versioning. +
Returns:
+ + + + +
+
+ Type +
+
+ +BAttachment +| + +null + + +
+
+ + + + + + + + + + + + + +

getAttachmentByTitle() → {BAttachment}

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +BAttachment + + +
+
+ + @@ -1626,7 +1762,109 @@ It's used for seamless note versioning.
Source:
+ + + + + + + + + + + + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +Array.<BAttachment> + + +
+
+ + + + + + + + + + + + + +

getAttachmentsByRole() → {Array.<BAttachment>}

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
@@ -1779,6 +2017,318 @@ It's used for seamless note versioning. + + + + + + +

getJsonContent() → {*}

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Throws:
+ + + +
+ + Error in case of invalid JSON + +
+ + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +* + + +
+
+ + + + + + + + + + + + + +

getJsonContentSafely() → {*|null}

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + +
+ valid object or null if the content cannot be parsed as JSON +
+ + + +
+
+ Type +
+
+ +* +| + +null + + +
+
+ + + + + + + + + + + + + +

(abstract, protected) getPojo()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
Overrides:
+
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + @@ -1838,7 +2388,7 @@ It's used for seamless note versioning.
Source:
@@ -1927,7 +2477,7 @@ It's used for seamless note versioning.
Source:
@@ -2192,7 +2742,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -2281,7 +2831,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -2374,7 +2924,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -2632,7 +3182,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
diff --git a/docs/backend_api/BackendScriptApi.html b/docs/backend_api/BackendScriptApi.html index 416bf48af..73fbd1295 100644 --- a/docs/backend_api/BackendScriptApi.html +++ b/docs/backend_api/BackendScriptApi.html @@ -94,7 +94,7 @@ available in the JS backend notes. You can use e.g. api.log(api.startNote.
Source:
@@ -240,7 +240,7 @@ available in the JS backend notes. You can use e.g. api.log(api.startNote.
Source:
@@ -352,7 +352,7 @@ available in the JS backend notes. You can use e.g. api.log(api.startNote.
Source:
@@ -462,7 +462,7 @@ available in the JS backend notes. You can use e.g. api.log(api.startNote.
Source:
@@ -572,7 +572,7 @@ available in the JS backend notes. You can use e.g. api.log(api.startNote.
Source:
@@ -682,7 +682,7 @@ available in the JS backend notes. You can use e.g. api.log(api.startNote.
Source:
@@ -792,7 +792,7 @@ available in the JS backend notes. You can use e.g. api.log(api.startNote.
Source:
@@ -902,7 +902,7 @@ available in the JS backend notes. You can use e.g. api.log(api.startNote.
Source:
@@ -1012,7 +1012,7 @@ available in the JS backend notes. You can use e.g. api.log(api.startNote.
Source:
@@ -1188,7 +1188,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -1691,7 +1691,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -2311,7 +2311,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -2817,7 +2817,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -3018,7 +3018,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -3200,7 +3200,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -3401,7 +3401,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -3552,7 +3552,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -3753,7 +3753,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -3855,7 +3855,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -4013,7 +4013,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -4167,7 +4167,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -4368,7 +4368,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -4478,7 +4478,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4679,7 +4679,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4833,7 +4833,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -5034,7 +5034,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -5235,7 +5235,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -5341,7 +5341,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -5511,7 +5511,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -5814,7 +5814,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -6015,7 +6015,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -6168,7 +6168,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -6323,7 +6323,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -6508,7 +6508,7 @@ instances execute the given function.
Source:
@@ -6566,6 +6566,170 @@ instances execute the given function. +

runOutsideOfSync(callback) → {Promise}

+ + + + + + +
+ Sync process can make data intermittently inconsistent. Scripts which require strong data consistency +can use this function to wait for a possible sync process to finish and prevent new sync process from starting +while it is running. + +Because this is an async process, the inner callback doesn't have automatic transaction handling, so in case +you need to make some DB changes, you need to surround your call with api.transactional(...) +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
callback + + +function + + + + function to be executed while sync process is not running
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + +
+ - resolves once the callback is finished (callback is awaited) +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + +

searchForNote(query, searchParamsopt) → {BNote|null}

@@ -6711,7 +6875,7 @@ instances execute the given function.
Source:
@@ -6913,7 +7077,7 @@ instances execute the given function.
Source:
@@ -7122,7 +7286,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
Source:
@@ -7465,7 +7629,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
Source:
@@ -7689,7 +7853,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
Source:
@@ -7845,7 +8009,7 @@ exists, then we'll use that transaction.
Source:
@@ -8000,7 +8164,7 @@ exists, then we'll use that transaction.
Source:
diff --git a/docs/backend_api/becca_entities_abstract_becca_entity.js.html b/docs/backend_api/becca_entities_abstract_becca_entity.js.html index d54522bc1..e60c3d4b5 100644 --- a/docs/backend_api/becca_entities_abstract_becca_entity.js.html +++ b/docs/backend_api/becca_entities_abstract_becca_entity.js.html @@ -46,31 +46,11 @@ let becca = null; class AbstractBeccaEntity { /** @protected */ beforeSaving() { - this.generateIdIfNecessary(); - } - - /** @protected */ - generateIdIfNecessary() { if (!this[this.constructor.primaryKeyName]) { this[this.constructor.primaryKeyName] = utils.newEntityId(); } } - /** @protected */ - generateHash(isDeleted = false) { - let contentToHash = ""; - - for (const propertyName of this.constructor.hashedProperties) { - contentToHash += `|${this[propertyName]}`; - } - - if (isDeleted) { - contentToHash += "|deleted"; - } - - return utils.hash(contentToHash).substr(0, 10); - } - /** @protected */ getUtcDateChanged() { return this.utcDateModified || this.utcDateCreated; @@ -89,7 +69,7 @@ class AbstractBeccaEntity { } /** @protected */ - putEntityChange(isDeleted = false) { + putEntityChange(isDeleted) { entityChangesService.putEntityChange({ entityName: this.constructor.entityName, entityId: this[this.constructor.primaryKeyName], @@ -100,11 +80,37 @@ class AbstractBeccaEntity { }); } + /** + * @protected + * @returns {string} + */ + generateHash(isDeleted) { + let contentToHash = ""; + + for (const propertyName of this.constructor.hashedProperties) { + contentToHash += `|${this[propertyName]}`; + } + + if (isDeleted) { + contentToHash += "|deleted"; + } + + return utils.hash(contentToHash).substr(0, 10); + } + /** @protected */ getPojoToSave() { return this.getPojo(); } + /** + * @protected + * @abstract + */ + getPojo() { + throw new Error(`Unimplemented getPojo() for entity '${this.constructor.name}'`) + } + /** * Saves entity - executes SQL, but doesn't commit the transaction on its own * @@ -116,9 +122,7 @@ class AbstractBeccaEntity { const isNewEntity = !this[primaryKeyName]; - if (this.beforeSaving) { - this.beforeSaving(opts); - } + this.beforeSaving(opts); const pojo = this.getPojoToSave(); @@ -129,7 +133,7 @@ class AbstractBeccaEntity { return; } - this.putEntityChange(false); + this.putEntityChange(!!this.isDeleted); if (!cls.isEntityEventsDisabled()) { const eventPayload = { diff --git a/docs/backend_api/becca_entities_battachment.js.html b/docs/backend_api/becca_entities_battachment.js.html index f76056dfb..6a389b12f 100644 --- a/docs/backend_api/becca_entities_battachment.js.html +++ b/docs/backend_api/becca_entities_battachment.js.html @@ -48,8 +48,7 @@ const attachmentRoleToNoteTypeMapping = { class BAttachment extends AbstractBeccaEntity { static get entityName() { return "attachments"; } static get primaryKeyName() { return "attachmentId"; } - static get hashedProperties() { return ["attachmentId", "ownerId", "role", "mime", "title", "blobId", - "utcDateScheduledForErasureSince", "utcDateModified"]; } + static get hashedProperties() { return ["attachmentId", "ownerId", "role", "mime", "title", "blobId", "utcDateScheduledForErasureSince"]; } constructor(row) { super(); diff --git a/docs/backend_api/becca_entities_bnote.js.html b/docs/backend_api/becca_entities_bnote.js.html index 6ef8952f1..8d3cd266b 100644 --- a/docs/backend_api/becca_entities_bnote.js.html +++ b/docs/backend_api/becca_entities_bnote.js.html @@ -160,11 +160,17 @@ class BNote extends AbstractBeccaEntity { */ this.contentSize = null; /** - * size of the content and note revision contents in bytes + * size of the note content, attachment contents in bytes * @type {int|null} * @private */ - this.noteSize = null; + this.contentAndAttachmentsSize = null; + /** + * size of the note content, attachment contents and revision contents in bytes + * @type {int|null} + * @private + */ + this.contentAndAttachmentsAndRevisionsSize = null; /** * number of note revisions for this note * @type {int|null} @@ -1635,16 +1641,12 @@ class BNote extends AbstractBeccaEntity { revision.save(); // to generate revisionId, which is then used to save attachments - if (this.type === 'text') { - for (const noteAttachment of this.getAttachments()) { - if (noteAttachment.utcDateScheduledForErasureSince) { - continue; - } - - const revisionAttachment = noteAttachment.copy(); - revisionAttachment.ownerId = revision.revisionId; - revisionAttachment.setContent(noteAttachment.getContent(), {forceSave: true}); + for (const noteAttachment of this.getAttachments()) { + const revisionAttachment = noteAttachment.copy(); + revisionAttachment.ownerId = revision.revisionId; + revisionAttachment.setContent(noteAttachment.getContent(), {forceSave: true}); + if (this.type === 'text') { // content is rewritten to point to the revision attachments noteContent = noteContent.replaceAll(`attachments/${noteAttachment.attachmentId}`, `attachments/${revisionAttachment.attachmentId}`); diff --git a/docs/backend_api/becca_entities_brevision.js.html b/docs/backend_api/becca_entities_brevision.js.html index 331e8cd54..009e72a2e 100644 --- a/docs/backend_api/becca_entities_brevision.js.html +++ b/docs/backend_api/becca_entities_brevision.js.html @@ -114,6 +114,29 @@ class BRevision extends AbstractBeccaEntity { return this._getContent(); } + /** + * @returns {*} + * @throws Error in case of invalid JSON */ + getJsonContent() { + const content = this.getContent(); + + if (!content || !content.trim()) { + return null; + } + + return JSON.parse(content); + } + + /** @returns {*|null} valid object or null if the content cannot be parsed as JSON */ + getJsonContentSafely() { + try { + return this.getJsonContent(); + } + catch (e) { + return null; + } + } + /** * @param content * @param {object} [opts] @@ -133,6 +156,45 @@ class BRevision extends AbstractBeccaEntity { .map(row => new BAttachment(row)); } + /** @returns {BAttachment|null} */ + getAttachmentById(attachmentId, opts = {}) { + opts.includeContentLength = !!opts.includeContentLength; + + const query = opts.includeContentLength + ? `SELECT attachments.*, LENGTH(blobs.content) AS contentLength + FROM attachments + JOIN blobs USING (blobId) + WHERE ownerId = ? AND attachmentId = ? AND isDeleted = 0` + : `SELECT * FROM attachments WHERE ownerId = ? AND attachmentId = ? AND isDeleted = 0`; + + return sql.getRows(query, [this.revisionId, attachmentId]) + .map(row => new BAttachment(row))[0]; + } + + /** @returns {BAttachment[]} */ + getAttachmentsByRole(role) { + return sql.getRows(` + SELECT attachments.* + FROM attachments + WHERE ownerId = ? + AND role = ? + AND isDeleted = 0 + ORDER BY position`, [this.revisionId, role]) + .map(row => new BAttachment(row)); + } + + /** @returns {BAttachment} */ + getAttachmentByTitle(title) { + return sql.getRows(` + SELECT attachments.* + FROM attachments + WHERE ownerId = ? + AND title = ? + AND isDeleted = 0 + ORDER BY position`, [this.revisionId, title]) + .map(row => new BAttachment(row))[0]; + } + beforeSaving() { super.beforeSaving(); diff --git a/docs/backend_api/services_backend_script_api.js.html b/docs/backend_api/services_backend_script_api.js.html index a0a6c60f1..4bc787c46 100644 --- a/docs/backend_api/services_backend_script_api.js.html +++ b/docs/backend_api/services_backend_script_api.js.html @@ -47,6 +47,7 @@ const SpacedUpdate = require("./spaced_update"); const specialNotesService = require("./special_notes"); const branchService = require("./branches"); const exportService = require("./export/zip"); +const syncMutex = require("./sync_mutex.js"); /** * <p>This is the main backend API interface for scripts. All the properties and methods are published in the "api" object @@ -599,6 +600,20 @@ function BackendScriptApi(currentNote, apiParams) { } }; + /** + * Sync process can make data intermittently inconsistent. Scripts which require strong data consistency + * can use this function to wait for a possible sync process to finish and prevent new sync process from starting + * while it is running. + * + * Because this is an async process, the inner callback doesn't have automatic transaction handling, so in case + * you need to make some DB changes, you need to surround your call with api.transactional(...) + * + * @method + * @param {function} callback - function to be executed while sync process is not running + * @returns {Promise} - resolves once the callback is finished (callback is awaited) + */ + this.runOutsideOfSync = syncMutex.doExclusively; + /** * This object contains "at your risk" and "no BC guarantees" objects for advanced use cases. * diff --git a/src/services/backend_script_api.js b/src/services/backend_script_api.js index 3cad85535..5854e002f 100644 --- a/src/services/backend_script_api.js +++ b/src/services/backend_script_api.js @@ -19,6 +19,7 @@ const SpacedUpdate = require("./spaced_update"); const specialNotesService = require("./special_notes"); const branchService = require("./branches"); const exportService = require("./export/zip"); +const syncMutex = require("./sync_mutex.js"); /** *

This is the main backend API interface for scripts. All the properties and methods are published in the "api" object @@ -571,6 +572,20 @@ function BackendScriptApi(currentNote, apiParams) { } }; + /** + * Sync process can make data intermittently inconsistent. Scripts which require strong data consistency + * can use this function to wait for a possible sync process to finish and prevent new sync process from starting + * while it is running. + * + * Because this is an async process, the inner callback doesn't have automatic transaction handling, so in case + * you need to make some DB changes, you need to surround your call with api.transactional(...) + * + * @method + * @param {function} callback - function to be executed while sync process is not running + * @returns {Promise} - resolves once the callback is finished (callback is awaited) + */ + this.runOutsideOfSync = syncMutex.doExclusively; + /** * This object contains "at your risk" and "no BC guarantees" objects for advanced use cases. * diff --git a/src/services/sync_mutex.js b/src/services/sync_mutex.js index 819371e80..fb95d03c4 100644 --- a/src/services/sync_mutex.js +++ b/src/services/sync_mutex.js @@ -1,5 +1,5 @@ /** - * Sync makes process can make data intermittently inconsistent. Processes which require strong data consistency + * Sync process can make data intermittently inconsistent. Processes which require strong data consistency * (like consistency checks) can use this mutex to make sure sync isn't currently running. */