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