parse 4.0.0-alpha.1 → 4.0.0-alpha.11
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 +6 -5
- package/dist/parse.js +12838 -21190
- package/dist/parse.min.js +7 -6
- package/dist/parse.weapp.js +7921 -17062
- package/dist/parse.weapp.min.js +7 -6
- package/lib/browser/Analytics.js +2 -27
- package/lib/browser/AnonymousUtils.js +6 -42
- package/lib/browser/Cloud.js +12 -77
- package/lib/browser/CloudCode.js +0 -3
- package/lib/browser/CoreManager.js +46 -191
- package/lib/browser/CryptoController.js +2 -16
- package/lib/browser/EventEmitter.js +1 -8
- package/lib/browser/EventuallyQueue.js +277 -824
- package/lib/browser/FacebookUtils.js +6 -42
- package/lib/browser/IndexedDBStorageController.js +3 -14
- package/lib/browser/InstallationController.js +2 -20
- package/lib/browser/LiveQueryClient.js +105 -213
- package/lib/browser/LiveQuerySubscription.js +10 -39
- package/lib/browser/LocalDatastore.js +451 -1081
- package/lib/browser/LocalDatastoreController.js +145 -602
- package/lib/browser/LocalDatastoreController.react-native.js +137 -573
- package/lib/browser/LocalDatastoreUtils.js +2 -19
- package/lib/browser/ObjectStateMutations.js +18 -121
- package/lib/browser/OfflineQuery.js +61 -222
- package/lib/browser/Parse.js +12 -115
- package/lib/browser/ParseACL.js +33 -148
- package/lib/browser/ParseCLP.js +96 -314
- package/lib/browser/ParseConfig.js +18 -95
- package/lib/browser/ParseError.js +63 -99
- package/lib/browser/ParseFile.js +128 -685
- package/lib/browser/ParseGeoPoint.js +23 -89
- package/lib/browser/ParseHooks.js +1 -34
- package/lib/browser/ParseInstallation.js +4 -32
- package/lib/browser/ParseLiveQuery.js +96 -505
- package/lib/browser/ParseObject.js +665 -1845
- package/lib/browser/ParseOp.js +41 -287
- package/lib/browser/ParsePolygon.js +13 -70
- package/lib/browser/ParseQuery.js +403 -1504
- package/lib/browser/ParseRelation.js +12 -68
- package/lib/browser/ParseRole.js +13 -75
- package/lib/browser/ParseSchema.js +49 -208
- package/lib/browser/ParseSession.js +11 -69
- package/lib/browser/ParseUser.js +274 -1127
- package/lib/browser/Push.js +7 -50
- package/lib/browser/RESTController.js +28 -157
- package/lib/browser/SingleInstanceStateController.js +19 -144
- package/lib/browser/Socket.weapp.js +0 -10
- package/lib/browser/Storage.js +10 -80
- package/lib/browser/StorageController.browser.js +4 -24
- package/lib/browser/StorageController.default.js +4 -24
- package/lib/browser/StorageController.react-native.js +6 -40
- package/lib/browser/StorageController.weapp.js +5 -23
- package/lib/browser/TaskQueue.js +1 -29
- package/lib/browser/UniqueInstanceStateController.js +19 -149
- package/lib/browser/Xhr.weapp.js +0 -17
- package/lib/browser/arrayContainsObject.js +2 -23
- package/lib/browser/canBeSerialized.js +3 -40
- package/lib/browser/decode.js +3 -40
- package/lib/browser/encode.js +9 -77
- package/lib/browser/equals.js +2 -34
- package/lib/browser/escape.js +1 -15
- package/lib/browser/isRevocableSession.js +2 -18
- package/lib/browser/parseDate.js +2 -20
- package/lib/browser/promiseUtils.js +3 -21
- package/lib/browser/unique.js +3 -24
- package/lib/browser/unsavedChildren.js +6 -57
- package/lib/browser/uuid.js +3 -1
- package/lib/node/Analytics.js +1 -25
- package/lib/node/AnonymousUtils.js +5 -44
- package/lib/node/Cloud.js +10 -73
- package/lib/node/CloudCode.js +0 -3
- package/lib/node/CoreManager.js +47 -227
- package/lib/node/CryptoController.js +2 -16
- package/lib/node/EventEmitter.js +1 -8
- package/lib/node/EventuallyQueue.js +16 -123
- package/lib/node/FacebookUtils.js +5 -44
- package/lib/node/IndexedDBStorageController.js +3 -19
- package/lib/node/InstallationController.js +2 -22
- package/lib/node/LiveQueryClient.js +72 -154
- package/lib/node/LiveQuerySubscription.js +7 -26
- package/lib/node/LocalDatastore.js +19 -182
- package/lib/node/LocalDatastoreController.js +6 -45
- package/lib/node/LocalDatastoreController.react-native.js +6 -52
- package/lib/node/LocalDatastoreUtils.js +1 -13
- package/lib/node/ObjectStateMutations.js +13 -100
- package/lib/node/OfflineQuery.js +27 -151
- package/lib/node/Parse.js +11 -108
- package/lib/node/ParseACL.js +32 -157
- package/lib/node/ParseCLP.js +69 -269
- package/lib/node/ParseConfig.js +16 -91
- package/lib/node/ParseError.js +61 -74
- package/lib/node/ParseFile.js +49 -212
- package/lib/node/ParseGeoPoint.js +21 -89
- package/lib/node/ParseHooks.js +0 -35
- package/lib/node/ParseInstallation.js +1 -17
- package/lib/node/ParseLiveQuery.js +10 -43
- package/lib/node/ParseObject.js +229 -964
- package/lib/node/ParseOp.js +31 -262
- package/lib/node/ParsePolygon.js +12 -69
- package/lib/node/ParseQuery.js +169 -888
- package/lib/node/ParseRelation.js +11 -68
- package/lib/node/ParseRole.js +10 -64
- package/lib/node/ParseSchema.js +46 -229
- package/lib/node/ParseSession.js +8 -57
- package/lib/node/ParseUser.js +107 -583
- package/lib/node/Push.js +4 -44
- package/lib/node/RESTController.js +18 -127
- package/lib/node/SingleInstanceStateController.js +17 -137
- package/lib/node/Socket.weapp.js +0 -7
- package/lib/node/Storage.js +10 -90
- package/lib/node/StorageController.browser.js +4 -30
- package/lib/node/StorageController.default.js +5 -28
- package/lib/node/StorageController.react-native.js +6 -47
- package/lib/node/StorageController.weapp.js +6 -28
- package/lib/node/TaskQueue.js +1 -24
- package/lib/node/UniqueInstanceStateController.js +16 -140
- package/lib/node/Xhr.weapp.js +0 -15
- package/lib/node/arrayContainsObject.js +1 -19
- package/lib/node/canBeSerialized.js +2 -35
- package/lib/node/decode.js +1 -33
- package/lib/node/encode.js +3 -61
- package/lib/node/equals.js +0 -27
- package/lib/node/escape.js +1 -13
- package/lib/node/isRevocableSession.js +1 -12
- package/lib/node/parseDate.js +1 -14
- package/lib/node/promiseUtils.js +2 -14
- package/lib/node/unique.js +1 -18
- package/lib/node/unsavedChildren.js +2 -45
- package/lib/node/uuid.js +6 -1
- package/lib/react-native/Analytics.js +0 -9
- package/lib/react-native/AnonymousUtils.js +0 -10
- package/lib/react-native/Cloud.js +0 -26
- package/lib/react-native/CoreManager.js +2 -6
- package/lib/react-native/CryptoController.js +0 -2
- package/lib/react-native/EventEmitter.js +0 -2
- package/lib/react-native/EventuallyQueue.js +156 -711
- package/lib/react-native/FacebookUtils.js +0 -22
- package/lib/react-native/IndexedDBStorageController.js +0 -1
- package/lib/react-native/InstallationController.js +0 -6
- package/lib/react-native/LiveQueryClient.js +46 -157
- package/lib/react-native/LiveQuerySubscription.js +3 -27
- package/lib/react-native/LocalDatastore.js +281 -948
- package/lib/react-native/LocalDatastoreController.js +71 -552
- package/lib/react-native/LocalDatastoreController.react-native.js +91 -526
- package/lib/react-native/LocalDatastoreUtils.js +0 -1
- package/lib/react-native/ObjectStateMutations.js +2 -65
- package/lib/react-native/OfflineQuery.js +25 -196
- package/lib/react-native/Parse.js +0 -65
- package/lib/react-native/ParseACL.js +0 -44
- package/lib/react-native/ParseCLP.js +23 -161
- package/lib/react-native/ParseConfig.js +0 -42
- package/lib/react-native/ParseError.js +1 -21
- package/lib/react-native/ParseFile.js +55 -529
- package/lib/react-native/ParseGeoPoint.js +0 -17
- package/lib/react-native/ParseHooks.js +0 -30
- package/lib/react-native/ParseInstallation.js +1 -23
- package/lib/react-native/ParseLiveQuery.js +55 -472
- package/lib/react-native/ParseObject.js +245 -1246
- package/lib/react-native/ParseOp.js +1 -138
- package/lib/react-native/ParsePolygon.js +0 -24
- package/lib/react-native/ParseQuery.js +182 -874
- package/lib/react-native/ParseRelation.js +0 -25
- package/lib/react-native/ParseRole.js +1 -36
- package/lib/react-native/ParseSchema.js +3 -54
- package/lib/react-native/ParseSession.js +1 -40
- package/lib/react-native/ParseUser.js +95 -773
- package/lib/react-native/Push.js +0 -16
- package/lib/react-native/RESTController.js +12 -109
- package/lib/react-native/SingleInstanceStateController.js +0 -44
- package/lib/react-native/Socket.weapp.js +0 -10
- package/lib/react-native/Storage.js +0 -24
- package/lib/react-native/StorageController.browser.js +0 -2
- package/lib/react-native/StorageController.default.js +0 -1
- package/lib/react-native/StorageController.react-native.js +0 -2
- package/lib/react-native/TaskQueue.js +0 -15
- package/lib/react-native/UniqueInstanceStateController.js +0 -47
- package/lib/react-native/Xhr.weapp.js +0 -16
- package/lib/react-native/arrayContainsObject.js +0 -5
- package/lib/react-native/canBeSerialized.js +0 -18
- package/lib/react-native/decode.js +0 -21
- package/lib/react-native/encode.js +0 -25
- package/lib/react-native/equals.js +0 -18
- package/lib/react-native/escape.js +0 -1
- package/lib/react-native/isRevocableSession.js +0 -1
- package/lib/react-native/parseDate.js +0 -3
- package/lib/react-native/promiseUtils.js +0 -13
- package/lib/react-native/unique.js +0 -4
- package/lib/react-native/unsavedChildren.js +0 -21
- package/lib/react-native/uuid.js +3 -1
- package/lib/weapp/Analytics.js +2 -27
- package/lib/weapp/AnonymousUtils.js +6 -42
- package/lib/weapp/Cloud.js +12 -77
- package/lib/weapp/CloudCode.js +0 -3
- package/lib/weapp/CoreManager.js +46 -191
- package/lib/weapp/CryptoController.js +2 -16
- package/lib/weapp/EventEmitter.js +1 -8
- package/lib/weapp/EventuallyQueue.js +277 -824
- package/lib/weapp/FacebookUtils.js +6 -42
- package/lib/weapp/IndexedDBStorageController.js +3 -14
- package/lib/weapp/InstallationController.js +2 -20
- package/lib/weapp/LiveQueryClient.js +105 -213
- package/lib/weapp/LiveQuerySubscription.js +10 -39
- package/lib/weapp/LocalDatastore.js +451 -1081
- package/lib/weapp/LocalDatastoreController.js +145 -602
- package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
- package/lib/weapp/LocalDatastoreUtils.js +2 -19
- package/lib/weapp/ObjectStateMutations.js +18 -121
- package/lib/weapp/OfflineQuery.js +61 -222
- package/lib/weapp/Parse.js +12 -115
- package/lib/weapp/ParseACL.js +33 -148
- package/lib/weapp/ParseCLP.js +96 -314
- package/lib/weapp/ParseConfig.js +18 -95
- package/lib/weapp/ParseError.js +63 -99
- package/lib/weapp/ParseFile.js +129 -686
- package/lib/weapp/ParseGeoPoint.js +23 -89
- package/lib/weapp/ParseHooks.js +1 -34
- package/lib/weapp/ParseInstallation.js +4 -32
- package/lib/weapp/ParseLiveQuery.js +96 -505
- package/lib/weapp/ParseObject.js +665 -1845
- package/lib/weapp/ParseOp.js +41 -287
- package/lib/weapp/ParsePolygon.js +13 -70
- package/lib/weapp/ParseQuery.js +403 -1504
- package/lib/weapp/ParseRelation.js +12 -68
- package/lib/weapp/ParseRole.js +13 -75
- package/lib/weapp/ParseSchema.js +49 -208
- package/lib/weapp/ParseSession.js +11 -69
- package/lib/weapp/ParseUser.js +274 -1127
- package/lib/weapp/Push.js +7 -50
- package/lib/weapp/RESTController.js +28 -157
- package/lib/weapp/SingleInstanceStateController.js +19 -144
- package/lib/weapp/Socket.weapp.js +0 -10
- package/lib/weapp/Storage.js +10 -80
- package/lib/weapp/StorageController.browser.js +4 -24
- package/lib/weapp/StorageController.default.js +4 -24
- package/lib/weapp/StorageController.react-native.js +6 -40
- package/lib/weapp/StorageController.weapp.js +5 -23
- package/lib/weapp/TaskQueue.js +1 -29
- package/lib/weapp/UniqueInstanceStateController.js +19 -149
- package/lib/weapp/Xhr.weapp.js +0 -17
- package/lib/weapp/arrayContainsObject.js +2 -23
- package/lib/weapp/canBeSerialized.js +3 -40
- package/lib/weapp/decode.js +3 -40
- package/lib/weapp/encode.js +9 -77
- package/lib/weapp/equals.js +2 -34
- package/lib/weapp/escape.js +1 -15
- package/lib/weapp/isRevocableSession.js +2 -18
- package/lib/weapp/parseDate.js +2 -20
- package/lib/weapp/promiseUtils.js +3 -21
- package/lib/weapp/unique.js +3 -24
- package/lib/weapp/unsavedChildren.js +6 -57
- package/lib/weapp/uuid.js +1 -6
- package/package.json +35 -31
- package/PATENTS +0 -37
|
@@ -1,57 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
6
|
-
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
exports.default = void 0;
|
|
12
|
-
|
|
9
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
13
10
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
14
|
-
|
|
15
11
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
16
|
-
|
|
17
|
-
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
18
|
-
|
|
19
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
20
|
-
|
|
21
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
22
|
-
|
|
23
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
24
|
-
|
|
25
15
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
26
|
-
|
|
27
16
|
var _decode = _interopRequireDefault(require("./decode"));
|
|
28
|
-
|
|
29
17
|
var _encode = _interopRequireDefault(require("./encode"));
|
|
30
|
-
|
|
31
18
|
var _escape2 = _interopRequireDefault(require("./escape"));
|
|
32
|
-
|
|
33
19
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
34
|
-
|
|
35
20
|
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
36
21
|
/**
|
|
37
|
-
* Copyright (c) 2015-present, Parse, LLC.
|
|
38
|
-
* All rights reserved.
|
|
39
|
-
*
|
|
40
|
-
* This source code is licensed under the BSD-style license found in the
|
|
41
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
42
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
43
|
-
*
|
|
44
22
|
* @flow
|
|
45
23
|
*/
|
|
46
|
-
|
|
47
24
|
/**
|
|
48
25
|
* Parse.Config is a local representation of configuration data that
|
|
49
26
|
* can be set from the Parse dashboard.
|
|
50
27
|
*
|
|
51
28
|
* @alias Parse.Config
|
|
52
29
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
30
|
var ParseConfig = /*#__PURE__*/function () {
|
|
56
31
|
function ParseConfig() {
|
|
57
32
|
(0, _classCallCheck2.default)(this, ParseConfig);
|
|
@@ -60,53 +35,41 @@ var ParseConfig = /*#__PURE__*/function () {
|
|
|
60
35
|
this.attributes = {};
|
|
61
36
|
this._escapedAttributes = {};
|
|
62
37
|
}
|
|
38
|
+
|
|
63
39
|
/**
|
|
64
40
|
* Gets the value of an attribute.
|
|
65
41
|
*
|
|
66
42
|
* @param {string} attr The name of an attribute.
|
|
67
43
|
* @returns {*}
|
|
68
44
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
45
|
(0, _createClass2.default)(ParseConfig, [{
|
|
72
46
|
key: "get",
|
|
73
|
-
value: function (attr
|
|
74
|
-
/*: string*/
|
|
75
|
-
)
|
|
76
|
-
/*: any*/
|
|
77
|
-
{
|
|
47
|
+
value: function (attr /*: string*/) /*: any*/{
|
|
78
48
|
return this.attributes[attr];
|
|
79
49
|
}
|
|
50
|
+
|
|
80
51
|
/**
|
|
81
52
|
* Gets the HTML-escaped value of an attribute.
|
|
82
53
|
*
|
|
83
54
|
* @param {string} attr The name of an attribute.
|
|
84
55
|
* @returns {string}
|
|
85
56
|
*/
|
|
86
|
-
|
|
87
57
|
}, {
|
|
88
58
|
key: "escape",
|
|
89
|
-
value: function (attr
|
|
90
|
-
/*: string*/
|
|
91
|
-
)
|
|
92
|
-
/*: string*/
|
|
93
|
-
{
|
|
59
|
+
value: function (attr /*: string*/) /*: string*/{
|
|
94
60
|
var html = this._escapedAttributes[attr];
|
|
95
|
-
|
|
96
61
|
if (html) {
|
|
97
62
|
return html;
|
|
98
63
|
}
|
|
99
|
-
|
|
100
64
|
var val = this.attributes[attr];
|
|
101
65
|
var escaped = '';
|
|
102
|
-
|
|
103
66
|
if (val != null) {
|
|
104
67
|
escaped = (0, _escape2.default)(val.toString());
|
|
105
68
|
}
|
|
106
|
-
|
|
107
69
|
this._escapedAttributes[attr] = escaped;
|
|
108
70
|
return escaped;
|
|
109
71
|
}
|
|
72
|
+
|
|
110
73
|
/**
|
|
111
74
|
* Retrieves the most recently-fetched configuration object, either from
|
|
112
75
|
* memory or from local storage if necessary.
|
|
@@ -115,14 +78,13 @@ var ParseConfig = /*#__PURE__*/function () {
|
|
|
115
78
|
* @returns {Parse.Config} The most recently-fetched Parse.Config if it
|
|
116
79
|
* exists, else an empty Parse.Config.
|
|
117
80
|
*/
|
|
118
|
-
|
|
119
81
|
}], [{
|
|
120
82
|
key: "current",
|
|
121
83
|
value: function () {
|
|
122
84
|
var controller = _CoreManager.default.getConfigController();
|
|
123
|
-
|
|
124
85
|
return controller.current();
|
|
125
86
|
}
|
|
87
|
+
|
|
126
88
|
/**
|
|
127
89
|
* Gets a new configuration object from the server.
|
|
128
90
|
*
|
|
@@ -135,18 +97,14 @@ var ParseConfig = /*#__PURE__*/function () {
|
|
|
135
97
|
* @returns {Promise} A promise that is resolved with a newly-created
|
|
136
98
|
* configuration object when the get completes.
|
|
137
99
|
*/
|
|
138
|
-
|
|
139
100
|
}, {
|
|
140
101
|
key: "get",
|
|
141
102
|
value: function () {
|
|
142
|
-
var options
|
|
143
|
-
/*: RequestOptions*/
|
|
144
|
-
= arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
145
|
-
|
|
103
|
+
var options /*: RequestOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
146
104
|
var controller = _CoreManager.default.getConfigController();
|
|
147
|
-
|
|
148
105
|
return controller.get(options);
|
|
149
106
|
}
|
|
107
|
+
|
|
150
108
|
/**
|
|
151
109
|
* Save value keys to the server.
|
|
152
110
|
*
|
|
@@ -160,17 +118,11 @@ var ParseConfig = /*#__PURE__*/function () {
|
|
|
160
118
|
* @returns {Promise} A promise that is resolved with a newly-created
|
|
161
119
|
* configuration object or with the current with the update.
|
|
162
120
|
*/
|
|
163
|
-
|
|
164
121
|
}, {
|
|
165
122
|
key: "save",
|
|
166
|
-
value: function (attrs
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
/*: { [key: string]: any }*/
|
|
170
|
-
) {
|
|
171
|
-
var controller = _CoreManager.default.getConfigController(); //To avoid a mismatch with the local and the cloud config we get a new version
|
|
172
|
-
|
|
173
|
-
|
|
123
|
+
value: function (attrs /*: { [key: string]: any }*/, masterKeyOnlyFlags /*: { [key: string]: any }*/) {
|
|
124
|
+
var controller = _CoreManager.default.getConfigController();
|
|
125
|
+
//To avoid a mismatch with the local and the cloud config we get a new version
|
|
174
126
|
return controller.save(attrs, masterKeyOnlyFlags).then(function () {
|
|
175
127
|
return controller.get({
|
|
176
128
|
useMasterKey: true
|
|
@@ -179,12 +131,12 @@ var ParseConfig = /*#__PURE__*/function () {
|
|
|
179
131
|
return _promise.default.reject(error);
|
|
180
132
|
});
|
|
181
133
|
}
|
|
134
|
+
|
|
182
135
|
/**
|
|
183
136
|
* Used for testing
|
|
184
137
|
*
|
|
185
138
|
* @private
|
|
186
139
|
*/
|
|
187
|
-
|
|
188
140
|
}, {
|
|
189
141
|
key: "_clearCache",
|
|
190
142
|
value: function () {
|
|
@@ -193,14 +145,11 @@ var ParseConfig = /*#__PURE__*/function () {
|
|
|
193
145
|
}]);
|
|
194
146
|
return ParseConfig;
|
|
195
147
|
}();
|
|
196
|
-
|
|
197
148
|
var currentConfig = null;
|
|
198
149
|
var CURRENT_CONFIG_KEY = 'currentConfig';
|
|
199
|
-
|
|
200
150
|
function decodePayload(data) {
|
|
201
151
|
try {
|
|
202
152
|
var json = JSON.parse(data);
|
|
203
|
-
|
|
204
153
|
if (json && (0, _typeof2.default)(json) === 'object') {
|
|
205
154
|
return (0, _decode.default)(json);
|
|
206
155
|
}
|
|
@@ -208,85 +157,61 @@ function decodePayload(data) {
|
|
|
208
157
|
return null;
|
|
209
158
|
}
|
|
210
159
|
}
|
|
211
|
-
|
|
212
160
|
var DefaultController = {
|
|
213
161
|
current: function () {
|
|
214
162
|
if (currentConfig) {
|
|
215
163
|
return currentConfig;
|
|
216
164
|
}
|
|
217
|
-
|
|
218
165
|
var config = new ParseConfig();
|
|
219
|
-
|
|
220
166
|
var storagePath = _Storage.default.generatePath(CURRENT_CONFIG_KEY);
|
|
221
|
-
|
|
222
167
|
if (!_Storage.default.async()) {
|
|
223
168
|
var configData = _Storage.default.getItem(storagePath);
|
|
224
|
-
|
|
225
169
|
if (configData) {
|
|
226
170
|
var attributes = decodePayload(configData);
|
|
227
|
-
|
|
228
171
|
if (attributes) {
|
|
229
172
|
config.attributes = attributes;
|
|
230
173
|
currentConfig = config;
|
|
231
174
|
}
|
|
232
175
|
}
|
|
233
|
-
|
|
234
176
|
return config;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
177
|
+
}
|
|
178
|
+
// Return a promise for async storage controllers
|
|
238
179
|
return _Storage.default.getItemAsync(storagePath).then(function (configData) {
|
|
239
180
|
if (configData) {
|
|
240
181
|
var _attributes = decodePayload(configData);
|
|
241
|
-
|
|
242
182
|
if (_attributes) {
|
|
243
183
|
config.attributes = _attributes;
|
|
244
184
|
currentConfig = config;
|
|
245
185
|
}
|
|
246
186
|
}
|
|
247
|
-
|
|
248
187
|
return config;
|
|
249
188
|
});
|
|
250
189
|
},
|
|
251
190
|
get: function () {
|
|
252
|
-
var options
|
|
253
|
-
/*: RequestOptions*/
|
|
254
|
-
= arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
255
|
-
|
|
191
|
+
var options /*: RequestOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
256
192
|
var RESTController = _CoreManager.default.getRESTController();
|
|
257
|
-
|
|
258
193
|
return RESTController.request('GET', 'config', {}, options).then(function (response) {
|
|
259
194
|
if (!response || !response.params) {
|
|
260
195
|
var error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Config JSON response invalid.');
|
|
261
196
|
return _promise.default.reject(error);
|
|
262
197
|
}
|
|
263
|
-
|
|
264
198
|
var config = new ParseConfig();
|
|
265
199
|
config.attributes = {};
|
|
266
|
-
|
|
267
200
|
for (var attr in response.params) {
|
|
268
201
|
config.attributes[attr] = (0, _decode.default)(response.params[attr]);
|
|
269
202
|
}
|
|
270
|
-
|
|
271
203
|
currentConfig = config;
|
|
272
204
|
return _Storage.default.setItemAsync(_Storage.default.generatePath(CURRENT_CONFIG_KEY), (0, _stringify.default)(response.params)).then(function () {
|
|
273
205
|
return config;
|
|
274
206
|
});
|
|
275
207
|
});
|
|
276
208
|
},
|
|
277
|
-
save: function (attrs
|
|
278
|
-
/*: { [key: string]: any }*/
|
|
279
|
-
, masterKeyOnlyFlags
|
|
280
|
-
/*: { [key: string]: any }*/
|
|
281
|
-
) {
|
|
209
|
+
save: function (attrs /*: { [key: string]: any }*/, masterKeyOnlyFlags /*: { [key: string]: any }*/) {
|
|
282
210
|
var RESTController = _CoreManager.default.getRESTController();
|
|
283
|
-
|
|
284
211
|
var encodedAttrs = {};
|
|
285
|
-
|
|
286
212
|
for (var _key in attrs) {
|
|
287
213
|
encodedAttrs[_key] = (0, _encode.default)(attrs[_key]);
|
|
288
214
|
}
|
|
289
|
-
|
|
290
215
|
return RESTController.request('PUT', 'config', {
|
|
291
216
|
params: encodedAttrs,
|
|
292
217
|
masterKeyOnly: masterKeyOnlyFlags
|
|
@@ -302,8 +227,6 @@ var DefaultController = {
|
|
|
302
227
|
});
|
|
303
228
|
}
|
|
304
229
|
};
|
|
305
|
-
|
|
306
230
|
_CoreManager.default.setConfigController(DefaultController);
|
|
307
|
-
|
|
308
231
|
var _default = ParseConfig;
|
|
309
232
|
exports.default = _default;
|