parse 4.0.1 → 4.1.0-alpha.2
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 +17995 -26193
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +8739 -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 +129 -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 +50 -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 +4 -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 +130 -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 +45 -43
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
4
|
-
|
|
5
4
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
6
|
-
|
|
7
5
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
8
|
-
|
|
9
6
|
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
10
|
-
|
|
11
7
|
function _interopRequireDefault(obj) {
|
|
12
8
|
return obj && obj.__esModule ? obj : {
|
|
13
9
|
default: obj
|
|
@@ -19,11 +15,11 @@ function _interopRequireDefault(obj) {
|
|
|
19
15
|
* @flow
|
|
20
16
|
*/
|
|
21
17
|
|
|
22
|
-
|
|
23
18
|
const QUEUE_KEY = 'Parse/Eventually/Queue';
|
|
24
19
|
let queueCache = [];
|
|
25
20
|
let dirtyCache = true;
|
|
26
21
|
let polling = undefined;
|
|
22
|
+
|
|
27
23
|
/**
|
|
28
24
|
* Provides utility functions to queue objects that will be
|
|
29
25
|
* saved to the server at a later date.
|
|
@@ -31,7 +27,6 @@ let polling = undefined;
|
|
|
31
27
|
* @class Parse.EventuallyQueue
|
|
32
28
|
* @static
|
|
33
29
|
*/
|
|
34
|
-
|
|
35
30
|
const EventuallyQueue = {
|
|
36
31
|
/**
|
|
37
32
|
* Add object to queue with save operation.
|
|
@@ -44,16 +39,9 @@ const EventuallyQueue = {
|
|
|
44
39
|
* @static
|
|
45
40
|
* @see Parse.Object#saveEventually
|
|
46
41
|
*/
|
|
47
|
-
save(object
|
|
48
|
-
/*: ParseObject*/
|
|
49
|
-
, serverOptions
|
|
50
|
-
/*: SaveOptions*/
|
|
51
|
-
= {})
|
|
52
|
-
/*: Promise*/
|
|
53
|
-
{
|
|
42
|
+
save(object /*: ParseObject*/, serverOptions /*: SaveOptions*/ = {}) /*: Promise*/{
|
|
54
43
|
return this.enqueue('save', object, serverOptions);
|
|
55
44
|
},
|
|
56
|
-
|
|
57
45
|
/**
|
|
58
46
|
* Add object to queue with save operation.
|
|
59
47
|
*
|
|
@@ -65,16 +53,9 @@ const EventuallyQueue = {
|
|
|
65
53
|
* @static
|
|
66
54
|
* @see Parse.Object#destroyEventually
|
|
67
55
|
*/
|
|
68
|
-
destroy(object
|
|
69
|
-
/*: ParseObject*/
|
|
70
|
-
, serverOptions
|
|
71
|
-
/*: RequestOptions*/
|
|
72
|
-
= {})
|
|
73
|
-
/*: Promise*/
|
|
74
|
-
{
|
|
56
|
+
destroy(object /*: ParseObject*/, serverOptions /*: RequestOptions*/ = {}) /*: Promise*/{
|
|
75
57
|
return this.enqueue('destroy', object, serverOptions);
|
|
76
58
|
},
|
|
77
|
-
|
|
78
59
|
/**
|
|
79
60
|
* Generate unique identifier to avoid duplicates and maintain previous state.
|
|
80
61
|
*
|
|
@@ -84,26 +65,16 @@ const EventuallyQueue = {
|
|
|
84
65
|
* @static
|
|
85
66
|
* @ignore
|
|
86
67
|
*/
|
|
87
|
-
generateQueueId(action
|
|
88
|
-
/*: string*/
|
|
89
|
-
, object
|
|
90
|
-
/*: ParseObject*/
|
|
91
|
-
)
|
|
92
|
-
/*: string*/
|
|
93
|
-
{
|
|
68
|
+
generateQueueId(action /*: string*/, object /*: ParseObject*/) /*: string*/{
|
|
94
69
|
object._getId();
|
|
95
|
-
|
|
96
70
|
const {
|
|
97
71
|
className,
|
|
98
72
|
id,
|
|
99
73
|
_localId
|
|
100
74
|
} = object;
|
|
101
|
-
|
|
102
75
|
const uniqueId = object.get('hash') || _localId;
|
|
103
|
-
|
|
104
76
|
return [action, className, id, uniqueId].join('_');
|
|
105
77
|
},
|
|
106
|
-
|
|
107
78
|
/**
|
|
108
79
|
* Build queue object and add to queue.
|
|
109
80
|
*
|
|
@@ -114,19 +85,10 @@ const EventuallyQueue = {
|
|
|
114
85
|
* @static
|
|
115
86
|
* @ignore
|
|
116
87
|
*/
|
|
117
|
-
async enqueue(action
|
|
118
|
-
/*: string*/
|
|
119
|
-
, object
|
|
120
|
-
/*: ParseObject*/
|
|
121
|
-
, serverOptions
|
|
122
|
-
/*: SaveOptions | RequestOptions*/
|
|
123
|
-
)
|
|
124
|
-
/*: Promise*/
|
|
125
|
-
{
|
|
88
|
+
async enqueue(action /*: string*/, object /*: ParseObject*/, serverOptions /*: SaveOptions | RequestOptions*/) /*: Promise*/{
|
|
126
89
|
const queueData = await this.getQueue();
|
|
127
90
|
const queueId = this.generateQueueId(action, object);
|
|
128
91
|
let index = this.queueItemExists(queueData, queueId);
|
|
129
|
-
|
|
130
92
|
if (index > -1) {
|
|
131
93
|
// Add cached values to new object if they don't exist
|
|
132
94
|
for (const prop in queueData[index].object) {
|
|
@@ -137,7 +99,6 @@ const EventuallyQueue = {
|
|
|
137
99
|
} else {
|
|
138
100
|
index = queueData.length;
|
|
139
101
|
}
|
|
140
|
-
|
|
141
102
|
queueData[index] = {
|
|
142
103
|
queueId,
|
|
143
104
|
action,
|
|
@@ -150,15 +111,12 @@ const EventuallyQueue = {
|
|
|
150
111
|
};
|
|
151
112
|
return this.setQueue(queueData);
|
|
152
113
|
},
|
|
153
|
-
|
|
154
114
|
store(data) {
|
|
155
115
|
return _Storage.default.setItemAsync(QUEUE_KEY, JSON.stringify(data));
|
|
156
116
|
},
|
|
157
|
-
|
|
158
117
|
load() {
|
|
159
118
|
return _Storage.default.getItemAsync(QUEUE_KEY);
|
|
160
119
|
},
|
|
161
|
-
|
|
162
120
|
/**
|
|
163
121
|
* Sets the in-memory queue from local storage and returns.
|
|
164
122
|
*
|
|
@@ -167,17 +125,13 @@ const EventuallyQueue = {
|
|
|
167
125
|
* @returns {Promise<Array>}
|
|
168
126
|
* @static
|
|
169
127
|
*/
|
|
170
|
-
async getQueue()
|
|
171
|
-
/*: Promise<Array>*/
|
|
172
|
-
{
|
|
128
|
+
async getQueue() /*: Promise<Array>*/{
|
|
173
129
|
if (dirtyCache) {
|
|
174
130
|
queueCache = JSON.parse((await this.load()) || '[]');
|
|
175
131
|
dirtyCache = false;
|
|
176
132
|
}
|
|
177
|
-
|
|
178
133
|
return queueCache;
|
|
179
134
|
},
|
|
180
|
-
|
|
181
135
|
/**
|
|
182
136
|
* Saves the queue to local storage
|
|
183
137
|
*
|
|
@@ -186,15 +140,10 @@ const EventuallyQueue = {
|
|
|
186
140
|
* @static
|
|
187
141
|
* @ignore
|
|
188
142
|
*/
|
|
189
|
-
setQueue(queue
|
|
190
|
-
/*: Queue*/
|
|
191
|
-
)
|
|
192
|
-
/*: Promise<void>*/
|
|
193
|
-
{
|
|
143
|
+
setQueue(queue /*: Queue*/) /*: Promise<void>*/{
|
|
194
144
|
queueCache = queue;
|
|
195
145
|
return this.store(queueCache);
|
|
196
146
|
},
|
|
197
|
-
|
|
198
147
|
/**
|
|
199
148
|
* Removes Parse.Object data from queue.
|
|
200
149
|
*
|
|
@@ -203,20 +152,14 @@ const EventuallyQueue = {
|
|
|
203
152
|
* @static
|
|
204
153
|
* @ignore
|
|
205
154
|
*/
|
|
206
|
-
async remove(queueId
|
|
207
|
-
/*: string*/
|
|
208
|
-
)
|
|
209
|
-
/*: Promise<void>*/
|
|
210
|
-
{
|
|
155
|
+
async remove(queueId /*: string*/) /*: Promise<void>*/{
|
|
211
156
|
const queueData = await this.getQueue();
|
|
212
157
|
const index = this.queueItemExists(queueData, queueId);
|
|
213
|
-
|
|
214
158
|
if (index > -1) {
|
|
215
159
|
queueData.splice(index, 1);
|
|
216
160
|
await this.setQueue(queueData);
|
|
217
161
|
}
|
|
218
162
|
},
|
|
219
|
-
|
|
220
163
|
/**
|
|
221
164
|
* Removes all objects from queue.
|
|
222
165
|
*
|
|
@@ -225,13 +168,10 @@ const EventuallyQueue = {
|
|
|
225
168
|
* @returns {Promise} A promise that is fulfilled when queue is cleared.
|
|
226
169
|
* @static
|
|
227
170
|
*/
|
|
228
|
-
clear()
|
|
229
|
-
/*: Promise*/
|
|
230
|
-
{
|
|
171
|
+
clear() /*: Promise*/{
|
|
231
172
|
queueCache = [];
|
|
232
173
|
return this.store([]);
|
|
233
174
|
},
|
|
234
|
-
|
|
235
175
|
/**
|
|
236
176
|
* Return the index of a queueId in the queue. Returns -1 if not found.
|
|
237
177
|
*
|
|
@@ -241,16 +181,9 @@ const EventuallyQueue = {
|
|
|
241
181
|
* @static
|
|
242
182
|
* @ignore
|
|
243
183
|
*/
|
|
244
|
-
queueItemExists(queue
|
|
245
|
-
/*: Queue*/
|
|
246
|
-
, queueId
|
|
247
|
-
/*: string*/
|
|
248
|
-
)
|
|
249
|
-
/*: number*/
|
|
250
|
-
{
|
|
184
|
+
queueItemExists(queue /*: Queue*/, queueId /*: string*/) /*: number*/{
|
|
251
185
|
return queue.findIndex(data => data.queueId === queueId);
|
|
252
186
|
},
|
|
253
|
-
|
|
254
187
|
/**
|
|
255
188
|
* Return the number of objects in the queue.
|
|
256
189
|
*
|
|
@@ -259,13 +192,10 @@ const EventuallyQueue = {
|
|
|
259
192
|
* @returns {number}
|
|
260
193
|
* @static
|
|
261
194
|
*/
|
|
262
|
-
async length()
|
|
263
|
-
/*: number*/
|
|
264
|
-
{
|
|
195
|
+
async length() /*: number*/{
|
|
265
196
|
const queueData = await this.getQueue();
|
|
266
197
|
return queueData.length;
|
|
267
198
|
},
|
|
268
|
-
|
|
269
199
|
/**
|
|
270
200
|
* Sends the queue to the server.
|
|
271
201
|
*
|
|
@@ -274,16 +204,12 @@ const EventuallyQueue = {
|
|
|
274
204
|
* @returns {Promise<boolean>} Returns true if queue was sent successfully.
|
|
275
205
|
* @static
|
|
276
206
|
*/
|
|
277
|
-
async sendQueue()
|
|
278
|
-
/*: Promise<boolean>*/
|
|
279
|
-
{
|
|
207
|
+
async sendQueue() /*: Promise<boolean>*/{
|
|
280
208
|
const queue = await this.getQueue();
|
|
281
209
|
const queueData = [...queue];
|
|
282
|
-
|
|
283
210
|
if (queueData.length === 0) {
|
|
284
211
|
return false;
|
|
285
212
|
}
|
|
286
|
-
|
|
287
213
|
for (let i = 0; i < queueData.length; i += 1) {
|
|
288
214
|
const queueObject = queueData[i];
|
|
289
215
|
const {
|
|
@@ -291,9 +217,7 @@ const EventuallyQueue = {
|
|
|
291
217
|
hash,
|
|
292
218
|
className
|
|
293
219
|
} = queueObject;
|
|
294
|
-
|
|
295
220
|
const ObjectType = _ParseObject.default.extend(className);
|
|
296
|
-
|
|
297
221
|
if (id) {
|
|
298
222
|
await this.process.byId(ObjectType, queueObject);
|
|
299
223
|
} else if (hash) {
|
|
@@ -302,10 +226,8 @@ const EventuallyQueue = {
|
|
|
302
226
|
await this.process.create(ObjectType, queueObject);
|
|
303
227
|
}
|
|
304
228
|
}
|
|
305
|
-
|
|
306
229
|
return true;
|
|
307
230
|
},
|
|
308
|
-
|
|
309
231
|
/**
|
|
310
232
|
* Build queue object and add to queue.
|
|
311
233
|
*
|
|
@@ -315,24 +237,16 @@ const EventuallyQueue = {
|
|
|
315
237
|
* @static
|
|
316
238
|
* @ignore
|
|
317
239
|
*/
|
|
318
|
-
async sendQueueCallback(object
|
|
319
|
-
/*: ParseObject*/
|
|
320
|
-
, queueObject
|
|
321
|
-
/*: QueueObject*/
|
|
322
|
-
)
|
|
323
|
-
/*: Promise<void>*/
|
|
324
|
-
{
|
|
240
|
+
async sendQueueCallback(object /*: ParseObject*/, queueObject /*: QueueObject*/) /*: Promise<void>*/{
|
|
325
241
|
if (!object) {
|
|
326
242
|
return this.remove(queueObject.queueId);
|
|
327
243
|
}
|
|
328
|
-
|
|
329
244
|
switch (queueObject.action) {
|
|
330
245
|
case 'save':
|
|
331
246
|
// Queued update was overwritten by other request. Do not save
|
|
332
247
|
if (typeof object.updatedAt !== 'undefined' && object.updatedAt > new Date(queueObject.object.createdAt)) {
|
|
333
248
|
return this.remove(queueObject.queueId);
|
|
334
249
|
}
|
|
335
|
-
|
|
336
250
|
try {
|
|
337
251
|
await object.save(queueObject.object, queueObject.serverOptions);
|
|
338
252
|
await this.remove(queueObject.queueId);
|
|
@@ -341,9 +255,7 @@ const EventuallyQueue = {
|
|
|
341
255
|
await this.remove(queueObject.queueId);
|
|
342
256
|
}
|
|
343
257
|
}
|
|
344
|
-
|
|
345
258
|
break;
|
|
346
|
-
|
|
347
259
|
case 'destroy':
|
|
348
260
|
try {
|
|
349
261
|
await object.destroy(queueObject.serverOptions);
|
|
@@ -353,11 +265,9 @@ const EventuallyQueue = {
|
|
|
353
265
|
await this.remove(queueObject.queueId);
|
|
354
266
|
}
|
|
355
267
|
}
|
|
356
|
-
|
|
357
268
|
break;
|
|
358
269
|
}
|
|
359
270
|
},
|
|
360
|
-
|
|
361
271
|
/**
|
|
362
272
|
* Start polling server for network connection.
|
|
363
273
|
* Will send queue if connection is established.
|
|
@@ -367,16 +277,12 @@ const EventuallyQueue = {
|
|
|
367
277
|
* @param [ms] Milliseconds to ping the server. Default 2000ms
|
|
368
278
|
* @static
|
|
369
279
|
*/
|
|
370
|
-
poll(ms
|
|
371
|
-
/*: number*/
|
|
372
|
-
= 2000) {
|
|
280
|
+
poll(ms /*: number*/ = 2000) {
|
|
373
281
|
if (polling) {
|
|
374
282
|
return;
|
|
375
283
|
}
|
|
376
|
-
|
|
377
284
|
polling = setInterval(() => {
|
|
378
285
|
const RESTController = _CoreManager.default.getRESTController();
|
|
379
|
-
|
|
380
286
|
RESTController.request('GET', 'health').then(({
|
|
381
287
|
status
|
|
382
288
|
}) => {
|
|
@@ -387,7 +293,6 @@ const EventuallyQueue = {
|
|
|
387
293
|
}).catch(e => e);
|
|
388
294
|
}, ms);
|
|
389
295
|
},
|
|
390
|
-
|
|
391
296
|
/**
|
|
392
297
|
* Turns off polling.
|
|
393
298
|
*
|
|
@@ -399,7 +304,6 @@ const EventuallyQueue = {
|
|
|
399
304
|
clearInterval(polling);
|
|
400
305
|
polling = undefined;
|
|
401
306
|
},
|
|
402
|
-
|
|
403
307
|
/**
|
|
404
308
|
* Return true if pinging the server.
|
|
405
309
|
*
|
|
@@ -408,24 +312,17 @@ const EventuallyQueue = {
|
|
|
408
312
|
* @returns {boolean}
|
|
409
313
|
* @static
|
|
410
314
|
*/
|
|
411
|
-
isPolling()
|
|
412
|
-
/*: boolean*/
|
|
413
|
-
{
|
|
315
|
+
isPolling() /*: boolean*/{
|
|
414
316
|
return !!polling;
|
|
415
317
|
},
|
|
416
|
-
|
|
417
|
-
_setPolling(flag
|
|
418
|
-
/*: boolean*/
|
|
419
|
-
) {
|
|
318
|
+
_setPolling(flag /*: boolean*/) {
|
|
420
319
|
polling = flag;
|
|
421
320
|
},
|
|
422
|
-
|
|
423
321
|
process: {
|
|
424
322
|
create(ObjectType, queueObject) {
|
|
425
323
|
const object = new ObjectType();
|
|
426
324
|
return EventuallyQueue.sendQueueCallback(object, queueObject);
|
|
427
325
|
},
|
|
428
|
-
|
|
429
326
|
async byId(ObjectType, queueObject) {
|
|
430
327
|
const {
|
|
431
328
|
sessionToken
|
|
@@ -437,7 +334,6 @@ const EventuallyQueue = {
|
|
|
437
334
|
});
|
|
438
335
|
return EventuallyQueue.sendQueueCallback(results[0], queueObject);
|
|
439
336
|
},
|
|
440
|
-
|
|
441
337
|
async byHash(ObjectType, queueObject) {
|
|
442
338
|
const {
|
|
443
339
|
sessionToken
|
|
@@ -447,14 +343,11 @@ const EventuallyQueue = {
|
|
|
447
343
|
const results = await query.find({
|
|
448
344
|
sessionToken
|
|
449
345
|
});
|
|
450
|
-
|
|
451
346
|
if (results.length > 0) {
|
|
452
347
|
return EventuallyQueue.sendQueueCallback(results[0], queueObject);
|
|
453
348
|
}
|
|
454
|
-
|
|
455
349
|
return EventuallyQueue.process.create(ObjectType, queueObject);
|
|
456
350
|
}
|
|
457
|
-
|
|
458
351
|
}
|
|
459
352
|
};
|
|
460
353
|
module.exports = EventuallyQueue;
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _ParseUser = _interopRequireDefault(require("./ParseUser"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) {
|
|
11
9
|
return obj && obj.__esModule ? obj : {
|
|
12
10
|
default: obj
|
|
@@ -15,10 +13,8 @@ function _interopRequireDefault(obj) {
|
|
|
15
13
|
/**
|
|
16
14
|
* @flow-weak
|
|
17
15
|
*/
|
|
18
|
-
|
|
19
16
|
/* global FB */
|
|
20
17
|
|
|
21
|
-
|
|
22
18
|
let initialized = false;
|
|
23
19
|
let requestedPermissions;
|
|
24
20
|
let initOptions;
|
|
@@ -27,7 +23,6 @@ const provider = {
|
|
|
27
23
|
if (typeof FB === 'undefined') {
|
|
28
24
|
options.error(this, 'Facebook SDK not found.');
|
|
29
25
|
}
|
|
30
|
-
|
|
31
26
|
FB.login(response => {
|
|
32
27
|
if (response.authResponse) {
|
|
33
28
|
if (options.success) {
|
|
@@ -46,44 +41,37 @@ const provider = {
|
|
|
46
41
|
scope: requestedPermissions
|
|
47
42
|
});
|
|
48
43
|
},
|
|
49
|
-
|
|
50
44
|
restoreAuthentication(authData) {
|
|
51
45
|
if (authData) {
|
|
52
46
|
const newOptions = {};
|
|
53
|
-
|
|
54
47
|
if (initOptions) {
|
|
55
48
|
for (const key in initOptions) {
|
|
56
49
|
newOptions[key] = initOptions[key];
|
|
57
50
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
51
|
+
}
|
|
52
|
+
// Suppress checks for login status from the browser.
|
|
53
|
+
newOptions.status = false;
|
|
60
54
|
|
|
61
|
-
|
|
55
|
+
// If the user doesn't match the one known by the FB SDK, log out.
|
|
62
56
|
// Most of the time, the users will match -- it's only in cases where
|
|
63
57
|
// the FB SDK knows of a different user than the one being restored
|
|
64
58
|
// from a Parse User that logged in with username/password.
|
|
65
|
-
|
|
66
59
|
const existingResponse = FB.getAuthResponse();
|
|
67
|
-
|
|
68
60
|
if (existingResponse && existingResponse.userID !== authData.id) {
|
|
69
61
|
FB.logout();
|
|
70
62
|
}
|
|
71
|
-
|
|
72
63
|
FB.init(newOptions);
|
|
73
64
|
}
|
|
74
|
-
|
|
75
65
|
return true;
|
|
76
66
|
},
|
|
77
|
-
|
|
78
67
|
getAuthType() {
|
|
79
68
|
return 'facebook';
|
|
80
69
|
},
|
|
81
|
-
|
|
82
70
|
deauthenticate() {
|
|
83
71
|
this.restoreAuthentication(null);
|
|
84
72
|
}
|
|
85
|
-
|
|
86
73
|
};
|
|
74
|
+
|
|
87
75
|
/**
|
|
88
76
|
* Provides a set of utilities for using Parse with Facebook.
|
|
89
77
|
*
|
|
@@ -91,7 +79,6 @@ const provider = {
|
|
|
91
79
|
* @static
|
|
92
80
|
* @hideconstructor
|
|
93
81
|
*/
|
|
94
|
-
|
|
95
82
|
const FacebookUtils = {
|
|
96
83
|
/**
|
|
97
84
|
* Initializes Parse Facebook integration. Call this function after you
|
|
@@ -115,30 +102,21 @@ const FacebookUtils = {
|
|
|
115
102
|
if (typeof FB === 'undefined') {
|
|
116
103
|
throw new Error('The Facebook JavaScript SDK must be loaded before calling init.');
|
|
117
104
|
}
|
|
118
|
-
|
|
119
105
|
initOptions = {};
|
|
120
|
-
|
|
121
106
|
if (options) {
|
|
122
107
|
for (const key in options) {
|
|
123
108
|
initOptions[key] = options[key];
|
|
124
109
|
}
|
|
125
110
|
}
|
|
126
|
-
|
|
127
111
|
if (initOptions.status && typeof console !== 'undefined') {
|
|
128
112
|
const warn = console.warn || console.log || function () {}; // eslint-disable-line no-console
|
|
129
|
-
|
|
130
|
-
|
|
131
113
|
warn.call(console, 'The "status" flag passed into' + ' FB.init, when set to true, can interfere with Parse Facebook' + ' integration, so it has been suppressed. Please call' + ' FB.getLoginStatus() explicitly if you require this behavior.');
|
|
132
114
|
}
|
|
133
|
-
|
|
134
115
|
initOptions.status = false;
|
|
135
116
|
FB.init(initOptions);
|
|
136
|
-
|
|
137
117
|
_ParseUser.default._registerAuthenticationProvider(provider);
|
|
138
|
-
|
|
139
118
|
initialized = true;
|
|
140
119
|
},
|
|
141
|
-
|
|
142
120
|
/**
|
|
143
121
|
* Gets whether the user has their account linked to Facebook.
|
|
144
122
|
*
|
|
@@ -152,7 +130,6 @@ const FacebookUtils = {
|
|
|
152
130
|
isLinked(user) {
|
|
153
131
|
return user._isLinked('facebook');
|
|
154
132
|
},
|
|
155
|
-
|
|
156
133
|
/**
|
|
157
134
|
* Logs in a user using Facebook. This method delegates to the Facebook
|
|
158
135
|
* SDK to authenticate the user, and then automatically logs in (or
|
|
@@ -182,16 +159,13 @@ const FacebookUtils = {
|
|
|
182
159
|
if (!initialized) {
|
|
183
160
|
throw new Error('You must initialize FacebookUtils before calling logIn.');
|
|
184
161
|
}
|
|
185
|
-
|
|
186
162
|
requestedPermissions = permissions;
|
|
187
163
|
return _ParseUser.default.logInWith('facebook', options);
|
|
188
164
|
}
|
|
189
|
-
|
|
190
165
|
return _ParseUser.default.logInWith('facebook', {
|
|
191
166
|
authData: permissions
|
|
192
167
|
}, options);
|
|
193
168
|
},
|
|
194
|
-
|
|
195
169
|
/**
|
|
196
170
|
* Links Facebook to an existing PFUser. This method delegates to the
|
|
197
171
|
* Facebook SDK to authenticate the user, and then automatically links
|
|
@@ -223,16 +197,13 @@ const FacebookUtils = {
|
|
|
223
197
|
if (!initialized) {
|
|
224
198
|
throw new Error('You must initialize FacebookUtils before calling link.');
|
|
225
199
|
}
|
|
226
|
-
|
|
227
200
|
requestedPermissions = permissions;
|
|
228
201
|
return user.linkWith('facebook', options);
|
|
229
202
|
}
|
|
230
|
-
|
|
231
203
|
return user.linkWith('facebook', {
|
|
232
204
|
authData: permissions
|
|
233
205
|
}, options);
|
|
234
206
|
},
|
|
235
|
-
|
|
236
207
|
/**
|
|
237
208
|
* Unlinks the Parse.User from a Facebook account.
|
|
238
209
|
*
|
|
@@ -248,15 +219,12 @@ const FacebookUtils = {
|
|
|
248
219
|
if (!initialized) {
|
|
249
220
|
throw new Error('You must initialize FacebookUtils before calling unlink.');
|
|
250
221
|
}
|
|
251
|
-
|
|
252
222
|
return user._unlinkFrom('facebook', options);
|
|
253
223
|
},
|
|
254
|
-
|
|
255
224
|
// Used for testing purposes
|
|
256
225
|
_getAuthProvider() {
|
|
257
226
|
return provider;
|
|
258
227
|
}
|
|
259
|
-
|
|
260
228
|
};
|
|
261
229
|
var _default = FacebookUtils;
|
|
262
230
|
exports.default = _default;
|
|
@@ -4,43 +4,27 @@ var _idbKeyval = require("idb-keyval");
|
|
|
4
4
|
/**
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
/* global window */
|
|
9
8
|
|
|
10
|
-
|
|
11
9
|
if (typeof window !== 'undefined' && window.indexedDB) {
|
|
12
10
|
const ParseStore = (0, _idbKeyval.createStore)('parseDB', 'parseStore');
|
|
13
11
|
module.exports = {
|
|
14
12
|
async: 1,
|
|
15
|
-
|
|
16
|
-
getItemAsync(path
|
|
17
|
-
/*: string*/
|
|
18
|
-
) {
|
|
13
|
+
getItemAsync(path /*: string*/) {
|
|
19
14
|
return (0, _idbKeyval.get)(path, ParseStore);
|
|
20
15
|
},
|
|
21
|
-
|
|
22
|
-
setItemAsync(path
|
|
23
|
-
/*: string*/
|
|
24
|
-
, value
|
|
25
|
-
/*: string*/
|
|
26
|
-
) {
|
|
16
|
+
setItemAsync(path /*: string*/, value /*: string*/) {
|
|
27
17
|
return (0, _idbKeyval.set)(path, value, ParseStore);
|
|
28
18
|
},
|
|
29
|
-
|
|
30
|
-
removeItemAsync(path
|
|
31
|
-
/*: string*/
|
|
32
|
-
) {
|
|
19
|
+
removeItemAsync(path /*: string*/) {
|
|
33
20
|
return (0, _idbKeyval.del)(path, ParseStore);
|
|
34
21
|
},
|
|
35
|
-
|
|
36
22
|
getAllKeysAsync() {
|
|
37
23
|
return (0, _idbKeyval.keys)(ParseStore);
|
|
38
24
|
},
|
|
39
|
-
|
|
40
25
|
clear() {
|
|
41
26
|
return (0, _idbKeyval.clear)(ParseStore);
|
|
42
27
|
}
|
|
43
|
-
|
|
44
28
|
};
|
|
45
29
|
} else {
|
|
46
30
|
// IndexedDB not supported
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) {
|
|
6
5
|
return obj && obj.__esModule ? obj : {
|
|
7
6
|
default: obj
|
|
@@ -11,20 +10,14 @@ function _interopRequireDefault(obj) {
|
|
|
11
10
|
* @flow
|
|
12
11
|
*/
|
|
13
12
|
|
|
14
|
-
|
|
15
13
|
const uuidv4 = require('./uuid');
|
|
16
|
-
|
|
17
14
|
let iidCache = null;
|
|
18
15
|
const InstallationController = {
|
|
19
|
-
currentInstallationId()
|
|
20
|
-
/*: Promise<string>*/
|
|
21
|
-
{
|
|
16
|
+
currentInstallationId() /*: Promise<string>*/{
|
|
22
17
|
if (typeof iidCache === 'string') {
|
|
23
18
|
return Promise.resolve(iidCache);
|
|
24
19
|
}
|
|
25
|
-
|
|
26
20
|
const path = _Storage.default.generatePath('installationId');
|
|
27
|
-
|
|
28
21
|
return _Storage.default.getItemAsync(path).then(iid => {
|
|
29
22
|
if (!iid) {
|
|
30
23
|
iid = uuidv4();
|
|
@@ -33,21 +26,15 @@ const InstallationController = {
|
|
|
33
26
|
return iid;
|
|
34
27
|
});
|
|
35
28
|
}
|
|
36
|
-
|
|
37
29
|
iidCache = iid;
|
|
38
30
|
return iid;
|
|
39
31
|
});
|
|
40
32
|
},
|
|
41
|
-
|
|
42
33
|
_clearCache() {
|
|
43
34
|
iidCache = null;
|
|
44
35
|
},
|
|
45
|
-
|
|
46
|
-
_setInstallationIdCache(iid
|
|
47
|
-
/*: string*/
|
|
48
|
-
) {
|
|
36
|
+
_setInstallationIdCache(iid /*: string*/) {
|
|
49
37
|
iidCache = iid;
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
};
|
|
53
40
|
module.exports = InstallationController;
|