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
|
@@ -8,29 +8,21 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
10
10
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
11
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
13
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
14
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
15
12
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
16
13
|
var _decode = _interopRequireDefault(require("./decode"));
|
|
17
14
|
var _encode = _interopRequireDefault(require("./encode"));
|
|
18
|
-
var
|
|
15
|
+
var _escape = _interopRequireDefault(require("./escape"));
|
|
19
16
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
20
17
|
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
21
|
-
/**
|
|
22
|
-
* @flow
|
|
23
|
-
*/
|
|
24
|
-
/*:: import type { RequestOptions } from './RESTController';*/
|
|
25
18
|
/**
|
|
26
19
|
* Parse.Config is a local representation of configuration data that
|
|
27
20
|
* can be set from the Parse dashboard.
|
|
28
21
|
*
|
|
29
22
|
* @alias Parse.Config
|
|
30
23
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
(0, _classCallCheck2.default)(this, ParseConfig);
|
|
24
|
+
class ParseConfig {
|
|
25
|
+
constructor() {
|
|
34
26
|
(0, _defineProperty2.default)(this, "attributes", void 0);
|
|
35
27
|
(0, _defineProperty2.default)(this, "_escapedAttributes", void 0);
|
|
36
28
|
this.attributes = {};
|
|
@@ -43,132 +35,118 @@ var ParseConfig = /*#__PURE__*/function () {
|
|
|
43
35
|
* @param {string} attr The name of an attribute.
|
|
44
36
|
* @returns {*}
|
|
45
37
|
*/
|
|
46
|
-
(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return this.attributes[attr];
|
|
50
|
-
}
|
|
38
|
+
get(attr) {
|
|
39
|
+
return this.attributes[attr];
|
|
40
|
+
}
|
|
51
41
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (html) {
|
|
63
|
-
return html;
|
|
64
|
-
}
|
|
65
|
-
var val = this.attributes[attr];
|
|
66
|
-
var escaped = '';
|
|
67
|
-
if (val != null) {
|
|
68
|
-
escaped = (0, _escape2.default)(val.toString());
|
|
69
|
-
}
|
|
70
|
-
this._escapedAttributes[attr] = escaped;
|
|
71
|
-
return escaped;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the HTML-escaped value of an attribute.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} attr The name of an attribute.
|
|
46
|
+
* @returns {string}
|
|
47
|
+
*/
|
|
48
|
+
escape(attr) {
|
|
49
|
+
const html = this._escapedAttributes[attr];
|
|
50
|
+
if (html) {
|
|
51
|
+
return html;
|
|
72
52
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
78
|
-
* @static
|
|
79
|
-
* @returns {Parse.Config} The most recently-fetched Parse.Config if it
|
|
80
|
-
* exists, else an empty Parse.Config.
|
|
81
|
-
*/
|
|
82
|
-
}], [{
|
|
83
|
-
key: "current",
|
|
84
|
-
value: function () {
|
|
85
|
-
var controller = _CoreManager.default.getConfigController();
|
|
86
|
-
return controller.current();
|
|
53
|
+
const val = this.attributes[attr];
|
|
54
|
+
let escaped = '';
|
|
55
|
+
if (val != null) {
|
|
56
|
+
escaped = (0, _escape.default)(val.toString());
|
|
87
57
|
}
|
|
58
|
+
this._escapedAttributes[attr] = escaped;
|
|
59
|
+
return escaped;
|
|
60
|
+
}
|
|
88
61
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}, {
|
|
102
|
-
key: "get",
|
|
103
|
-
value: function () {
|
|
104
|
-
var options /*: RequestOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
105
|
-
var controller = _CoreManager.default.getConfigController();
|
|
106
|
-
return controller.get(options);
|
|
107
|
-
}
|
|
62
|
+
/**
|
|
63
|
+
* Retrieves the most recently-fetched configuration object, either from
|
|
64
|
+
* memory or from local storage if necessary.
|
|
65
|
+
*
|
|
66
|
+
* @static
|
|
67
|
+
* @returns {Parse.Config} The most recently-fetched Parse.Config if it
|
|
68
|
+
* exists, else an empty Parse.Config.
|
|
69
|
+
*/
|
|
70
|
+
static current() {
|
|
71
|
+
const controller = _CoreManager.default.getConfigController();
|
|
72
|
+
return controller.current();
|
|
73
|
+
}
|
|
108
74
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Gets a new configuration object from the server.
|
|
77
|
+
*
|
|
78
|
+
* @static
|
|
79
|
+
* @param {object} options
|
|
80
|
+
* Valid options are:<ul>
|
|
81
|
+
* <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
|
|
82
|
+
* be used for this request.
|
|
83
|
+
* </ul>
|
|
84
|
+
* @returns {Promise} A promise that is resolved with a newly-created
|
|
85
|
+
* configuration object when the get completes.
|
|
86
|
+
*/
|
|
87
|
+
static get() {
|
|
88
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
89
|
+
const controller = _CoreManager.default.getConfigController();
|
|
90
|
+
return controller.get(options);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Save value keys to the server.
|
|
95
|
+
*
|
|
96
|
+
* @static
|
|
97
|
+
* @param {object} attrs The config parameters and values.
|
|
98
|
+
* @param {object} masterKeyOnlyFlags The flags that define whether config parameters listed
|
|
99
|
+
* in `attrs` should be retrievable only by using the master key.
|
|
100
|
+
* For example: `param1: true` makes `param1` only retrievable by using the master key.
|
|
101
|
+
* If a parameter is not provided or set to `false`, it can be retrieved without
|
|
102
|
+
* using the master key.
|
|
103
|
+
* @returns {Promise} A promise that is resolved with a newly-created
|
|
104
|
+
* configuration object or with the current with the update.
|
|
105
|
+
*/
|
|
106
|
+
static save(attrs, masterKeyOnlyFlags) {
|
|
107
|
+
const controller = _CoreManager.default.getConfigController();
|
|
108
|
+
//To avoid a mismatch with the local and the cloud config we get a new version
|
|
109
|
+
return controller.save(attrs, masterKeyOnlyFlags).then(() => {
|
|
110
|
+
return controller.get({
|
|
111
|
+
useMasterKey: true
|
|
133
112
|
});
|
|
134
|
-
}
|
|
113
|
+
}, error => {
|
|
114
|
+
return _promise.default.reject(error);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
135
117
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return ParseConfig;
|
|
148
|
-
}();
|
|
149
|
-
var currentConfig = null;
|
|
150
|
-
var CURRENT_CONFIG_KEY = 'currentConfig';
|
|
118
|
+
/**
|
|
119
|
+
* Used for testing
|
|
120
|
+
*
|
|
121
|
+
* @private
|
|
122
|
+
*/
|
|
123
|
+
static _clearCache() {
|
|
124
|
+
currentConfig = null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
let currentConfig = null;
|
|
128
|
+
const CURRENT_CONFIG_KEY = 'currentConfig';
|
|
151
129
|
function decodePayload(data) {
|
|
152
130
|
try {
|
|
153
|
-
|
|
154
|
-
if (json &&
|
|
131
|
+
const json = JSON.parse(data);
|
|
132
|
+
if (json && typeof json === 'object') {
|
|
155
133
|
return (0, _decode.default)(json);
|
|
156
134
|
}
|
|
157
135
|
} catch (e) {
|
|
158
136
|
return null;
|
|
159
137
|
}
|
|
160
138
|
}
|
|
161
|
-
|
|
162
|
-
current
|
|
139
|
+
const DefaultController = {
|
|
140
|
+
current() {
|
|
163
141
|
if (currentConfig) {
|
|
164
142
|
return currentConfig;
|
|
165
143
|
}
|
|
166
|
-
|
|
167
|
-
|
|
144
|
+
const config = new ParseConfig();
|
|
145
|
+
const storagePath = _Storage.default.generatePath(CURRENT_CONFIG_KEY);
|
|
168
146
|
if (!_Storage.default.async()) {
|
|
169
|
-
|
|
147
|
+
const configData = _Storage.default.getItem(storagePath);
|
|
170
148
|
if (configData) {
|
|
171
|
-
|
|
149
|
+
const attributes = decodePayload(configData);
|
|
172
150
|
if (attributes) {
|
|
173
151
|
config.attributes = attributes;
|
|
174
152
|
currentConfig = config;
|
|
@@ -177,57 +155,56 @@ var DefaultController = {
|
|
|
177
155
|
return config;
|
|
178
156
|
}
|
|
179
157
|
// Return a promise for async storage controllers
|
|
180
|
-
return _Storage.default.getItemAsync(storagePath).then(
|
|
158
|
+
return _Storage.default.getItemAsync(storagePath).then(configData => {
|
|
181
159
|
if (configData) {
|
|
182
|
-
|
|
183
|
-
if (
|
|
184
|
-
config.attributes =
|
|
160
|
+
const attributes = decodePayload(configData);
|
|
161
|
+
if (attributes) {
|
|
162
|
+
config.attributes = attributes;
|
|
185
163
|
currentConfig = config;
|
|
186
164
|
}
|
|
187
165
|
}
|
|
188
166
|
return config;
|
|
189
167
|
});
|
|
190
168
|
},
|
|
191
|
-
get
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return RESTController.request('GET', 'config', {}, options).then(
|
|
169
|
+
get() {
|
|
170
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
171
|
+
const RESTController = _CoreManager.default.getRESTController();
|
|
172
|
+
return RESTController.request('GET', 'config', {}, options).then(response => {
|
|
195
173
|
if (!response || !response.params) {
|
|
196
|
-
|
|
174
|
+
const error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Config JSON response invalid.');
|
|
197
175
|
return _promise.default.reject(error);
|
|
198
176
|
}
|
|
199
|
-
|
|
177
|
+
const config = new ParseConfig();
|
|
200
178
|
config.attributes = {};
|
|
201
|
-
for (
|
|
179
|
+
for (const attr in response.params) {
|
|
202
180
|
config.attributes[attr] = (0, _decode.default)(response.params[attr]);
|
|
203
181
|
}
|
|
204
182
|
currentConfig = config;
|
|
205
|
-
return _Storage.default.setItemAsync(_Storage.default.generatePath(CURRENT_CONFIG_KEY), (0, _stringify.default)(response.params)).then(
|
|
183
|
+
return _Storage.default.setItemAsync(_Storage.default.generatePath(CURRENT_CONFIG_KEY), (0, _stringify.default)(response.params)).then(() => {
|
|
206
184
|
return config;
|
|
207
185
|
});
|
|
208
186
|
});
|
|
209
187
|
},
|
|
210
|
-
save
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
for (
|
|
214
|
-
encodedAttrs[
|
|
188
|
+
save(attrs, masterKeyOnlyFlags) {
|
|
189
|
+
const RESTController = _CoreManager.default.getRESTController();
|
|
190
|
+
const encodedAttrs = {};
|
|
191
|
+
for (const key in attrs) {
|
|
192
|
+
encodedAttrs[key] = (0, _encode.default)(attrs[key]);
|
|
215
193
|
}
|
|
216
194
|
return RESTController.request('PUT', 'config', {
|
|
217
195
|
params: encodedAttrs,
|
|
218
196
|
masterKeyOnly: masterKeyOnlyFlags
|
|
219
197
|
}, {
|
|
220
198
|
useMasterKey: true
|
|
221
|
-
}).then(
|
|
199
|
+
}).then(response => {
|
|
222
200
|
if (response && response.result) {
|
|
223
201
|
return _promise.default.resolve();
|
|
224
202
|
} else {
|
|
225
|
-
|
|
203
|
+
const error = new _ParseError.default(_ParseError.default.INTERNAL_SERVER_ERROR, 'Error occured updating Config.');
|
|
226
204
|
return _promise.default.reject(error);
|
|
227
205
|
}
|
|
228
206
|
});
|
|
229
207
|
}
|
|
230
208
|
};
|
|
231
209
|
_CoreManager.default.setConfigController(DefaultController);
|
|
232
|
-
var _default = ParseConfig;
|
|
233
|
-
exports.default = _default;
|
|
210
|
+
var _default = exports.default = ParseConfig;
|