parse 5.2.0-alpha.1 → 5.2.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parse.js +10519 -15246
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +10499 -15371
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Analytics.js +7 -11
- package/lib/browser/AnonymousUtils.js +17 -22
- package/lib/browser/Cloud.js +23 -41
- package/lib/browser/CoreManager.js +71 -79
- package/lib/browser/CryptoController.js +14 -9
- package/lib/browser/EventEmitter.js +9 -2
- package/lib/browser/EventuallyQueue.js +156 -357
- package/lib/browser/FacebookUtils.js +23 -28
- package/lib/browser/IndexedDBStorageController.js +18 -14
- package/lib/browser/InstallationController.js +55 -121
- package/lib/browser/LiveQueryClient.js +312 -485
- package/lib/browser/LiveQuerySubscription.js +25 -28
- package/lib/browser/LocalDatastore.js +258 -624
- package/lib/browser/LocalDatastoreController.default.js +42 -226
- package/lib/browser/LocalDatastoreController.js +11 -1
- package/lib/browser/LocalDatastoreController.react-native.js +66 -160
- package/lib/browser/LocalDatastoreUtils.js +4 -7
- package/lib/browser/ObjectStateMutations.js +54 -96
- package/lib/browser/OfflineQuery.js +106 -198
- package/lib/browser/Parse.js +44 -60
- package/lib/browser/ParseACL.js +242 -288
- package/lib/browser/ParseCLP.js +372 -572
- package/lib/browser/ParseConfig.js +115 -138
- package/lib/browser/ParseError.js +85 -182
- package/lib/browser/ParseFile.js +294 -438
- package/lib/browser/ParseGeoPoint.js +121 -146
- package/lib/browser/ParseHooks.js +23 -25
- package/lib/browser/ParseInstallation.js +225 -367
- package/lib/browser/ParseLiveQuery.js +74 -148
- package/lib/browser/ParseObject.js +2014 -2621
- package/lib/browser/ParseOp.js +343 -484
- package/lib/browser/ParsePolygon.js +101 -120
- package/lib/browser/ParseQuery.js +1708 -2052
- package/lib/browser/ParseRelation.js +99 -118
- package/lib/browser/ParseRole.js +88 -140
- package/lib/browser/ParseSchema.js +372 -434
- package/lib/browser/ParseSession.js +62 -110
- package/lib/browser/ParseUser.js +941 -1284
- package/lib/browser/Push.js +15 -38
- package/lib/browser/RESTController.js +85 -124
- package/lib/browser/SingleInstanceStateController.js +57 -86
- package/lib/browser/Socket.weapp.js +50 -33
- package/lib/browser/Storage.js +23 -28
- package/lib/browser/StorageController.browser.js +16 -13
- package/lib/browser/StorageController.default.js +15 -14
- package/lib/browser/StorageController.js +14 -1
- package/lib/browser/StorageController.react-native.js +31 -30
- package/lib/browser/StorageController.weapp.js +19 -13
- package/lib/browser/TaskQueue.js +31 -43
- package/lib/browser/UniqueInstanceStateController.js +65 -86
- package/lib/browser/WebSocketController.js +11 -4
- package/lib/browser/Xhr.weapp.js +90 -78
- package/lib/browser/arrayContainsObject.js +3 -3
- package/lib/browser/canBeSerialized.js +10 -11
- package/lib/browser/decode.js +11 -11
- package/lib/browser/encode.js +11 -11
- package/lib/browser/equals.js +9 -10
- package/lib/browser/escape.js +2 -2
- package/lib/browser/isRevocableSession.js +1 -1
- package/lib/browser/parseDate.js +10 -10
- package/lib/browser/promiseUtils.js +19 -19
- package/lib/browser/unique.js +4 -4
- package/lib/browser/unsavedChildren.js +20 -21
- package/lib/browser/uuid.js +2 -4
- package/lib/node/Analytics.js +5 -9
- package/lib/node/AnonymousUtils.js +10 -15
- package/lib/node/Cloud.js +11 -11
- package/lib/node/CoreManager.js +59 -67
- package/lib/node/CryptoController.js +8 -3
- package/lib/node/EventEmitter.js +7 -1
- package/lib/node/EventuallyQueue.js +20 -39
- package/lib/node/FacebookUtils.js +4 -8
- package/lib/node/IndexedDBStorageController.js +14 -10
- package/lib/node/InstallationController.js +12 -13
- package/lib/node/LiveQueryClient.js +23 -21
- package/lib/node/LiveQuerySubscription.js +6 -7
- package/lib/node/LocalDatastore.js +23 -23
- package/lib/node/LocalDatastoreController.default.js +11 -12
- package/lib/node/LocalDatastoreController.js +14 -1
- package/lib/node/LocalDatastoreController.react-native.js +25 -21
- package/lib/node/LocalDatastoreUtils.js +4 -7
- package/lib/node/ObjectStateMutations.js +12 -22
- package/lib/node/OfflineQuery.js +37 -23
- package/lib/node/Parse.js +36 -50
- package/lib/node/ParseACL.js +21 -30
- package/lib/node/ParseCLP.js +38 -40
- package/lib/node/ParseConfig.js +10 -17
- package/lib/node/ParseError.js +460 -461
- package/lib/node/ParseFile.js +27 -47
- package/lib/node/ParseGeoPoint.js +16 -17
- package/lib/node/ParseHooks.js +16 -18
- package/lib/node/ParseInstallation.js +10 -11
- package/lib/node/ParseLiveQuery.js +9 -14
- package/lib/node/ParseObject.js +142 -173
- package/lib/node/ParseOp.js +35 -47
- package/lib/node/ParsePolygon.js +14 -20
- package/lib/node/ParseQuery.js +100 -123
- package/lib/node/ParseRelation.js +10 -19
- package/lib/node/ParseRole.js +10 -11
- package/lib/node/ParseSchema.js +29 -42
- package/lib/node/ParseSession.js +10 -11
- package/lib/node/ParseUser.js +76 -87
- package/lib/node/Push.js +7 -12
- package/lib/node/RESTController.js +24 -36
- package/lib/node/SingleInstanceStateController.js +41 -69
- package/lib/node/Socket.weapp.js +23 -2
- package/lib/node/Storage.js +14 -19
- package/lib/node/StorageController.browser.js +10 -8
- package/lib/node/StorageController.default.js +9 -9
- package/lib/node/StorageController.js +16 -1
- package/lib/node/StorageController.react-native.js +20 -20
- package/lib/node/StorageController.weapp.js +14 -8
- package/lib/node/TaskQueue.js +2 -3
- package/lib/node/UniqueInstanceStateController.js +43 -63
- package/lib/node/WebSocketController.js +15 -2
- package/lib/node/Xhr.weapp.js +11 -2
- package/lib/node/arrayContainsObject.js +4 -4
- package/lib/node/canBeSerialized.js +5 -5
- package/lib/node/decode.js +4 -4
- package/lib/node/encode.js +5 -5
- package/lib/node/equals.js +4 -4
- package/lib/node/escape.js +1 -1
- package/lib/node/isRevocableSession.js +1 -1
- package/lib/node/parseDate.js +1 -1
- package/lib/node/promiseUtils.js +7 -7
- package/lib/node/unique.js +5 -5
- package/lib/node/unsavedChildren.js +5 -5
- package/lib/node/uuid.js +2 -4
- package/lib/react-native/Analytics.js +2 -2
- package/lib/react-native/AnonymousUtils.js +3 -4
- package/lib/react-native/CoreManager.js +2 -3
- package/lib/react-native/CryptoController.js +6 -1
- package/lib/react-native/EventEmitter.js +6 -1
- package/lib/react-native/EventuallyQueue.js +1 -2
- package/lib/react-native/FacebookUtils.js +1 -2
- package/lib/react-native/IndexedDBStorageController.js +11 -5
- package/lib/react-native/InstallationController.js +1 -2
- package/lib/react-native/LiveQueryClient.js +8 -7
- package/lib/react-native/LiveQuerySubscription.js +2 -4
- package/lib/react-native/LocalDatastore.js +3 -3
- package/lib/react-native/LocalDatastoreController.default.js +1 -2
- package/lib/react-native/LocalDatastoreController.js +11 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +11 -12
- package/lib/react-native/LocalDatastoreUtils.js +3 -6
- package/lib/react-native/OfflineQuery.js +25 -20
- package/lib/react-native/Parse.js +24 -38
- package/lib/react-native/ParseACL.js +4 -6
- package/lib/react-native/ParseCLP.js +2 -4
- package/lib/react-native/ParseConfig.js +4 -6
- package/lib/react-native/ParseError.js +13 -31
- package/lib/react-native/ParseFile.js +3 -4
- package/lib/react-native/ParseGeoPoint.js +2 -4
- package/lib/react-native/ParseInstallation.js +13 -30
- package/lib/react-native/ParseLiveQuery.js +2 -4
- package/lib/react-native/ParseObject.js +77 -87
- package/lib/react-native/ParseOp.js +41 -79
- package/lib/react-native/ParsePolygon.js +2 -4
- package/lib/react-native/ParseQuery.js +43 -45
- package/lib/react-native/ParseRelation.js +2 -4
- package/lib/react-native/ParseRole.js +13 -30
- package/lib/react-native/ParseSchema.js +3 -5
- package/lib/react-native/ParseSession.js +12 -29
- package/lib/react-native/ParseUser.js +24 -49
- package/lib/react-native/RESTController.js +10 -4
- package/lib/react-native/SingleInstanceStateController.js +23 -37
- package/lib/react-native/Socket.weapp.js +9 -4
- package/lib/react-native/Storage.js +1 -2
- package/lib/react-native/StorageController.browser.js +6 -1
- package/lib/react-native/StorageController.default.js +6 -1
- package/lib/react-native/StorageController.js +13 -1
- package/lib/react-native/StorageController.react-native.js +11 -6
- package/lib/react-native/StorageController.weapp.js +6 -1
- package/lib/react-native/TaskQueue.js +2 -4
- package/lib/react-native/UniqueInstanceStateController.js +23 -37
- package/lib/react-native/WebSocketController.js +9 -1
- package/lib/react-native/Xhr.weapp.js +9 -4
- package/lib/react-native/unsavedChildren.js +3 -3
- package/lib/react-native/uuid.js +1 -2
- package/lib/weapp/Analytics.js +7 -11
- package/lib/weapp/AnonymousUtils.js +17 -22
- package/lib/weapp/Cloud.js +23 -41
- package/lib/weapp/CoreManager.js +71 -79
- package/lib/weapp/CryptoController.js +14 -9
- package/lib/weapp/EventEmitter.js +9 -2
- package/lib/weapp/EventuallyQueue.js +156 -357
- package/lib/weapp/FacebookUtils.js +23 -28
- package/lib/weapp/IndexedDBStorageController.js +18 -14
- package/lib/weapp/InstallationController.js +55 -121
- package/lib/weapp/LiveQueryClient.js +312 -485
- package/lib/weapp/LiveQuerySubscription.js +25 -28
- package/lib/weapp/LocalDatastore.js +258 -624
- package/lib/weapp/LocalDatastoreController.default.js +42 -226
- package/lib/weapp/LocalDatastoreController.js +11 -1
- package/lib/weapp/LocalDatastoreController.react-native.js +66 -160
- package/lib/weapp/LocalDatastoreUtils.js +4 -7
- package/lib/weapp/ObjectStateMutations.js +54 -96
- package/lib/weapp/OfflineQuery.js +106 -198
- package/lib/weapp/Parse.js +44 -59
- package/lib/weapp/ParseACL.js +242 -288
- package/lib/weapp/ParseCLP.js +372 -572
- package/lib/weapp/ParseConfig.js +115 -138
- package/lib/weapp/ParseError.js +85 -182
- package/lib/weapp/ParseFile.js +295 -440
- package/lib/weapp/ParseGeoPoint.js +121 -146
- package/lib/weapp/ParseHooks.js +23 -25
- package/lib/weapp/ParseInstallation.js +225 -367
- package/lib/weapp/ParseLiveQuery.js +74 -148
- package/lib/weapp/ParseObject.js +2014 -2621
- package/lib/weapp/ParseOp.js +343 -484
- package/lib/weapp/ParsePolygon.js +101 -120
- package/lib/weapp/ParseQuery.js +1708 -2052
- package/lib/weapp/ParseRelation.js +99 -118
- package/lib/weapp/ParseRole.js +88 -140
- package/lib/weapp/ParseSchema.js +372 -434
- package/lib/weapp/ParseSession.js +62 -110
- package/lib/weapp/ParseUser.js +941 -1284
- package/lib/weapp/Push.js +15 -38
- package/lib/weapp/RESTController.js +86 -125
- package/lib/weapp/SingleInstanceStateController.js +57 -86
- package/lib/weapp/Socket.weapp.js +50 -33
- package/lib/weapp/Storage.js +23 -28
- package/lib/weapp/StorageController.browser.js +16 -13
- package/lib/weapp/StorageController.default.js +15 -14
- package/lib/weapp/StorageController.js +14 -1
- package/lib/weapp/StorageController.react-native.js +31 -30
- package/lib/weapp/StorageController.weapp.js +19 -13
- package/lib/weapp/TaskQueue.js +31 -43
- package/lib/weapp/UniqueInstanceStateController.js +65 -86
- package/lib/weapp/WebSocketController.js +11 -4
- package/lib/weapp/Xhr.weapp.js +90 -78
- package/lib/weapp/arrayContainsObject.js +3 -3
- package/lib/weapp/canBeSerialized.js +10 -11
- package/lib/weapp/decode.js +11 -11
- package/lib/weapp/encode.js +11 -11
- package/lib/weapp/equals.js +9 -10
- package/lib/weapp/escape.js +2 -2
- package/lib/weapp/isRevocableSession.js +1 -1
- package/lib/weapp/parseDate.js +10 -10
- package/lib/weapp/promiseUtils.js +19 -19
- package/lib/weapp/unique.js +4 -4
- package/lib/weapp/unsavedChildren.js +20 -21
- package/lib/weapp/uuid.js +6 -8
- package/package.json +24 -30
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
|
|
4
|
-
var _Array$from2 = require("@babel/runtime-corejs3/core-js-stable/array/from");
|
|
5
|
-
var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
|
|
6
|
-
var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
|
|
7
|
-
var _Array$isArray2 = require("@babel/runtime-corejs3/core-js-stable/array/is-array");
|
|
8
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
9
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
10
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
@@ -13,88 +8,19 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
13
8
|
exports.default = void 0;
|
|
14
9
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
15
10
|
var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
|
|
16
|
-
var
|
|
11
|
+
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
17
12
|
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
|
|
18
13
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
19
|
-
var _keys2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
20
14
|
var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
|
|
21
|
-
var _keys3 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/keys"));
|
|
22
15
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
23
16
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
17
|
+
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
24
18
|
var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
|
|
25
19
|
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
26
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
|
|
27
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/toConsumableArray"));
|
|
28
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
|
29
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
|
30
20
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
21
|
+
var _LocalDatastoreController = _interopRequireDefault(require("./LocalDatastoreController"));
|
|
31
22
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
32
23
|
var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
|
|
33
|
-
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
34
|
-
var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
|
|
35
|
-
if (!it) {
|
|
36
|
-
if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
37
|
-
if (it) o = it;
|
|
38
|
-
var i = 0;
|
|
39
|
-
var F = function () {};
|
|
40
|
-
return {
|
|
41
|
-
s: F,
|
|
42
|
-
n: function () {
|
|
43
|
-
if (i >= o.length) return {
|
|
44
|
-
done: true
|
|
45
|
-
};
|
|
46
|
-
return {
|
|
47
|
-
done: false,
|
|
48
|
-
value: o[i++]
|
|
49
|
-
};
|
|
50
|
-
},
|
|
51
|
-
e: function (_e) {
|
|
52
|
-
throw _e;
|
|
53
|
-
},
|
|
54
|
-
f: F
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
58
|
-
}
|
|
59
|
-
var normalCompletion = true,
|
|
60
|
-
didErr = false,
|
|
61
|
-
err;
|
|
62
|
-
return {
|
|
63
|
-
s: function () {
|
|
64
|
-
it = it.call(o);
|
|
65
|
-
},
|
|
66
|
-
n: function () {
|
|
67
|
-
var step = it.next();
|
|
68
|
-
normalCompletion = step.done;
|
|
69
|
-
return step;
|
|
70
|
-
},
|
|
71
|
-
e: function (_e2) {
|
|
72
|
-
didErr = true;
|
|
73
|
-
err = _e2;
|
|
74
|
-
},
|
|
75
|
-
f: function () {
|
|
76
|
-
try {
|
|
77
|
-
if (!normalCompletion && it.return != null) it.return();
|
|
78
|
-
} finally {
|
|
79
|
-
if (didErr) throw err;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
85
|
-
var _context20;
|
|
86
|
-
if (!o) return;
|
|
87
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
88
|
-
var n = _sliceInstanceProperty(_context20 = Object.prototype.toString.call(o)).call(_context20, 8, -1);
|
|
89
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
90
|
-
if (n === "Map" || n === "Set") return _Array$from2(o);
|
|
91
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
92
|
-
}
|
|
93
|
-
function _arrayLikeToArray(arr, len) {
|
|
94
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
95
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
96
|
-
return arr2;
|
|
97
|
-
}
|
|
98
24
|
/**
|
|
99
25
|
* Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
|
|
100
26
|
* To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
|
|
@@ -115,250 +41,120 @@ function _arrayLikeToArray(arr, len) {
|
|
|
115
41
|
* @class Parse.LocalDatastore
|
|
116
42
|
* @static
|
|
117
43
|
*/
|
|
118
|
-
|
|
44
|
+
const LocalDatastore = {
|
|
119
45
|
isEnabled: false,
|
|
120
46
|
isSyncing: false,
|
|
121
|
-
fromPinWithName
|
|
122
|
-
|
|
47
|
+
fromPinWithName(name) {
|
|
48
|
+
const controller = _CoreManager.default.getLocalDatastoreController();
|
|
123
49
|
return controller.fromPinWithName(name);
|
|
124
50
|
},
|
|
125
|
-
pinWithName
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return _regenerator.default.wrap(function (_context) {
|
|
129
|
-
while (1) switch (_context.prev = _context.next) {
|
|
130
|
-
case 0:
|
|
131
|
-
controller = _CoreManager.default.getLocalDatastoreController();
|
|
132
|
-
return _context.abrupt("return", controller.pinWithName(name, value));
|
|
133
|
-
case 2:
|
|
134
|
-
case "end":
|
|
135
|
-
return _context.stop();
|
|
136
|
-
}
|
|
137
|
-
}, _callee);
|
|
138
|
-
}))();
|
|
51
|
+
async pinWithName(name, value) {
|
|
52
|
+
const controller = _CoreManager.default.getLocalDatastoreController();
|
|
53
|
+
return controller.pinWithName(name, value);
|
|
139
54
|
},
|
|
140
|
-
unPinWithName
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return _regenerator.default.wrap(function (_context2) {
|
|
144
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
145
|
-
case 0:
|
|
146
|
-
controller = _CoreManager.default.getLocalDatastoreController();
|
|
147
|
-
return _context2.abrupt("return", controller.unPinWithName(name));
|
|
148
|
-
case 2:
|
|
149
|
-
case "end":
|
|
150
|
-
return _context2.stop();
|
|
151
|
-
}
|
|
152
|
-
}, _callee2);
|
|
153
|
-
}))();
|
|
55
|
+
async unPinWithName(name) {
|
|
56
|
+
const controller = _CoreManager.default.getLocalDatastoreController();
|
|
57
|
+
return controller.unPinWithName(name);
|
|
154
58
|
},
|
|
155
|
-
_getAllContents
|
|
156
|
-
|
|
59
|
+
_getAllContents() {
|
|
60
|
+
const controller = _CoreManager.default.getLocalDatastoreController();
|
|
157
61
|
return controller.getAllContents();
|
|
158
62
|
},
|
|
159
63
|
// Use for testing
|
|
160
|
-
_getRawStorage
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return _regenerator.default.wrap(function (_context3) {
|
|
164
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
165
|
-
case 0:
|
|
166
|
-
controller = _CoreManager.default.getLocalDatastoreController();
|
|
167
|
-
return _context3.abrupt("return", controller.getRawStorage());
|
|
168
|
-
case 2:
|
|
169
|
-
case "end":
|
|
170
|
-
return _context3.stop();
|
|
171
|
-
}
|
|
172
|
-
}, _callee3);
|
|
173
|
-
}))();
|
|
64
|
+
async _getRawStorage() {
|
|
65
|
+
const controller = _CoreManager.default.getLocalDatastoreController();
|
|
66
|
+
return controller.getRawStorage();
|
|
174
67
|
},
|
|
175
|
-
_clear
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return _regenerator.default.wrap(function (_context4) {
|
|
179
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
180
|
-
case 0:
|
|
181
|
-
controller = _CoreManager.default.getLocalDatastoreController();
|
|
182
|
-
return _context4.abrupt("return", controller.clear());
|
|
183
|
-
case 2:
|
|
184
|
-
case "end":
|
|
185
|
-
return _context4.stop();
|
|
186
|
-
}
|
|
187
|
-
}, _callee4);
|
|
188
|
-
}))();
|
|
68
|
+
async _clear() {
|
|
69
|
+
const controller = _CoreManager.default.getLocalDatastoreController();
|
|
70
|
+
return controller.clear();
|
|
189
71
|
},
|
|
190
72
|
// Pin the object and children recursively
|
|
191
73
|
// Saves the object and children key to Pin Name
|
|
192
|
-
_handlePinAllWithName
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
children[parentKey] = json;
|
|
214
|
-
for (objectKey in children) {
|
|
215
|
-
objectKeys.push(objectKey);
|
|
216
|
-
toPinPromises.push(_this.pinWithName(objectKey, [children[objectKey]]));
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
} catch (err) {
|
|
220
|
-
_iterator.e(err);
|
|
221
|
-
} finally {
|
|
222
|
-
_iterator.f();
|
|
223
|
-
}
|
|
224
|
-
fromPinPromise = _this.fromPinWithName(pinName);
|
|
225
|
-
_context6.next = 8;
|
|
226
|
-
return _promise.default.all([fromPinPromise, toPinPromises]);
|
|
227
|
-
case 8:
|
|
228
|
-
_yield$Promise$all = _context6.sent;
|
|
229
|
-
_yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 1);
|
|
230
|
-
pinned = _yield$Promise$all2[0];
|
|
231
|
-
toPin = (0, _toConsumableArray2.default)(new _set.default((0, _concat.default)(_context5 = []).call(_context5, (0, _toConsumableArray2.default)(pinned || []), objectKeys)));
|
|
232
|
-
return _context6.abrupt("return", _this.pinWithName(pinName, toPin));
|
|
233
|
-
case 13:
|
|
234
|
-
case "end":
|
|
235
|
-
return _context6.stop();
|
|
236
|
-
}
|
|
237
|
-
}, _callee5);
|
|
238
|
-
}))();
|
|
74
|
+
async _handlePinAllWithName(name, objects) {
|
|
75
|
+
const pinName = this.getPinName(name);
|
|
76
|
+
const toPinPromises = [];
|
|
77
|
+
const objectKeys = [];
|
|
78
|
+
for (const parent of objects) {
|
|
79
|
+
const children = this._getChildren(parent);
|
|
80
|
+
const parentKey = this.getKeyForObject(parent);
|
|
81
|
+
const json = parent._toFullJSON(undefined, true);
|
|
82
|
+
if (parent._localId) {
|
|
83
|
+
json._localId = parent._localId;
|
|
84
|
+
}
|
|
85
|
+
children[parentKey] = json;
|
|
86
|
+
for (const objectKey in children) {
|
|
87
|
+
objectKeys.push(objectKey);
|
|
88
|
+
toPinPromises.push(this.pinWithName(objectKey, [children[objectKey]]));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const fromPinPromise = this.fromPinWithName(pinName);
|
|
92
|
+
const [pinned] = await _promise.default.all([fromPinPromise, toPinPromises]);
|
|
93
|
+
const toPin = [...new _set.default([...(pinned || []), ...objectKeys])];
|
|
94
|
+
return this.pinWithName(pinName, toPin);
|
|
239
95
|
},
|
|
240
96
|
// Removes object and children keys from pin name
|
|
241
97
|
// Keeps the object and children pinned
|
|
242
|
-
_handleUnPinAllWithName
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
objectKeys = (0, _toConsumableArray2.default)(new _set.default(objectKeys));
|
|
270
|
-
pinned = localDatastore[pinName] || [];
|
|
271
|
-
pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
|
|
272
|
-
return !(0, _includes.default)(objectKeys).call(objectKeys, item);
|
|
273
|
-
});
|
|
274
|
-
if (pinned.length == 0) {
|
|
275
|
-
promises.push(_this2.unPinWithName(pinName));
|
|
276
|
-
delete localDatastore[pinName];
|
|
277
|
-
} else {
|
|
278
|
-
promises.push(_this2.pinWithName(pinName, pinned));
|
|
279
|
-
localDatastore[pinName] = pinned;
|
|
280
|
-
}
|
|
281
|
-
_iterator3 = _createForOfIteratorHelper(objectKeys);
|
|
282
|
-
_context8.prev = 13;
|
|
283
|
-
_iterator3.s();
|
|
284
|
-
case 15:
|
|
285
|
-
if ((_step3 = _iterator3.n()).done) {
|
|
286
|
-
_context8.next = 31;
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
objectKey = _step3.value;
|
|
290
|
-
hasReference = false;
|
|
291
|
-
_context8.t0 = (0, _keys3.default)(_regenerator.default).call(_regenerator.default, localDatastore);
|
|
292
|
-
case 19:
|
|
293
|
-
if ((_context8.t1 = _context8.t0()).done) {
|
|
294
|
-
_context8.next = 28;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
key = _context8.t1.value;
|
|
298
|
-
if (!(key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX))) {
|
|
299
|
-
_context8.next = 26;
|
|
300
|
-
break;
|
|
301
|
-
}
|
|
302
|
-
pinnedObjects = localDatastore[key] || [];
|
|
303
|
-
if (!(0, _includes.default)(pinnedObjects).call(pinnedObjects, objectKey)) {
|
|
304
|
-
_context8.next = 26;
|
|
305
|
-
break;
|
|
306
|
-
}
|
|
98
|
+
async _handleUnPinAllWithName(name, objects) {
|
|
99
|
+
const localDatastore = await this._getAllContents();
|
|
100
|
+
const pinName = this.getPinName(name);
|
|
101
|
+
const promises = [];
|
|
102
|
+
let objectKeys = [];
|
|
103
|
+
for (const parent of objects) {
|
|
104
|
+
const children = this._getChildren(parent);
|
|
105
|
+
const parentKey = this.getKeyForObject(parent);
|
|
106
|
+
objectKeys.push(parentKey, ...(0, _keys.default)(children));
|
|
107
|
+
}
|
|
108
|
+
objectKeys = [...new _set.default(objectKeys)];
|
|
109
|
+
let pinned = localDatastore[pinName] || [];
|
|
110
|
+
pinned = (0, _filter.default)(pinned).call(pinned, item => !(0, _includes.default)(objectKeys).call(objectKeys, item));
|
|
111
|
+
if (pinned.length == 0) {
|
|
112
|
+
promises.push(this.unPinWithName(pinName));
|
|
113
|
+
delete localDatastore[pinName];
|
|
114
|
+
} else {
|
|
115
|
+
promises.push(this.pinWithName(pinName, pinned));
|
|
116
|
+
localDatastore[pinName] = pinned;
|
|
117
|
+
}
|
|
118
|
+
for (const objectKey of objectKeys) {
|
|
119
|
+
let hasReference = false;
|
|
120
|
+
for (const key in localDatastore) {
|
|
121
|
+
if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
|
|
122
|
+
const pinnedObjects = localDatastore[key] || [];
|
|
123
|
+
if ((0, _includes.default)(pinnedObjects).call(pinnedObjects, objectKey)) {
|
|
307
124
|
hasReference = true;
|
|
308
|
-
return _context8.abrupt("break", 28);
|
|
309
|
-
case 26:
|
|
310
|
-
_context8.next = 19;
|
|
311
125
|
break;
|
|
312
|
-
|
|
313
|
-
if (!hasReference) {
|
|
314
|
-
promises.push(_this2.unPinWithName(objectKey));
|
|
315
|
-
}
|
|
316
|
-
case 29:
|
|
317
|
-
_context8.next = 15;
|
|
318
|
-
break;
|
|
319
|
-
case 31:
|
|
320
|
-
_context8.next = 36;
|
|
321
|
-
break;
|
|
322
|
-
case 33:
|
|
323
|
-
_context8.prev = 33;
|
|
324
|
-
_context8.t2 = _context8["catch"](13);
|
|
325
|
-
_iterator3.e(_context8.t2);
|
|
326
|
-
case 36:
|
|
327
|
-
_context8.prev = 36;
|
|
328
|
-
_iterator3.f();
|
|
329
|
-
return _context8.finish(36);
|
|
330
|
-
case 39:
|
|
331
|
-
return _context8.abrupt("return", _promise.default.all(promises));
|
|
332
|
-
case 40:
|
|
333
|
-
case "end":
|
|
334
|
-
return _context8.stop();
|
|
126
|
+
}
|
|
335
127
|
}
|
|
336
|
-
}
|
|
337
|
-
|
|
128
|
+
}
|
|
129
|
+
if (!hasReference) {
|
|
130
|
+
promises.push(this.unPinWithName(objectKey));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return _promise.default.all(promises);
|
|
338
134
|
},
|
|
339
135
|
// Retrieve all pointer fields from object recursively
|
|
340
|
-
_getChildren
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
for (
|
|
136
|
+
_getChildren(object) {
|
|
137
|
+
const encountered = {};
|
|
138
|
+
const json = object._toFullJSON(undefined, true);
|
|
139
|
+
for (const key in json) {
|
|
344
140
|
if (json[key] && json[key].__type && json[key].__type === 'Object') {
|
|
345
141
|
this._traverse(json[key], encountered);
|
|
346
142
|
}
|
|
347
143
|
}
|
|
348
144
|
return encountered;
|
|
349
145
|
},
|
|
350
|
-
_traverse
|
|
146
|
+
_traverse(object, encountered) {
|
|
351
147
|
if (!object.objectId) {
|
|
352
148
|
return;
|
|
353
149
|
} else {
|
|
354
|
-
|
|
150
|
+
const objectKey = this.getKeyForObject(object);
|
|
355
151
|
if (encountered[objectKey]) {
|
|
356
152
|
return;
|
|
357
153
|
}
|
|
358
154
|
encountered[objectKey] = object;
|
|
359
155
|
}
|
|
360
|
-
for (
|
|
361
|
-
|
|
156
|
+
for (const key in object) {
|
|
157
|
+
let json = object[key];
|
|
362
158
|
if (!object[key]) {
|
|
363
159
|
json = object;
|
|
364
160
|
}
|
|
@@ -368,254 +164,134 @@ var LocalDatastore = {
|
|
|
368
164
|
}
|
|
369
165
|
},
|
|
370
166
|
// Transform keys in pin name to objects
|
|
371
|
-
_serializeObjectsFromPinName
|
|
372
|
-
var
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
return _context9.abrupt("return", allObjects);
|
|
394
|
-
case 7:
|
|
395
|
-
pinName = _this3.getPinName(name);
|
|
396
|
-
pinned = localDatastore[pinName];
|
|
397
|
-
if ((0, _isArray.default)(pinned)) {
|
|
398
|
-
_context9.next = 11;
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
return _context9.abrupt("return", []);
|
|
402
|
-
case 11:
|
|
403
|
-
promises = (0, _map.default)(pinned).call(pinned, function (objectKey) {
|
|
404
|
-
return _this3.fromPinWithName(objectKey);
|
|
405
|
-
});
|
|
406
|
-
_context9.next = 14;
|
|
407
|
-
return _promise.default.all(promises);
|
|
408
|
-
case 14:
|
|
409
|
-
objects = _context9.sent;
|
|
410
|
-
objects = (0, _concat.default)(_ref = []).apply(_ref, (0, _toConsumableArray2.default)(objects));
|
|
411
|
-
return _context9.abrupt("return", (0, _filter.default)(objects).call(objects, function (object) {
|
|
412
|
-
return object != null;
|
|
413
|
-
}));
|
|
414
|
-
case 17:
|
|
415
|
-
case "end":
|
|
416
|
-
return _context9.stop();
|
|
417
|
-
}
|
|
418
|
-
}, _callee7);
|
|
419
|
-
}))();
|
|
167
|
+
async _serializeObjectsFromPinName(name) {
|
|
168
|
+
var _context;
|
|
169
|
+
const localDatastore = await this._getAllContents();
|
|
170
|
+
const allObjects = [];
|
|
171
|
+
for (const key in localDatastore) {
|
|
172
|
+
if ((0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.OBJECT_PREFIX)) {
|
|
173
|
+
allObjects.push(localDatastore[key][0]);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (!name) {
|
|
177
|
+
return allObjects;
|
|
178
|
+
}
|
|
179
|
+
const pinName = this.getPinName(name);
|
|
180
|
+
const pinned = localDatastore[pinName];
|
|
181
|
+
if (!(0, _isArray.default)(pinned)) {
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
const promises = (0, _map.default)(pinned).call(pinned, objectKey => this.fromPinWithName(objectKey));
|
|
185
|
+
let objects = await _promise.default.all(promises);
|
|
186
|
+
objects = (0, _concat.default)(_context = []).call(_context, ...objects);
|
|
187
|
+
return (0, _filter.default)(objects).call(objects, object => object != null);
|
|
420
188
|
},
|
|
421
189
|
// Replaces object pointers with pinned pointers
|
|
422
190
|
// The object pointers may contain old data
|
|
423
191
|
// Uses Breadth First Search Algorithm
|
|
424
|
-
_serializeObject
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
uniqueId = 0;
|
|
451
|
-
meta[uniqueId] = root;
|
|
192
|
+
async _serializeObject(objectKey, localDatastore) {
|
|
193
|
+
let LDS = localDatastore;
|
|
194
|
+
if (!LDS) {
|
|
195
|
+
LDS = await this._getAllContents();
|
|
196
|
+
}
|
|
197
|
+
if (!LDS[objectKey] || LDS[objectKey].length === 0) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
const root = LDS[objectKey][0];
|
|
201
|
+
const queue = [];
|
|
202
|
+
const meta = {};
|
|
203
|
+
let uniqueId = 0;
|
|
204
|
+
meta[uniqueId] = root;
|
|
205
|
+
queue.push(uniqueId);
|
|
206
|
+
while (queue.length !== 0) {
|
|
207
|
+
const nodeId = queue.shift();
|
|
208
|
+
const subTreeRoot = meta[nodeId];
|
|
209
|
+
for (const field in subTreeRoot) {
|
|
210
|
+
const value = subTreeRoot[field];
|
|
211
|
+
if (value.__type && value.__type === 'Object') {
|
|
212
|
+
const key = this.getKeyForObject(value);
|
|
213
|
+
if (LDS[key] && LDS[key].length > 0) {
|
|
214
|
+
const pointer = LDS[key][0];
|
|
215
|
+
uniqueId++;
|
|
216
|
+
meta[uniqueId] = pointer;
|
|
217
|
+
subTreeRoot[field] = pointer;
|
|
452
218
|
queue.push(uniqueId);
|
|
453
|
-
|
|
454
|
-
nodeId = queue.shift();
|
|
455
|
-
subTreeRoot = meta[nodeId];
|
|
456
|
-
for (field in subTreeRoot) {
|
|
457
|
-
value = subTreeRoot[field];
|
|
458
|
-
if (value.__type && value.__type === 'Object') {
|
|
459
|
-
key = _this4.getKeyForObject(value);
|
|
460
|
-
if (LDS[key] && LDS[key].length > 0) {
|
|
461
|
-
pointer = LDS[key][0];
|
|
462
|
-
uniqueId++;
|
|
463
|
-
meta[uniqueId] = pointer;
|
|
464
|
-
subTreeRoot[field] = pointer;
|
|
465
|
-
queue.push(uniqueId);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
return _context10.abrupt("return", root);
|
|
471
|
-
case 15:
|
|
472
|
-
case "end":
|
|
473
|
-
return _context10.stop();
|
|
219
|
+
}
|
|
474
220
|
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return root;
|
|
477
224
|
},
|
|
478
225
|
// Called when an object is save / fetched
|
|
479
226
|
// Update object pin value
|
|
480
|
-
_updateObjectIfPinned
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
return _context11.abrupt("return");
|
|
492
|
-
case 2:
|
|
493
|
-
objectKey = _this5.getKeyForObject(object);
|
|
494
|
-
_context11.next = 5;
|
|
495
|
-
return _this5.fromPinWithName(objectKey);
|
|
496
|
-
case 5:
|
|
497
|
-
pinned = _context11.sent;
|
|
498
|
-
if (!(!pinned || pinned.length === 0)) {
|
|
499
|
-
_context11.next = 8;
|
|
500
|
-
break;
|
|
501
|
-
}
|
|
502
|
-
return _context11.abrupt("return");
|
|
503
|
-
case 8:
|
|
504
|
-
return _context11.abrupt("return", _this5.pinWithName(objectKey, [object._toFullJSON()]));
|
|
505
|
-
case 9:
|
|
506
|
-
case "end":
|
|
507
|
-
return _context11.stop();
|
|
508
|
-
}
|
|
509
|
-
}, _callee9);
|
|
510
|
-
}))();
|
|
227
|
+
async _updateObjectIfPinned(object) {
|
|
228
|
+
if (!this.isEnabled) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const objectKey = this.getKeyForObject(object);
|
|
232
|
+
const pinned = await this.fromPinWithName(objectKey);
|
|
233
|
+
if (!pinned || pinned.length === 0) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
return this.pinWithName(objectKey, [object._toFullJSON()]);
|
|
511
237
|
},
|
|
512
238
|
// Called when object is destroyed
|
|
513
239
|
// Unpin object and remove all references from pin names
|
|
514
240
|
// TODO: Destroy children?
|
|
515
|
-
_destroyObjectIfPinned
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
case 9:
|
|
540
|
-
promises = [_this6.unPinWithName(objectKey)];
|
|
541
|
-
delete localDatastore[objectKey];
|
|
542
|
-
for (key in localDatastore) {
|
|
543
|
-
if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
|
|
544
|
-
pinned = localDatastore[key] || [];
|
|
545
|
-
if ((0, _includes.default)(pinned).call(pinned, objectKey)) {
|
|
546
|
-
pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
|
|
547
|
-
return item !== objectKey;
|
|
548
|
-
});
|
|
549
|
-
if (pinned.length == 0) {
|
|
550
|
-
promises.push(_this6.unPinWithName(key));
|
|
551
|
-
delete localDatastore[key];
|
|
552
|
-
} else {
|
|
553
|
-
promises.push(_this6.pinWithName(key, pinned));
|
|
554
|
-
localDatastore[key] = pinned;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
return _context12.abrupt("return", _promise.default.all(promises));
|
|
560
|
-
case 13:
|
|
561
|
-
case "end":
|
|
562
|
-
return _context12.stop();
|
|
241
|
+
async _destroyObjectIfPinned(object) {
|
|
242
|
+
if (!this.isEnabled) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const localDatastore = await this._getAllContents();
|
|
246
|
+
const objectKey = this.getKeyForObject(object);
|
|
247
|
+
const pin = localDatastore[objectKey];
|
|
248
|
+
if (!pin) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const promises = [this.unPinWithName(objectKey)];
|
|
252
|
+
delete localDatastore[objectKey];
|
|
253
|
+
for (const key in localDatastore) {
|
|
254
|
+
if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
|
|
255
|
+
let pinned = localDatastore[key] || [];
|
|
256
|
+
if ((0, _includes.default)(pinned).call(pinned, objectKey)) {
|
|
257
|
+
pinned = (0, _filter.default)(pinned).call(pinned, item => item !== objectKey);
|
|
258
|
+
if (pinned.length == 0) {
|
|
259
|
+
promises.push(this.unPinWithName(key));
|
|
260
|
+
delete localDatastore[key];
|
|
261
|
+
} else {
|
|
262
|
+
promises.push(this.pinWithName(key, pinned));
|
|
263
|
+
localDatastore[key] = pinned;
|
|
264
|
+
}
|
|
563
265
|
}
|
|
564
|
-
}
|
|
565
|
-
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return _promise.default.all(promises);
|
|
566
269
|
},
|
|
567
270
|
// Update pin and references of the unsaved object
|
|
568
|
-
_updateLocalIdForObject
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
if (!(!unsaved || unsaved.length === 0)) {
|
|
589
|
-
_context15.next = 9;
|
|
590
|
-
break;
|
|
591
|
-
}
|
|
592
|
-
return _context15.abrupt("return");
|
|
593
|
-
case 9:
|
|
594
|
-
promises = [_this7.unPinWithName(localKey), _this7.pinWithName(objectKey, unsaved)];
|
|
595
|
-
_context15.next = 12;
|
|
596
|
-
return _this7._getAllContents();
|
|
597
|
-
case 12:
|
|
598
|
-
localDatastore = _context15.sent;
|
|
599
|
-
for (key in localDatastore) {
|
|
600
|
-
if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
|
|
601
|
-
pinned = localDatastore[key] || [];
|
|
602
|
-
if ((0, _includes.default)(pinned).call(pinned, localKey)) {
|
|
603
|
-
pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
|
|
604
|
-
return item !== localKey;
|
|
605
|
-
});
|
|
606
|
-
pinned.push(objectKey);
|
|
607
|
-
promises.push(_this7.pinWithName(key, pinned));
|
|
608
|
-
localDatastore[key] = pinned;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
return _context15.abrupt("return", _promise.default.all(promises));
|
|
613
|
-
case 15:
|
|
614
|
-
case "end":
|
|
615
|
-
return _context15.stop();
|
|
271
|
+
async _updateLocalIdForObject(localId, object) {
|
|
272
|
+
if (!this.isEnabled) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const localKey = `${_LocalDatastoreUtils.OBJECT_PREFIX}${object.className}_${localId}`;
|
|
276
|
+
const objectKey = this.getKeyForObject(object);
|
|
277
|
+
const unsaved = await this.fromPinWithName(localKey);
|
|
278
|
+
if (!unsaved || unsaved.length === 0) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const promises = [this.unPinWithName(localKey), this.pinWithName(objectKey, unsaved)];
|
|
282
|
+
const localDatastore = await this._getAllContents();
|
|
283
|
+
for (const key in localDatastore) {
|
|
284
|
+
if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
|
|
285
|
+
let pinned = localDatastore[key] || [];
|
|
286
|
+
if ((0, _includes.default)(pinned).call(pinned, localKey)) {
|
|
287
|
+
pinned = (0, _filter.default)(pinned).call(pinned, item => item !== localKey);
|
|
288
|
+
pinned.push(objectKey);
|
|
289
|
+
promises.push(this.pinWithName(key, pinned));
|
|
290
|
+
localDatastore[key] = pinned;
|
|
616
291
|
}
|
|
617
|
-
}
|
|
618
|
-
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return _promise.default.all(promises);
|
|
619
295
|
},
|
|
620
296
|
/**
|
|
621
297
|
* Updates Local Datastore from Server
|
|
@@ -628,117 +304,76 @@ var LocalDatastore = {
|
|
|
628
304
|
* @name Parse.LocalDatastore.updateFromServer
|
|
629
305
|
* @static
|
|
630
306
|
*/
|
|
631
|
-
updateFromServer
|
|
632
|
-
var
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
break;
|
|
690
|
-
case 23:
|
|
691
|
-
queryPromises = (0, _map.default)(_context16 = (0, _keys2.default)(pointersHash)).call(_context16, function (className) {
|
|
692
|
-
var objectIds = (0, _from.default)(pointersHash[className]);
|
|
693
|
-
var query = new _ParseQuery.default(className);
|
|
694
|
-
query.limit(objectIds.length);
|
|
695
|
-
if (objectIds.length === 1) {
|
|
696
|
-
query.equalTo('objectId', objectIds[0]);
|
|
697
|
-
} else {
|
|
698
|
-
query.containedIn('objectId', objectIds);
|
|
699
|
-
}
|
|
700
|
-
return (0, _find.default)(query).call(query);
|
|
701
|
-
});
|
|
702
|
-
_context17.prev = 24;
|
|
703
|
-
_context17.next = 27;
|
|
704
|
-
return _promise.default.all(queryPromises);
|
|
705
|
-
case 27:
|
|
706
|
-
responses = _context17.sent;
|
|
707
|
-
objects = (0, _concat.default)([]).apply([], responses);
|
|
708
|
-
pinPromises = (0, _map.default)(objects).call(objects, function (object) {
|
|
709
|
-
var objectKey = _this8.getKeyForObject(object);
|
|
710
|
-
return _this8.pinWithName(objectKey, object._toFullJSON());
|
|
711
|
-
});
|
|
712
|
-
_context17.next = 32;
|
|
713
|
-
return _promise.default.all(pinPromises);
|
|
714
|
-
case 32:
|
|
715
|
-
_this8.isSyncing = false;
|
|
716
|
-
_context17.next = 39;
|
|
717
|
-
break;
|
|
718
|
-
case 35:
|
|
719
|
-
_context17.prev = 35;
|
|
720
|
-
_context17.t0 = _context17["catch"](24);
|
|
721
|
-
console.error('Error syncing LocalDatastore: ', _context17.t0);
|
|
722
|
-
_this8.isSyncing = false;
|
|
723
|
-
case 39:
|
|
724
|
-
case "end":
|
|
725
|
-
return _context17.stop();
|
|
726
|
-
}
|
|
727
|
-
}, _callee12, null, [[24, 35]]);
|
|
728
|
-
}))();
|
|
307
|
+
async updateFromServer() {
|
|
308
|
+
var _context2;
|
|
309
|
+
if (!this.checkIfEnabled() || this.isSyncing) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
const localDatastore = await this._getAllContents();
|
|
313
|
+
const keys = [];
|
|
314
|
+
for (const key in localDatastore) {
|
|
315
|
+
if ((0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.OBJECT_PREFIX)) {
|
|
316
|
+
keys.push(key);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (keys.length === 0) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
this.isSyncing = true;
|
|
323
|
+
const pointersHash = {};
|
|
324
|
+
for (const key of keys) {
|
|
325
|
+
// Ignore the OBJECT_PREFIX
|
|
326
|
+
let [,, className, objectId] = key.split('_');
|
|
327
|
+
|
|
328
|
+
// User key is split into [ 'Parse', 'LDS', '', 'User', 'objectId' ]
|
|
329
|
+
if (key.split('_').length === 5 && key.split('_')[3] === 'User') {
|
|
330
|
+
className = '_User';
|
|
331
|
+
objectId = key.split('_')[4];
|
|
332
|
+
}
|
|
333
|
+
if ((0, _startsWith.default)(objectId).call(objectId, 'local')) {
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
if (!(className in pointersHash)) {
|
|
337
|
+
pointersHash[className] = new _set.default();
|
|
338
|
+
}
|
|
339
|
+
pointersHash[className].add(objectId);
|
|
340
|
+
}
|
|
341
|
+
const queryPromises = (0, _map.default)(_context2 = (0, _keys.default)(pointersHash)).call(_context2, className => {
|
|
342
|
+
const objectIds = (0, _from.default)(pointersHash[className]);
|
|
343
|
+
const query = new _ParseQuery.default(className);
|
|
344
|
+
query.limit(objectIds.length);
|
|
345
|
+
if (objectIds.length === 1) {
|
|
346
|
+
query.equalTo('objectId', objectIds[0]);
|
|
347
|
+
} else {
|
|
348
|
+
query.containedIn('objectId', objectIds);
|
|
349
|
+
}
|
|
350
|
+
return (0, _find.default)(query).call(query);
|
|
351
|
+
});
|
|
352
|
+
try {
|
|
353
|
+
const responses = await _promise.default.all(queryPromises);
|
|
354
|
+
const objects = (0, _concat.default)([]).apply([], responses);
|
|
355
|
+
const pinPromises = (0, _map.default)(objects).call(objects, object => {
|
|
356
|
+
const objectKey = this.getKeyForObject(object);
|
|
357
|
+
return this.pinWithName(objectKey, object._toFullJSON());
|
|
358
|
+
});
|
|
359
|
+
await _promise.default.all(pinPromises);
|
|
360
|
+
this.isSyncing = false;
|
|
361
|
+
} catch (error) {
|
|
362
|
+
console.error('Error syncing LocalDatastore: ', error);
|
|
363
|
+
this.isSyncing = false;
|
|
364
|
+
}
|
|
729
365
|
},
|
|
730
|
-
getKeyForObject
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
return (0, _concat.default)(_context18 = (0, _concat.default)(_context19 = "".concat(_LocalDatastoreUtils.OBJECT_PREFIX)).call(_context19, object.className, "_")).call(_context18, objectId);
|
|
366
|
+
getKeyForObject(object) {
|
|
367
|
+
const objectId = object.objectId || object._getId();
|
|
368
|
+
return `${_LocalDatastoreUtils.OBJECT_PREFIX}${object.className}_${objectId}`;
|
|
734
369
|
},
|
|
735
|
-
getPinName
|
|
370
|
+
getPinName(pinName) {
|
|
736
371
|
if (!pinName || pinName === _LocalDatastoreUtils.DEFAULT_PIN) {
|
|
737
372
|
return _LocalDatastoreUtils.DEFAULT_PIN;
|
|
738
373
|
}
|
|
739
374
|
return _LocalDatastoreUtils.PIN_PREFIX + pinName;
|
|
740
375
|
},
|
|
741
|
-
checkIfEnabled
|
|
376
|
+
checkIfEnabled() {
|
|
742
377
|
if (!this.isEnabled) {
|
|
743
378
|
console.error('Parse.enableLocalDatastore() must be called first');
|
|
744
379
|
}
|
|
@@ -746,7 +381,6 @@ var LocalDatastore = {
|
|
|
746
381
|
}
|
|
747
382
|
};
|
|
748
383
|
module.exports = LocalDatastore;
|
|
749
|
-
var _default = LocalDatastore;
|
|
750
|
-
|
|
751
|
-
_CoreManager.default.setLocalDatastoreController(require('./LocalDatastoreController'));
|
|
384
|
+
var _default = exports.default = LocalDatastore;
|
|
385
|
+
_CoreManager.default.setLocalDatastoreController(_LocalDatastoreController.default);
|
|
752
386
|
_CoreManager.default.setLocalDatastore(LocalDatastore);
|