parse 4.0.0-beta.1 → 4.0.1-beta.1
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/LICENSE +167 -25
- package/NOTICE +10 -0
- package/README.md +1 -3
- package/dist/parse.js +188 -374
- package/dist/parse.min.js +7 -6
- package/dist/parse.weapp.js +188 -374
- package/dist/parse.weapp.min.js +7 -6
- package/lib/browser/Analytics.js +0 -7
- package/lib/browser/AnonymousUtils.js +0 -7
- package/lib/browser/Cloud.js +0 -7
- package/lib/browser/CoreManager.js +1 -8
- package/lib/browser/EventEmitter.js +0 -7
- package/lib/browser/FacebookUtils.js +0 -7
- package/lib/browser/InstallationController.js +0 -7
- package/lib/browser/LocalDatastoreUtils.js +0 -7
- package/lib/browser/OfflineQuery.js +27 -8
- package/lib/browser/Parse.js +0 -9
- package/lib/browser/ParseACL.js +0 -7
- package/lib/browser/ParseConfig.js +0 -7
- package/lib/browser/ParseError.js +0 -9
- package/lib/browser/ParseGeoPoint.js +0 -7
- package/lib/browser/ParseObject.js +158 -126
- package/lib/browser/ParsePolygon.js +0 -7
- package/lib/browser/ParseRelation.js +0 -7
- package/lib/browser/ParseSchema.js +0 -7
- package/lib/browser/Push.js +0 -7
- package/lib/browser/RESTController.js +0 -7
- package/lib/browser/SingleInstanceStateController.js +0 -7
- package/lib/browser/Storage.js +0 -7
- package/lib/browser/StorageController.browser.js +0 -7
- package/lib/browser/StorageController.default.js +0 -7
- package/lib/browser/StorageController.react-native.js +0 -7
- package/lib/browser/StorageController.weapp.js +0 -7
- package/lib/browser/TaskQueue.js +0 -7
- package/lib/browser/UniqueInstanceStateController.js +0 -7
- package/lib/browser/arrayContainsObject.js +0 -7
- package/lib/browser/canBeSerialized.js +0 -7
- package/lib/browser/decode.js +0 -7
- package/lib/browser/encode.js +0 -7
- package/lib/browser/equals.js +0 -9
- package/lib/browser/escape.js +0 -7
- package/lib/browser/isRevocableSession.js +0 -7
- package/lib/browser/parseDate.js +0 -7
- package/lib/browser/unique.js +0 -7
- package/lib/browser/unsavedChildren.js +0 -7
- package/lib/node/Analytics.js +0 -7
- package/lib/node/AnonymousUtils.js +0 -7
- package/lib/node/Cloud.js +0 -7
- package/lib/node/CoreManager.js +1 -8
- package/lib/node/EventEmitter.js +0 -7
- package/lib/node/FacebookUtils.js +0 -7
- package/lib/node/InstallationController.js +0 -7
- package/lib/node/LiveQueryClient.js +0 -10
- package/lib/node/LiveQuerySubscription.js +0 -10
- package/lib/node/LocalDatastore.js +0 -7
- package/lib/node/LocalDatastoreController.js +0 -7
- package/lib/node/LocalDatastoreController.react-native.js +0 -7
- package/lib/node/LocalDatastoreUtils.js +0 -7
- package/lib/node/ObjectStateMutations.js +0 -7
- package/lib/node/OfflineQuery.js +8 -0
- package/lib/node/Parse.js +0 -9
- package/lib/node/ParseACL.js +0 -7
- package/lib/node/ParseCLP.js +0 -7
- package/lib/node/ParseConfig.js +0 -7
- package/lib/node/ParseError.js +0 -9
- package/lib/node/ParseFile.js +0 -7
- package/lib/node/ParseGeoPoint.js +0 -7
- package/lib/node/ParseInstallation.js +0 -7
- package/lib/node/ParseLiveQuery.js +0 -7
- package/lib/node/ParseObject.js +40 -29
- package/lib/node/ParseOp.js +0 -7
- package/lib/node/ParsePolygon.js +0 -7
- package/lib/node/ParseQuery.js +0 -7
- package/lib/node/ParseRelation.js +0 -7
- package/lib/node/ParseRole.js +0 -7
- package/lib/node/ParseSchema.js +0 -7
- package/lib/node/ParseSession.js +0 -7
- package/lib/node/ParseUser.js +0 -7
- package/lib/node/Push.js +0 -7
- package/lib/node/RESTController.js +0 -7
- package/lib/node/SingleInstanceStateController.js +0 -7
- package/lib/node/Storage.js +0 -7
- package/lib/node/StorageController.browser.js +0 -7
- package/lib/node/StorageController.default.js +0 -7
- package/lib/node/StorageController.react-native.js +0 -7
- package/lib/node/StorageController.weapp.js +0 -7
- package/lib/node/TaskQueue.js +0 -7
- package/lib/node/UniqueInstanceStateController.js +0 -7
- package/lib/node/arrayContainsObject.js +0 -7
- package/lib/node/canBeSerialized.js +0 -7
- package/lib/node/decode.js +0 -7
- package/lib/node/encode.js +0 -7
- package/lib/node/equals.js +0 -9
- package/lib/node/escape.js +0 -7
- package/lib/node/isRevocableSession.js +0 -7
- package/lib/node/parseDate.js +0 -7
- package/lib/node/unique.js +0 -7
- package/lib/node/unsavedChildren.js +0 -7
- package/lib/react-native/CoreManager.js +2 -2
- package/lib/react-native/EventuallyQueue.js +169 -676
- package/lib/react-native/LiveQueryClient.js +3 -46
- package/lib/react-native/LocalDatastore.js +303 -863
- package/lib/react-native/LocalDatastoreController.js +75 -535
- package/lib/react-native/LocalDatastoreController.react-native.js +95 -503
- package/lib/react-native/ObjectStateMutations.js +2 -31
- package/lib/react-native/OfflineQuery.js +24 -60
- package/lib/react-native/ParseCLP.js +55 -129
- package/lib/react-native/ParseFile.js +63 -468
- package/lib/react-native/ParseLiveQuery.js +60 -455
- package/lib/react-native/ParseObject.js +263 -897
- package/lib/react-native/ParseQuery.js +207 -643
- package/lib/react-native/ParseSchema.js +3 -3
- package/lib/react-native/ParseUser.js +118 -573
- package/lib/react-native/RESTController.js +1 -29
- package/lib/weapp/Analytics.js +0 -7
- package/lib/weapp/AnonymousUtils.js +0 -7
- package/lib/weapp/Cloud.js +0 -7
- package/lib/weapp/CoreManager.js +1 -8
- package/lib/weapp/EventEmitter.js +0 -7
- package/lib/weapp/FacebookUtils.js +0 -7
- package/lib/weapp/InstallationController.js +0 -7
- package/lib/weapp/LocalDatastoreUtils.js +0 -7
- package/lib/weapp/OfflineQuery.js +27 -8
- package/lib/weapp/Parse.js +0 -9
- package/lib/weapp/ParseACL.js +0 -7
- package/lib/weapp/ParseConfig.js +0 -7
- package/lib/weapp/ParseError.js +0 -9
- package/lib/weapp/ParseGeoPoint.js +0 -7
- package/lib/weapp/ParseObject.js +158 -126
- package/lib/weapp/ParsePolygon.js +0 -7
- package/lib/weapp/ParseRelation.js +0 -7
- package/lib/weapp/ParseSchema.js +0 -7
- package/lib/weapp/Push.js +0 -7
- package/lib/weapp/RESTController.js +0 -7
- package/lib/weapp/SingleInstanceStateController.js +0 -7
- package/lib/weapp/Storage.js +0 -7
- package/lib/weapp/StorageController.browser.js +0 -7
- package/lib/weapp/StorageController.default.js +0 -7
- package/lib/weapp/StorageController.react-native.js +0 -7
- package/lib/weapp/StorageController.weapp.js +0 -7
- package/lib/weapp/TaskQueue.js +0 -7
- package/lib/weapp/UniqueInstanceStateController.js +0 -7
- package/lib/weapp/arrayContainsObject.js +0 -7
- package/lib/weapp/canBeSerialized.js +0 -7
- package/lib/weapp/decode.js +0 -7
- package/lib/weapp/encode.js +0 -7
- package/lib/weapp/equals.js +0 -9
- package/lib/weapp/escape.js +0 -7
- package/lib/weapp/isRevocableSession.js +0 -7
- package/lib/weapp/parseDate.js +0 -7
- package/lib/weapp/unique.js +0 -7
- package/lib/weapp/unsavedChildren.js +0 -7
- package/package.json +9 -9
- package/PATENTS +0 -37
|
@@ -13,8 +13,6 @@ exports.pushPendingState = pushPendingState;
|
|
|
13
13
|
exports.setPendingOp = setPendingOp;
|
|
14
14
|
exports.setServerData = setServerData;
|
|
15
15
|
|
|
16
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
-
|
|
18
16
|
var _encode = _interopRequireDefault(require("./encode"));
|
|
19
17
|
|
|
20
18
|
var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
@@ -27,32 +25,6 @@ var _TaskQueue = _interopRequireDefault(require("./TaskQueue"));
|
|
|
27
25
|
|
|
28
26
|
var _ParseOp = require("./ParseOp");
|
|
29
27
|
|
|
30
|
-
function ownKeys(object, enumerableOnly) {
|
|
31
|
-
var keys = Object.keys(object);
|
|
32
|
-
|
|
33
|
-
if (Object.getOwnPropertySymbols) {
|
|
34
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
35
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
36
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
37
|
-
})), keys.push.apply(keys, symbols);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return keys;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function _objectSpread(target) {
|
|
44
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
45
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
46
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
47
|
-
(0, _defineProperty2.default)(target, key, source[key]);
|
|
48
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
49
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return target;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
28
|
function defaultState() {
|
|
57
29
|
return {
|
|
58
30
|
serverData: {},
|
|
@@ -156,9 +128,8 @@ function estimateAttributes(serverData, pendingOps, className, id) {
|
|
|
156
128
|
var fields = attr.split('.');
|
|
157
129
|
var first = fields[0];
|
|
158
130
|
var last = fields[fields.length - 1];
|
|
159
|
-
data[first] =
|
|
160
|
-
|
|
161
|
-
var object = _objectSpread({}, data);
|
|
131
|
+
data[first] = Object.assign({}, serverData[first]);
|
|
132
|
+
var object = Object.assign({}, data);
|
|
162
133
|
|
|
163
134
|
for (var _i = 0; _i < fields.length - 1; _i++) {
|
|
164
135
|
var key = fields[_i];
|
|
@@ -2,46 +2,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
2
2
|
|
|
3
3
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
4
4
|
|
|
5
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
6
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
7
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
8
|
-
|
|
9
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
10
|
-
if (it) o = it;
|
|
11
|
-
var i = 0;
|
|
12
|
-
return function () {
|
|
13
|
-
if (i >= o.length) return {
|
|
14
|
-
done: true
|
|
15
|
-
};
|
|
16
|
-
return {
|
|
17
|
-
done: false,
|
|
18
|
-
value: o[i++]
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
27
|
-
if (!o) return;
|
|
28
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
29
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
30
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
31
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
32
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function _arrayLikeToArray(arr, len) {
|
|
36
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
37
|
-
|
|
38
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
39
|
-
arr2[i] = arr[i];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return arr2;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
5
|
var equalObjects = require('./equals').default;
|
|
46
6
|
|
|
47
7
|
var decode = require('./decode').default;
|
|
@@ -69,6 +29,14 @@ function contains(haystack, needle) {
|
|
|
69
29
|
return false;
|
|
70
30
|
}
|
|
71
31
|
|
|
32
|
+
if (Array.isArray(needle)) {
|
|
33
|
+
for (var need of needle) {
|
|
34
|
+
if (contains(haystack, need)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
72
40
|
return haystack.indexOf(needle) > -1;
|
|
73
41
|
}
|
|
74
42
|
|
|
@@ -166,9 +134,7 @@ function relativeTimeToDate(text) {
|
|
|
166
134
|
|
|
167
135
|
var seconds = 0;
|
|
168
136
|
|
|
169
|
-
for (var
|
|
170
|
-
var _ref = _pairs[_i];
|
|
171
|
-
|
|
137
|
+
for (var _ref of pairs) {
|
|
172
138
|
var _ref2 = (0, _slicedToArray2.default)(_ref, 2);
|
|
173
139
|
|
|
174
140
|
var num = _ref2[0];
|
|
@@ -178,7 +144,7 @@ function relativeTimeToDate(text) {
|
|
|
178
144
|
if (!Number.isInteger(val)) {
|
|
179
145
|
return {
|
|
180
146
|
status: 'error',
|
|
181
|
-
info:
|
|
147
|
+
info: `'${num}' is not an integer.`
|
|
182
148
|
};
|
|
183
149
|
}
|
|
184
150
|
|
|
@@ -227,7 +193,7 @@ function relativeTimeToDate(text) {
|
|
|
227
193
|
default:
|
|
228
194
|
return {
|
|
229
195
|
status: 'error',
|
|
230
|
-
info:
|
|
196
|
+
info: `Invalid interval: '${interval}'`
|
|
231
197
|
};
|
|
232
198
|
}
|
|
233
199
|
}
|
|
@@ -304,7 +270,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
304
270
|
}
|
|
305
271
|
|
|
306
272
|
if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(key)) {
|
|
307
|
-
throw new ParseError(ParseError.INVALID_KEY_NAME,
|
|
273
|
+
throw new ParseError(ParseError.INVALID_KEY_NAME, `Invalid Key: ${key}`);
|
|
308
274
|
}
|
|
309
275
|
|
|
310
276
|
if (typeof constraints !== 'object') {
|
|
@@ -338,7 +304,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
338
304
|
var parserResult = relativeTimeToDate(compareTo['$relativeTime']);
|
|
339
305
|
|
|
340
306
|
if (parserResult.status !== 'success') {
|
|
341
|
-
throw new ParseError(ParseError.INVALID_JSON,
|
|
307
|
+
throw new ParseError(ParseError.INVALID_JSON, `bad $relativeTime (${key}) value. ${parserResult.info}`);
|
|
342
308
|
}
|
|
343
309
|
|
|
344
310
|
compareTo = parserResult.result;
|
|
@@ -495,8 +461,8 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
495
461
|
return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
|
|
496
462
|
});
|
|
497
463
|
|
|
498
|
-
for (var
|
|
499
|
-
var subObject = transformObject(subQueryObjects[
|
|
464
|
+
for (var _i = 0; _i < subQueryObjects.length; _i += 1) {
|
|
465
|
+
var subObject = transformObject(subQueryObjects[_i]);
|
|
500
466
|
return equalObjects(object[key], subObject[compareTo.key]);
|
|
501
467
|
}
|
|
502
468
|
|
|
@@ -509,8 +475,8 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
509
475
|
return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
|
|
510
476
|
});
|
|
511
477
|
|
|
512
|
-
for (var
|
|
513
|
-
var _subObject = transformObject(_subQueryObjects[
|
|
478
|
+
for (var _i2 = 0; _i2 < _subQueryObjects.length; _i2 += 1) {
|
|
479
|
+
var _subObject = transformObject(_subQueryObjects[_i2]);
|
|
514
480
|
|
|
515
481
|
return !equalObjects(object[key], _subObject[compareTo.key]);
|
|
516
482
|
}
|
|
@@ -524,8 +490,8 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
524
490
|
return matchesQuery(compareTo.className, obj, arr, compareTo.where);
|
|
525
491
|
});
|
|
526
492
|
|
|
527
|
-
for (var
|
|
528
|
-
var _subObject2 = transformObject(_subQueryObjects2[
|
|
493
|
+
for (var _i3 = 0; _i3 < _subQueryObjects2.length; _i3 += 1) {
|
|
494
|
+
var _subObject2 = transformObject(_subQueryObjects2[_i3]);
|
|
529
495
|
|
|
530
496
|
if (object[key].className === _subObject2.className && object[key].objectId === _subObject2.objectId) {
|
|
531
497
|
return true;
|
|
@@ -541,8 +507,8 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
541
507
|
return matchesQuery(compareTo.className, obj, arr, compareTo.where);
|
|
542
508
|
});
|
|
543
509
|
|
|
544
|
-
for (var
|
|
545
|
-
var _subObject3 = transformObject(_subQueryObjects3[
|
|
510
|
+
for (var _i4 = 0; _i4 < _subQueryObjects3.length; _i4 += 1) {
|
|
511
|
+
var _subObject3 = transformObject(_subQueryObjects3[_i4]);
|
|
546
512
|
|
|
547
513
|
if (object[key].className === _subObject3.className && object[key].objectId === _subObject3.objectId) {
|
|
548
514
|
return false;
|
|
@@ -554,9 +520,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
554
520
|
|
|
555
521
|
case '$containedBy':
|
|
556
522
|
{
|
|
557
|
-
for (var
|
|
558
|
-
var value = _step.value;
|
|
559
|
-
|
|
523
|
+
for (var value of object[key]) {
|
|
560
524
|
if (!contains(compareTo, value)) {
|
|
561
525
|
return false;
|
|
562
526
|
}
|
|
@@ -623,13 +587,13 @@ function validateQuery(query) {
|
|
|
623
587
|
if (q && q[key] && q[key].$regex) {
|
|
624
588
|
if (typeof q[key].$options === 'string') {
|
|
625
589
|
if (!q[key].$options.match(/^[imxs]+$/)) {
|
|
626
|
-
throw new ParseError(ParseError.INVALID_QUERY,
|
|
590
|
+
throw new ParseError(ParseError.INVALID_QUERY, `Bad $options value for query: ${q[key].$options}`);
|
|
627
591
|
}
|
|
628
592
|
}
|
|
629
593
|
}
|
|
630
594
|
|
|
631
595
|
if (specialQuerykeys.indexOf(key) < 0 && !key.match(/^[a-zA-Z][a-zA-Z0-9_\.]*$/)) {
|
|
632
|
-
throw new ParseError(ParseError.INVALID_KEY_NAME,
|
|
596
|
+
throw new ParseError(ParseError.INVALID_KEY_NAME, `Invalid key name: ${key}`);
|
|
633
597
|
}
|
|
634
598
|
});
|
|
635
599
|
}
|
|
@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
|
|
10
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
9
|
|
|
14
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
@@ -19,72 +15,6 @@ var _ParseRole = _interopRequireDefault(require("./ParseRole"));
|
|
|
19
15
|
|
|
20
16
|
var _ParseUser = _interopRequireDefault(require("./ParseUser"));
|
|
21
17
|
|
|
22
|
-
function ownKeys(object, enumerableOnly) {
|
|
23
|
-
var keys = Object.keys(object);
|
|
24
|
-
|
|
25
|
-
if (Object.getOwnPropertySymbols) {
|
|
26
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
27
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
28
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
29
|
-
})), keys.push.apply(keys, symbols);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return keys;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function _objectSpread(target) {
|
|
36
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
37
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
38
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
39
|
-
(0, _defineProperty2.default)(target, key, source[key]);
|
|
40
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
41
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return target;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
49
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
50
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
51
|
-
|
|
52
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
53
|
-
if (it) o = it;
|
|
54
|
-
var i = 0;
|
|
55
|
-
return function () {
|
|
56
|
-
if (i >= o.length) return {
|
|
57
|
-
done: true
|
|
58
|
-
};
|
|
59
|
-
return {
|
|
60
|
-
done: false,
|
|
61
|
-
value: o[i++]
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
70
|
-
if (!o) return;
|
|
71
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
72
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
73
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
74
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
75
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function _arrayLikeToArray(arr, len) {
|
|
79
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
80
|
-
|
|
81
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
82
|
-
arr2[i] = arr[i];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return arr2;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
18
|
var PUBLIC_KEY = '*';
|
|
89
19
|
var VALID_PERMISSIONS = new Map();
|
|
90
20
|
VALID_PERMISSIONS.set('get', {});
|
|
@@ -104,54 +34,52 @@ var ParseCLP = function () {
|
|
|
104
34
|
(0, _classCallCheck2.default)(this, ParseCLP);
|
|
105
35
|
this.permissionsMap = {};
|
|
106
36
|
|
|
107
|
-
var _loop = function
|
|
108
|
-
_this.permissionsMap[operation] =
|
|
37
|
+
var _loop = function (operation, group) {
|
|
38
|
+
_this.permissionsMap[operation] = Object.assign({}, group);
|
|
109
39
|
var action = operation.charAt(0).toUpperCase() + operation.slice(1);
|
|
110
40
|
|
|
111
|
-
_this[
|
|
41
|
+
_this[`get${action}RequiresAuthentication`] = function () {
|
|
112
42
|
return this._getAccess(operation, 'requiresAuthentication');
|
|
113
43
|
};
|
|
114
44
|
|
|
115
|
-
_this[
|
|
45
|
+
_this[`set${action}RequiresAuthentication`] = function (allowed) {
|
|
116
46
|
this._setAccess(operation, 'requiresAuthentication', allowed);
|
|
117
47
|
};
|
|
118
48
|
|
|
119
|
-
_this[
|
|
49
|
+
_this[`get${action}PointerFields`] = function () {
|
|
120
50
|
return this._getAccess(operation, 'pointerFields', false);
|
|
121
51
|
};
|
|
122
52
|
|
|
123
|
-
_this[
|
|
53
|
+
_this[`set${action}PointerFields`] = function (pointerFields) {
|
|
124
54
|
this._setArrayAccess(operation, 'pointerFields', pointerFields);
|
|
125
55
|
};
|
|
126
56
|
|
|
127
|
-
_this[
|
|
57
|
+
_this[`get${action}Access`] = function (entity) {
|
|
128
58
|
return this._getAccess(operation, entity);
|
|
129
59
|
};
|
|
130
60
|
|
|
131
|
-
_this[
|
|
61
|
+
_this[`set${action}Access`] = function (entity, allowed) {
|
|
132
62
|
this._setAccess(operation, entity, allowed);
|
|
133
63
|
};
|
|
134
64
|
|
|
135
|
-
_this[
|
|
136
|
-
return this[
|
|
65
|
+
_this[`getPublic${action}Access`] = function () {
|
|
66
|
+
return this[`get${action}Access`](PUBLIC_KEY);
|
|
137
67
|
};
|
|
138
68
|
|
|
139
|
-
_this[
|
|
140
|
-
this[
|
|
69
|
+
_this[`setPublic${action}Access`] = function (allowed) {
|
|
70
|
+
this[`set${action}Access`](PUBLIC_KEY, allowed);
|
|
141
71
|
};
|
|
142
72
|
|
|
143
|
-
_this[
|
|
144
|
-
return this[
|
|
73
|
+
_this[`getRole${action}Access`] = function (role) {
|
|
74
|
+
return this[`get${action}Access`](this._getRoleName(role));
|
|
145
75
|
};
|
|
146
76
|
|
|
147
|
-
_this[
|
|
148
|
-
this[
|
|
77
|
+
_this[`setRole${action}Access`] = function (role, allowed) {
|
|
78
|
+
this[`set${action}Access`](this._getRoleName(role), allowed);
|
|
149
79
|
};
|
|
150
80
|
};
|
|
151
81
|
|
|
152
|
-
for (var
|
|
153
|
-
var _ref = _step.value;
|
|
154
|
-
|
|
82
|
+
for (var _ref of VALID_PERMISSIONS.entries()) {
|
|
155
83
|
var _ref2 = (0, _slicedToArray2.default)(_ref, 2);
|
|
156
84
|
|
|
157
85
|
var operation = _ref2[0];
|
|
@@ -160,14 +88,12 @@ var ParseCLP = function () {
|
|
|
160
88
|
_loop(operation, group);
|
|
161
89
|
}
|
|
162
90
|
|
|
163
|
-
for (var
|
|
164
|
-
var _ref3 = _step2.value;
|
|
165
|
-
|
|
91
|
+
for (var _ref3 of VALID_PERMISSIONS_EXTENDED.entries()) {
|
|
166
92
|
var _ref4 = (0, _slicedToArray2.default)(_ref3, 2);
|
|
167
93
|
|
|
168
|
-
var
|
|
169
|
-
var
|
|
170
|
-
this.permissionsMap[
|
|
94
|
+
var _operation = _ref4[0];
|
|
95
|
+
var _group = _ref4[1];
|
|
96
|
+
this.permissionsMap[_operation] = Object.assign({}, _group);
|
|
171
97
|
}
|
|
172
98
|
|
|
173
99
|
if (userId && typeof userId === 'object') {
|
|
@@ -217,12 +143,12 @@ var ParseCLP = function () {
|
|
|
217
143
|
|
|
218
144
|
(0, _createClass2.default)(ParseCLP, [{
|
|
219
145
|
key: "toJSON",
|
|
220
|
-
value: function
|
|
221
|
-
return
|
|
146
|
+
value: function () {
|
|
147
|
+
return Object.assign({}, this.permissionsMap);
|
|
222
148
|
}
|
|
223
149
|
}, {
|
|
224
150
|
key: "equals",
|
|
225
|
-
value: function
|
|
151
|
+
value: function (other) {
|
|
226
152
|
if (!(other instanceof ParseCLP)) {
|
|
227
153
|
return false;
|
|
228
154
|
}
|
|
@@ -261,7 +187,7 @@ var ParseCLP = function () {
|
|
|
261
187
|
}
|
|
262
188
|
}, {
|
|
263
189
|
key: "_getRoleName",
|
|
264
|
-
value: function
|
|
190
|
+
value: function (role) {
|
|
265
191
|
var name = role;
|
|
266
192
|
|
|
267
193
|
if (role instanceof _ParseRole.default) {
|
|
@@ -272,11 +198,11 @@ var ParseCLP = function () {
|
|
|
272
198
|
throw new TypeError('role must be a Parse.Role or a String');
|
|
273
199
|
}
|
|
274
200
|
|
|
275
|
-
return
|
|
201
|
+
return `role:${name}`;
|
|
276
202
|
}
|
|
277
203
|
}, {
|
|
278
204
|
key: "_parseEntity",
|
|
279
|
-
value: function
|
|
205
|
+
value: function (entity) {
|
|
280
206
|
var userId = entity;
|
|
281
207
|
|
|
282
208
|
if (userId instanceof _ParseUser.default) {
|
|
@@ -297,7 +223,7 @@ var ParseCLP = function () {
|
|
|
297
223
|
}
|
|
298
224
|
}, {
|
|
299
225
|
key: "_setAccess",
|
|
300
|
-
value: function
|
|
226
|
+
value: function (permission, userId, allowed) {
|
|
301
227
|
userId = this._parseEntity(userId);
|
|
302
228
|
|
|
303
229
|
if (typeof allowed !== 'boolean') {
|
|
@@ -322,7 +248,7 @@ var ParseCLP = function () {
|
|
|
322
248
|
}
|
|
323
249
|
}, {
|
|
324
250
|
key: "_getAccess",
|
|
325
|
-
value: function
|
|
251
|
+
value: function (permission, userId) {
|
|
326
252
|
var returnBoolean = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
327
253
|
userId = this._parseEntity(userId);
|
|
328
254
|
var permissions = this.permissionsMap[permission][userId];
|
|
@@ -339,7 +265,7 @@ var ParseCLP = function () {
|
|
|
339
265
|
}
|
|
340
266
|
}, {
|
|
341
267
|
key: "_setArrayAccess",
|
|
342
|
-
value: function
|
|
268
|
+
value: function (permission, userId, fields) {
|
|
343
269
|
userId = this._parseEntity(userId);
|
|
344
270
|
var permissions = this.permissionsMap[permission][userId];
|
|
345
271
|
|
|
@@ -359,7 +285,7 @@ var ParseCLP = function () {
|
|
|
359
285
|
}
|
|
360
286
|
}, {
|
|
361
287
|
key: "_setGroupPointerPermission",
|
|
362
|
-
value: function
|
|
288
|
+
value: function (operation, pointerFields) {
|
|
363
289
|
var fields = this.permissionsMap[operation];
|
|
364
290
|
|
|
365
291
|
if (!fields) {
|
|
@@ -373,47 +299,47 @@ var ParseCLP = function () {
|
|
|
373
299
|
})) {
|
|
374
300
|
this.permissionsMap[operation] = pointerFields;
|
|
375
301
|
} else {
|
|
376
|
-
throw new TypeError(operation
|
|
302
|
+
throw new TypeError(`${operation}.pointerFields must be an array of strings or undefined.`);
|
|
377
303
|
}
|
|
378
304
|
}
|
|
379
305
|
}, {
|
|
380
306
|
key: "_getGroupPointerPermissions",
|
|
381
|
-
value: function
|
|
307
|
+
value: function (operation) {
|
|
382
308
|
return this.permissionsMap[operation];
|
|
383
309
|
}
|
|
384
310
|
}, {
|
|
385
311
|
key: "setReadUserFields",
|
|
386
|
-
value: function
|
|
312
|
+
value: function (pointerFields) {
|
|
387
313
|
this._setGroupPointerPermission('readUserFields', pointerFields);
|
|
388
314
|
}
|
|
389
315
|
}, {
|
|
390
316
|
key: "getReadUserFields",
|
|
391
|
-
value: function
|
|
317
|
+
value: function () {
|
|
392
318
|
return this._getGroupPointerPermissions('readUserFields');
|
|
393
319
|
}
|
|
394
320
|
}, {
|
|
395
321
|
key: "setWriteUserFields",
|
|
396
|
-
value: function
|
|
322
|
+
value: function (pointerFields) {
|
|
397
323
|
this._setGroupPointerPermission('writeUserFields', pointerFields);
|
|
398
324
|
}
|
|
399
325
|
}, {
|
|
400
326
|
key: "getWriteUserFields",
|
|
401
|
-
value: function
|
|
327
|
+
value: function () {
|
|
402
328
|
return this._getGroupPointerPermissions('writeUserFields');
|
|
403
329
|
}
|
|
404
330
|
}, {
|
|
405
331
|
key: "setProtectedFields",
|
|
406
|
-
value: function
|
|
332
|
+
value: function (userId, fields) {
|
|
407
333
|
this._setArrayAccess('protectedFields', userId, fields);
|
|
408
334
|
}
|
|
409
335
|
}, {
|
|
410
336
|
key: "getProtectedFields",
|
|
411
|
-
value: function
|
|
337
|
+
value: function (userId) {
|
|
412
338
|
return this._getAccess('protectedFields', userId, false);
|
|
413
339
|
}
|
|
414
340
|
}, {
|
|
415
341
|
key: "setReadAccess",
|
|
416
|
-
value: function
|
|
342
|
+
value: function (userId, allowed) {
|
|
417
343
|
this._setAccess('find', userId, allowed);
|
|
418
344
|
|
|
419
345
|
this._setAccess('get', userId, allowed);
|
|
@@ -422,12 +348,12 @@ var ParseCLP = function () {
|
|
|
422
348
|
}
|
|
423
349
|
}, {
|
|
424
350
|
key: "getReadAccess",
|
|
425
|
-
value: function
|
|
351
|
+
value: function (userId) {
|
|
426
352
|
return this._getAccess('find', userId) && this._getAccess('get', userId) && this._getAccess('count', userId);
|
|
427
353
|
}
|
|
428
354
|
}, {
|
|
429
355
|
key: "setWriteAccess",
|
|
430
|
-
value: function
|
|
356
|
+
value: function (userId, allowed) {
|
|
431
357
|
this._setAccess('create', userId, allowed);
|
|
432
358
|
|
|
433
359
|
this._setAccess('update', userId, allowed);
|
|
@@ -438,67 +364,67 @@ var ParseCLP = function () {
|
|
|
438
364
|
}
|
|
439
365
|
}, {
|
|
440
366
|
key: "getWriteAccess",
|
|
441
|
-
value: function
|
|
367
|
+
value: function (userId) {
|
|
442
368
|
return this._getAccess('create', userId) && this._getAccess('update', userId) && this._getAccess('delete', userId) && this._getAccess('addField', userId);
|
|
443
369
|
}
|
|
444
370
|
}, {
|
|
445
371
|
key: "setPublicReadAccess",
|
|
446
|
-
value: function
|
|
372
|
+
value: function (allowed) {
|
|
447
373
|
this.setReadAccess(PUBLIC_KEY, allowed);
|
|
448
374
|
}
|
|
449
375
|
}, {
|
|
450
376
|
key: "getPublicReadAccess",
|
|
451
|
-
value: function
|
|
377
|
+
value: function () {
|
|
452
378
|
return this.getReadAccess(PUBLIC_KEY);
|
|
453
379
|
}
|
|
454
380
|
}, {
|
|
455
381
|
key: "setPublicWriteAccess",
|
|
456
|
-
value: function
|
|
382
|
+
value: function (allowed) {
|
|
457
383
|
this.setWriteAccess(PUBLIC_KEY, allowed);
|
|
458
384
|
}
|
|
459
385
|
}, {
|
|
460
386
|
key: "getPublicWriteAccess",
|
|
461
|
-
value: function
|
|
387
|
+
value: function () {
|
|
462
388
|
return this.getWriteAccess(PUBLIC_KEY);
|
|
463
389
|
}
|
|
464
390
|
}, {
|
|
465
391
|
key: "setPublicProtectedFields",
|
|
466
|
-
value: function
|
|
392
|
+
value: function (fields) {
|
|
467
393
|
this.setProtectedFields(PUBLIC_KEY, fields);
|
|
468
394
|
}
|
|
469
395
|
}, {
|
|
470
396
|
key: "getPublicProtectedFields",
|
|
471
|
-
value: function
|
|
397
|
+
value: function () {
|
|
472
398
|
return this.getProtectedFields(PUBLIC_KEY);
|
|
473
399
|
}
|
|
474
400
|
}, {
|
|
475
401
|
key: "getRoleReadAccess",
|
|
476
|
-
value: function
|
|
402
|
+
value: function (role) {
|
|
477
403
|
return this.getReadAccess(this._getRoleName(role));
|
|
478
404
|
}
|
|
479
405
|
}, {
|
|
480
406
|
key: "getRoleWriteAccess",
|
|
481
|
-
value: function
|
|
407
|
+
value: function (role) {
|
|
482
408
|
return this.getWriteAccess(this._getRoleName(role));
|
|
483
409
|
}
|
|
484
410
|
}, {
|
|
485
411
|
key: "setRoleReadAccess",
|
|
486
|
-
value: function
|
|
412
|
+
value: function (role, allowed) {
|
|
487
413
|
this.setReadAccess(this._getRoleName(role), allowed);
|
|
488
414
|
}
|
|
489
415
|
}, {
|
|
490
416
|
key: "setRoleWriteAccess",
|
|
491
|
-
value: function
|
|
417
|
+
value: function (role, allowed) {
|
|
492
418
|
this.setWriteAccess(this._getRoleName(role), allowed);
|
|
493
419
|
}
|
|
494
420
|
}, {
|
|
495
421
|
key: "getRoleProtectedFields",
|
|
496
|
-
value: function
|
|
422
|
+
value: function (role) {
|
|
497
423
|
return this.getProtectedFields(this._getRoleName(role));
|
|
498
424
|
}
|
|
499
425
|
}, {
|
|
500
426
|
key: "setRoleProtectedFields",
|
|
501
|
-
value: function
|
|
427
|
+
value: function (role, fields) {
|
|
502
428
|
this.setProtectedFields(this._getRoleName(role), fields);
|
|
503
429
|
}
|
|
504
430
|
}]);
|