parse 6.1.0-alpha.2 → 6.1.0

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.
Files changed (174) hide show
  1. package/README.md +0 -8
  2. package/dist/parse.js +27 -47
  3. package/dist/parse.min.js +2 -2
  4. package/dist/parse.weapp.js +27 -47
  5. package/dist/parse.weapp.min.js +2 -2
  6. package/lib/browser/CoreManager.js +1 -2
  7. package/lib/browser/CryptoController.js +0 -1
  8. package/lib/browser/EventEmitter.js +0 -1
  9. package/lib/browser/EventuallyQueue.js +0 -1
  10. package/lib/browser/IndexedDBStorageController.js +0 -1
  11. package/lib/browser/InstallationController.js +0 -1
  12. package/lib/browser/LocalDatastore.js +0 -1
  13. package/lib/browser/LocalDatastoreController.default.js +0 -1
  14. package/lib/browser/LocalDatastoreController.js +0 -1
  15. package/lib/browser/LocalDatastoreController.react-native.js +0 -1
  16. package/lib/browser/OfflineQuery.js +0 -1
  17. package/lib/browser/ParseInstallation.js +0 -1
  18. package/lib/browser/ParseQuery.js +19 -17
  19. package/lib/browser/RESTController.js +4 -3
  20. package/lib/browser/Socket.weapp.js +0 -1
  21. package/lib/browser/Storage.js +0 -1
  22. package/lib/browser/StorageController.browser.js +0 -1
  23. package/lib/browser/StorageController.default.js +0 -1
  24. package/lib/browser/StorageController.js +0 -1
  25. package/lib/browser/StorageController.react-native.js +0 -1
  26. package/lib/browser/StorageController.weapp.js +0 -1
  27. package/lib/browser/TaskQueue.js +0 -1
  28. package/lib/browser/WebSocketController.js +0 -1
  29. package/lib/browser/Xhr.weapp.js +0 -1
  30. package/lib/browser/uuid.js +0 -1
  31. package/lib/node/CoreManager.js +1 -2
  32. package/lib/node/CryptoController.js +0 -1
  33. package/lib/node/EventEmitter.js +0 -1
  34. package/lib/node/EventuallyQueue.js +0 -1
  35. package/lib/node/IndexedDBStorageController.js +0 -1
  36. package/lib/node/InstallationController.js +0 -1
  37. package/lib/node/LocalDatastore.js +0 -1
  38. package/lib/node/LocalDatastoreController.default.js +0 -1
  39. package/lib/node/LocalDatastoreController.js +0 -1
  40. package/lib/node/LocalDatastoreController.react-native.js +0 -1
  41. package/lib/node/OfflineQuery.js +0 -1
  42. package/lib/node/ParseInstallation.js +0 -1
  43. package/lib/node/RESTController.js +0 -1
  44. package/lib/node/Socket.weapp.js +0 -1
  45. package/lib/node/Storage.js +0 -1
  46. package/lib/node/StorageController.browser.js +0 -1
  47. package/lib/node/StorageController.default.js +0 -1
  48. package/lib/node/StorageController.js +0 -1
  49. package/lib/node/StorageController.react-native.js +0 -1
  50. package/lib/node/StorageController.weapp.js +0 -1
  51. package/lib/node/TaskQueue.js +0 -1
  52. package/lib/node/WebSocketController.js +0 -1
  53. package/lib/node/Xhr.weapp.js +0 -1
  54. package/lib/node/uuid.js +0 -1
  55. package/lib/react-native/CoreManager.js +1 -2
  56. package/lib/react-native/CryptoController.js +0 -1
  57. package/lib/react-native/EventEmitter.js +0 -1
  58. package/lib/react-native/EventuallyQueue.js +0 -1
  59. package/lib/react-native/IndexedDBStorageController.js +0 -1
  60. package/lib/react-native/InstallationController.js +0 -1
  61. package/lib/react-native/LocalDatastore.js +0 -1
  62. package/lib/react-native/LocalDatastoreController.default.js +0 -1
  63. package/lib/react-native/LocalDatastoreController.js +0 -1
  64. package/lib/react-native/LocalDatastoreController.react-native.js +0 -1
  65. package/lib/react-native/OfflineQuery.js +0 -1
  66. package/lib/react-native/ParseInstallation.js +0 -1
  67. package/lib/react-native/RESTController.js +0 -1
  68. package/lib/react-native/Socket.weapp.js +0 -1
  69. package/lib/react-native/Storage.js +0 -1
  70. package/lib/react-native/StorageController.browser.js +0 -1
  71. package/lib/react-native/StorageController.default.js +0 -1
  72. package/lib/react-native/StorageController.js +0 -1
  73. package/lib/react-native/StorageController.react-native.js +0 -1
  74. package/lib/react-native/StorageController.weapp.js +0 -1
  75. package/lib/react-native/TaskQueue.js +0 -1
  76. package/lib/react-native/WebSocketController.js +0 -1
  77. package/lib/react-native/Xhr.weapp.js +0 -1
  78. package/lib/react-native/uuid.js +0 -1
  79. package/lib/weapp/CoreManager.js +1 -2
  80. package/lib/weapp/CryptoController.js +0 -1
  81. package/lib/weapp/EventEmitter.js +0 -1
  82. package/lib/weapp/EventuallyQueue.js +0 -1
  83. package/lib/weapp/IndexedDBStorageController.js +0 -1
  84. package/lib/weapp/InstallationController.js +0 -1
  85. package/lib/weapp/LocalDatastore.js +0 -1
  86. package/lib/weapp/LocalDatastoreController.default.js +0 -1
  87. package/lib/weapp/LocalDatastoreController.js +0 -1
  88. package/lib/weapp/LocalDatastoreController.react-native.js +0 -1
  89. package/lib/weapp/OfflineQuery.js +0 -1
  90. package/lib/weapp/ParseInstallation.js +0 -1
  91. package/lib/weapp/ParseQuery.js +19 -17
  92. package/lib/weapp/RESTController.js +4 -3
  93. package/lib/weapp/Socket.weapp.js +0 -1
  94. package/lib/weapp/Storage.js +0 -1
  95. package/lib/weapp/StorageController.browser.js +0 -1
  96. package/lib/weapp/StorageController.default.js +0 -1
  97. package/lib/weapp/StorageController.js +0 -1
  98. package/lib/weapp/StorageController.react-native.js +0 -1
  99. package/lib/weapp/StorageController.weapp.js +0 -1
  100. package/lib/weapp/TaskQueue.js +0 -1
  101. package/lib/weapp/WebSocketController.js +0 -1
  102. package/lib/weapp/Xhr.weapp.js +0 -1
  103. package/lib/weapp/uuid.js +0 -1
  104. package/package.json +11 -9
  105. package/types/Analytics.d.ts +42 -0
  106. package/types/AnonymousUtils.d.ts +84 -0
  107. package/types/Cloud.d.ts +65 -0
  108. package/types/CloudCode.d.ts +307 -0
  109. package/types/CoreManager.d.ts +325 -0
  110. package/types/CryptoController.d.ts +5 -0
  111. package/types/EventEmitter.d.ts +5 -0
  112. package/types/EventuallyQueue.d.ts +168 -0
  113. package/types/FacebookUtils.d.ts +107 -0
  114. package/types/IndexedDBStorageController.d.ts +2 -0
  115. package/types/InstallationController.d.ts +10 -0
  116. package/types/LiveQueryClient.d.ts +128 -0
  117. package/types/LiveQuerySubscription.d.ts +103 -0
  118. package/types/LocalDatastore.d.ts +56 -0
  119. package/types/LocalDatastoreController.d.ts +2 -0
  120. package/types/LocalDatastoreController.default.d.ts +9 -0
  121. package/types/LocalDatastoreController.react-native.d.ts +9 -0
  122. package/types/LocalDatastoreUtils.d.ts +5 -0
  123. package/types/ObjectStateMutations.d.ts +28 -0
  124. package/types/OfflineQuery.d.ts +20 -0
  125. package/types/Parse.d.ts +633 -0
  126. package/types/ParseACL.d.ts +141 -0
  127. package/types/ParseCLP.d.ts +293 -0
  128. package/types/ParseConfig.d.ts +77 -0
  129. package/types/ParseError.d.ts +476 -0
  130. package/types/ParseFile.d.ts +192 -0
  131. package/types/ParseGeoPoint.d.ts +104 -0
  132. package/types/ParseHooks.d.ts +27 -0
  133. package/types/ParseInstallation.d.ts +179 -0
  134. package/types/ParseLiveQuery.d.ts +48 -0
  135. package/types/ParseObject.d.ts +1072 -0
  136. package/types/ParseOp.d.ts +78 -0
  137. package/types/ParsePolygon.d.ts +69 -0
  138. package/types/ParseQuery.d.ts +961 -0
  139. package/types/ParseRelation.d.ts +56 -0
  140. package/types/ParseRole.d.ts +79 -0
  141. package/types/ParseSchema.d.ts +286 -0
  142. package/types/ParseSession.d.ts +45 -0
  143. package/types/ParseUser.d.ts +517 -0
  144. package/types/Push.d.ts +62 -0
  145. package/types/RESTController.d.ts +35 -0
  146. package/types/SingleInstanceStateController.d.ts +24 -0
  147. package/types/Socket.weapp.d.ts +10 -0
  148. package/types/Storage.d.ts +14 -0
  149. package/types/StorageController.browser.d.ts +9 -0
  150. package/types/StorageController.d.ts +2 -0
  151. package/types/StorageController.default.d.ts +9 -0
  152. package/types/StorageController.react-native.d.ts +11 -0
  153. package/types/StorageController.weapp.d.ts +9 -0
  154. package/types/TaskQueue.d.ts +11 -0
  155. package/types/UniqueInstanceStateController.d.ts +20 -0
  156. package/types/WebSocketController.d.ts +2 -0
  157. package/types/Xhr.weapp.d.ts +29 -0
  158. package/types/arrayContainsObject.d.ts +2 -0
  159. package/types/canBeSerialized.d.ts +2 -0
  160. package/types/decode.d.ts +1 -0
  161. package/types/encode.d.ts +1 -0
  162. package/types/equals.d.ts +1 -0
  163. package/types/escape.d.ts +1 -0
  164. package/types/index.d.ts +66 -0
  165. package/types/isRevocableSession.d.ts +1 -0
  166. package/types/node.d.ts +3 -0
  167. package/types/parseDate.d.ts +1 -0
  168. package/types/promiseUtils.d.ts +9 -0
  169. package/types/react-native.d.ts +3 -0
  170. package/types/tests.ts +2256 -0
  171. package/types/tsconfig.json +25 -0
  172. package/types/unique.d.ts +1 -0
  173. package/types/unsavedChildren.d.ts +11 -0
  174. package/types/uuid.d.ts +2 -0
@@ -0,0 +1,168 @@
1
+ import ParseObject from './ParseObject';
2
+ import type { Queue, QueueObject } from './CoreManager';
3
+ import type { SaveOptions } from './ParseObject';
4
+ import type { RequestOptions } from './RESTController';
5
+ /**
6
+ * Provides utility functions to queue objects that will be
7
+ * saved to the server at a later date.
8
+ *
9
+ * @class Parse.EventuallyQueue
10
+ * @static
11
+ */
12
+ declare const EventuallyQueue: {
13
+ /**
14
+ * Add object to queue with save operation.
15
+ *
16
+ * @function save
17
+ * @name Parse.EventuallyQueue.save
18
+ * @param {ParseObject} object Parse.Object to be saved eventually
19
+ * @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#save Parse.Object.save} options.
20
+ * @returns {Promise} A promise that is fulfilled if object is added to queue.
21
+ * @static
22
+ * @see Parse.Object#saveEventually
23
+ */
24
+ save(object: ParseObject, serverOptions?: SaveOptions): Promise<void>;
25
+ /**
26
+ * Add object to queue with save operation.
27
+ *
28
+ * @function destroy
29
+ * @name Parse.EventuallyQueue.destroy
30
+ * @param {ParseObject} object Parse.Object to be destroyed eventually
31
+ * @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#destroy Parse.Object.destroy} options
32
+ * @returns {Promise} A promise that is fulfilled if object is added to queue.
33
+ * @static
34
+ * @see Parse.Object#destroyEventually
35
+ */
36
+ destroy(object: ParseObject, serverOptions?: RequestOptions): Promise<void>;
37
+ /**
38
+ * Generate unique identifier to avoid duplicates and maintain previous state.
39
+ *
40
+ * @param {string} action save / destroy
41
+ * @param {object} object Parse.Object to be queued
42
+ * @returns {string}
43
+ * @static
44
+ * @ignore
45
+ */
46
+ generateQueueId(action: string, object: ParseObject): string;
47
+ /**
48
+ * Build queue object and add to queue.
49
+ *
50
+ * @param {string} action save / destroy
51
+ * @param {object} object Parse.Object to be queued
52
+ * @param {object} [serverOptions]
53
+ * @returns {Promise} A promise that is fulfilled if object is added to queue.
54
+ * @static
55
+ * @ignore
56
+ */
57
+ enqueue(action: string, object: ParseObject, serverOptions?: SaveOptions | RequestOptions): Promise<void>;
58
+ store(data: Queue): Promise<void>;
59
+ load(): Promise<string | null>;
60
+ /**
61
+ * Sets the in-memory queue from local storage and returns.
62
+ *
63
+ * @function getQueue
64
+ * @name Parse.EventuallyQueue.getQueue
65
+ * @returns {Promise<Queue>}
66
+ * @static
67
+ */
68
+ getQueue(): Promise<Queue>;
69
+ /**
70
+ * Saves the queue to local storage
71
+ *
72
+ * @param {Queue} queue Queue containing Parse.Object data.
73
+ * @returns {Promise} A promise that is fulfilled when queue is stored.
74
+ * @static
75
+ * @ignore
76
+ */
77
+ setQueue(queue: Queue): Promise<void>;
78
+ /**
79
+ * Removes Parse.Object data from queue.
80
+ *
81
+ * @param {string} queueId Unique identifier for Parse.Object data.
82
+ * @returns {Promise} A promise that is fulfilled when queue is stored.
83
+ * @static
84
+ * @ignore
85
+ */
86
+ remove(queueId: string): Promise<void>;
87
+ /**
88
+ * Removes all objects from queue.
89
+ *
90
+ * @function clear
91
+ * @name Parse.EventuallyQueue.clear
92
+ * @returns {Promise} A promise that is fulfilled when queue is cleared.
93
+ * @static
94
+ */
95
+ clear(): Promise<void>;
96
+ /**
97
+ * Return the index of a queueId in the queue. Returns -1 if not found.
98
+ *
99
+ * @param {Queue} queue Queue containing Parse.Object data.
100
+ * @param {string} queueId Unique identifier for Parse.Object data.
101
+ * @returns {number}
102
+ * @static
103
+ * @ignore
104
+ */
105
+ queueItemExists(queue: Queue, queueId: string): number;
106
+ /**
107
+ * Return the number of objects in the queue.
108
+ *
109
+ * @function length
110
+ * @name Parse.EventuallyQueue.length
111
+ * @returns {Promise<number>}
112
+ * @static
113
+ */
114
+ length(): Promise<number>;
115
+ /**
116
+ * Sends the queue to the server.
117
+ *
118
+ * @function sendQueue
119
+ * @name Parse.EventuallyQueue.sendQueue
120
+ * @returns {Promise<boolean>} Returns true if queue was sent successfully.
121
+ * @static
122
+ */
123
+ sendQueue(): Promise<boolean>;
124
+ /**
125
+ * Build queue object and add to queue.
126
+ *
127
+ * @param {ParseObject} object Parse.Object to be processed
128
+ * @param {QueueObject} queueObject Parse.Object data from the queue
129
+ * @returns {Promise} A promise that is fulfilled when operation is performed.
130
+ * @static
131
+ * @ignore
132
+ */
133
+ sendQueueCallback(object: ParseObject, queueObject: QueueObject): Promise<void>;
134
+ /**
135
+ * Start polling server for network connection.
136
+ * Will send queue if connection is established.
137
+ *
138
+ * @function poll
139
+ * @name Parse.EventuallyQueue.poll
140
+ * @param [ms] Milliseconds to ping the server. Default 2000ms
141
+ * @static
142
+ */
143
+ poll(ms?: number): void;
144
+ /**
145
+ * Turns off polling.
146
+ *
147
+ * @function stopPoll
148
+ * @name Parse.EventuallyQueue.stopPoll
149
+ * @static
150
+ */
151
+ stopPoll(): void;
152
+ /**
153
+ * Return true if pinging the server.
154
+ *
155
+ * @function isPolling
156
+ * @name Parse.EventuallyQueue.isPolling
157
+ * @returns {boolean}
158
+ * @static
159
+ */
160
+ isPolling(): boolean;
161
+ _setPolling(flag: boolean): void;
162
+ process: {
163
+ create(ObjectType: any, queueObject: any): Promise<void>;
164
+ byId(ObjectType: any, queueObject: any): Promise<void>;
165
+ byHash(ObjectType: any, queueObject: any): Promise<void>;
166
+ };
167
+ };
168
+ export default EventuallyQueue;
@@ -0,0 +1,107 @@
1
+ import ParseUser from './ParseUser';
2
+ import type { AuthProvider } from './ParseUser';
3
+ /**
4
+ * Provides a set of utilities for using Parse with Facebook.
5
+ *
6
+ * @class Parse.FacebookUtils
7
+ * @static
8
+ * @hideconstructor
9
+ */
10
+ declare const FacebookUtils: {
11
+ /**
12
+ * Initializes Parse Facebook integration. Call this function after you
13
+ * have loaded the Facebook Javascript SDK with the same parameters
14
+ * as you would pass to<code>
15
+ * <a href=
16
+ * "https://developers.facebook.com/docs/reference/javascript/FB.init/">
17
+ * FB.init()</a></code>. Parse.FacebookUtils will invoke FB.init() for you
18
+ * with these arguments.
19
+ *
20
+ * @function init
21
+ * @name Parse.FacebookUtils.init
22
+ * @param {object} options Facebook options argument as described here:
23
+ * <a href=
24
+ * "https://developers.facebook.com/docs/reference/javascript/FB.init/">
25
+ * FB.init()</a>. The status flag will be coerced to 'false' because it
26
+ * interferes with Parse Facebook integration. Call FB.getLoginStatus()
27
+ * explicitly if this behavior is required by your application.
28
+ */
29
+ init(options: any): void;
30
+ /**
31
+ * Gets whether the user has their account linked to Facebook.
32
+ *
33
+ * @function isLinked
34
+ * @name Parse.FacebookUtils.isLinked
35
+ * @param {Parse.User} user User to check for a facebook link.
36
+ * The user must be logged in on this device.
37
+ * @returns {boolean} <code>true</code> if the user has their account
38
+ * linked to Facebook.
39
+ */
40
+ isLinked(user: any): any;
41
+ /**
42
+ * Logs in a user using Facebook. This method delegates to the Facebook
43
+ * SDK to authenticate the user, and then automatically logs in (or
44
+ * creates, in the case where it is a new user) a Parse.User.
45
+ *
46
+ * Standard API:
47
+ *
48
+ * <code>logIn(permission: string, authData: Object);</code>
49
+ *
50
+ * Advanced API: Used for handling your own oAuth tokens
51
+ * {@link https://docs.parseplatform.org/rest/guide/#linking-users}
52
+ *
53
+ * <code>logIn(authData: Object, options?: Object);</code>
54
+ *
55
+ * @function logIn
56
+ * @name Parse.FacebookUtils.logIn
57
+ * @param {(string | object)} permissions The permissions required for Facebook
58
+ * log in. This is a comma-separated string of permissions.
59
+ * Alternatively, supply a Facebook authData object as described in our
60
+ * REST API docs if you want to handle getting facebook auth tokens
61
+ * yourself.
62
+ * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
63
+ * @returns {Promise}
64
+ */
65
+ logIn(permissions: any, options: any): Promise<ParseUser<import("./ParseObject").Attributes>>;
66
+ /**
67
+ * Links Facebook to an existing PFUser. This method delegates to the
68
+ * Facebook SDK to authenticate the user, and then automatically links
69
+ * the account to the Parse.User.
70
+ *
71
+ * Standard API:
72
+ *
73
+ * <code>link(user: Parse.User, permission: string, authData?: Object);</code>
74
+ *
75
+ * Advanced API: Used for handling your own oAuth tokens
76
+ * {@link https://docs.parseplatform.org/rest/guide/#linking-users}
77
+ *
78
+ * <code>link(user: Parse.User, authData: Object, options?: FullOptions);</code>
79
+ *
80
+ * @function link
81
+ * @name Parse.FacebookUtils.link
82
+ * @param {Parse.User} user User to link to Facebook. This must be the
83
+ * current user.
84
+ * @param {(string | object)} permissions The permissions required for Facebook
85
+ * log in. This is a comma-separated string of permissions.
86
+ * Alternatively, supply a Facebook authData object as described in our
87
+ * REST API docs if you want to handle getting facebook auth tokens
88
+ * yourself.
89
+ * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
90
+ * @returns {Promise}
91
+ */
92
+ link(user: any, permissions: any, options: any): any;
93
+ /**
94
+ * Unlinks the Parse.User from a Facebook account.
95
+ *
96
+ * @function unlink
97
+ * @name Parse.FacebookUtils.unlink
98
+ * @param {Parse.User} user User to unlink from Facebook. This must be the
99
+ * current user.
100
+ * @param {object} options Standard options object with success and error
101
+ * callbacks.
102
+ * @returns {Promise}
103
+ */
104
+ unlink: (user: any, options: any) => any;
105
+ _getAuthProvider(): AuthProvider;
106
+ };
107
+ export default FacebookUtils;
@@ -0,0 +1,2 @@
1
+ declare let IndexedDBStorageController: any;
2
+ export default IndexedDBStorageController;
@@ -0,0 +1,10 @@
1
+ import ParseInstallation from './ParseInstallation';
2
+ declare const InstallationController: {
3
+ updateInstallationOnDisk(installation: ParseInstallation): Promise<void>;
4
+ currentInstallationId(): Promise<string>;
5
+ currentInstallation(): Promise<ParseInstallation | null>;
6
+ _clearCache(): void;
7
+ _setInstallationIdCache(iid: string): void;
8
+ _setCurrentInstallationCache(installation: ParseInstallation, matchesDisk?: boolean): void;
9
+ };
10
+ export default InstallationController;
@@ -0,0 +1,128 @@
1
+ import { WebSocketController } from './CoreManager';
2
+ import LiveQuerySubscription from './LiveQuerySubscription';
3
+ import type ParseQuery from './ParseQuery';
4
+ /**
5
+ * Creates a new LiveQueryClient.
6
+ * <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
7
+ *
8
+ * A wrapper of a standard WebSocket client. We add several useful methods to
9
+ * help you connect/disconnect to LiveQueryServer, subscribe/unsubscribe a ParseQuery easily.
10
+ *
11
+ * javascriptKey and masterKey are used for verifying the LiveQueryClient when it tries
12
+ * to connect to the LiveQuery server
13
+ *
14
+ * We expose three events to help you monitor the status of the LiveQueryClient.
15
+ *
16
+ * <pre>
17
+ * const LiveQueryClient = Parse.LiveQueryClient;
18
+ * const client = new LiveQueryClient({
19
+ * applicationId: '',
20
+ * serverURL: '',
21
+ * javascriptKey: '',
22
+ * masterKey: ''
23
+ * });
24
+ * </pre>
25
+ *
26
+ * Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.
27
+ * <pre>
28
+ * client.on('open', () => {
29
+ *
30
+ * });</pre>
31
+ *
32
+ * Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.
33
+ * <pre>
34
+ * client.on('close', () => {
35
+ *
36
+ * });</pre>
37
+ *
38
+ * Error - When some network error or LiveQuery server error happens, you'll get this event.
39
+ * <pre>
40
+ * client.on('error', (error) => {
41
+ *
42
+ * });</pre>
43
+ *
44
+ * @alias Parse.LiveQueryClient
45
+ */
46
+ declare class LiveQueryClient {
47
+ attempts: number;
48
+ id: number;
49
+ requestId: number;
50
+ applicationId: string;
51
+ serverURL: string;
52
+ javascriptKey?: string;
53
+ masterKey?: string;
54
+ sessionToken?: string;
55
+ installationId?: string;
56
+ additionalProperties: boolean;
57
+ connectPromise: any;
58
+ subscriptions: Map<number, LiveQuerySubscription>;
59
+ socket: WebSocketController & {
60
+ closingPromise?: any;
61
+ };
62
+ state: string;
63
+ reconnectHandle: any;
64
+ emitter: any;
65
+ on: any;
66
+ emit: any;
67
+ /**
68
+ * @param {object} options
69
+ * @param {string} options.applicationId - applicationId of your Parse app
70
+ * @param {string} options.serverURL - <b>the URL of your LiveQuery server</b>
71
+ * @param {string} options.javascriptKey (optional)
72
+ * @param {string} options.masterKey (optional) Your Parse Master Key. (Node.js only!)
73
+ * @param {string} options.sessionToken (optional)
74
+ * @param {string} options.installationId (optional)
75
+ */
76
+ constructor({ applicationId, serverURL, javascriptKey, masterKey, sessionToken, installationId, }: {
77
+ applicationId: any;
78
+ serverURL: any;
79
+ javascriptKey: any;
80
+ masterKey: any;
81
+ sessionToken: any;
82
+ installationId: any;
83
+ });
84
+ shouldOpen(): any;
85
+ /**
86
+ * Subscribes to a ParseQuery
87
+ *
88
+ * If you provide the sessionToken, when the LiveQuery server gets ParseObject's
89
+ * updates from parse server, it'll try to check whether the sessionToken fulfills
90
+ * the ParseObject's ACL. The LiveQuery server will only send updates to clients whose
91
+ * sessionToken is fit for the ParseObject's ACL. You can check the LiveQuery protocol
92
+ * <a href="https://github.com/parse-community/parse-server/wiki/Parse-LiveQuery-Protocol-Specification">here</a> for more details. The subscription you get is the same subscription you get
93
+ * from our Standard API.
94
+ *
95
+ * @param {ParseQuery} query - the ParseQuery you want to subscribe to
96
+ * @param {string} sessionToken (optional)
97
+ * @returns {LiveQuerySubscription | undefined}
98
+ */
99
+ subscribe(query: ParseQuery, sessionToken?: string): LiveQuerySubscription | undefined;
100
+ /**
101
+ * After calling unsubscribe you'll stop receiving events from the subscription object.
102
+ *
103
+ * @param {object} subscription - subscription you would like to unsubscribe from.
104
+ * @returns {Promise | undefined}
105
+ */
106
+ unsubscribe(subscription: LiveQuerySubscription): Promise<void>;
107
+ /**
108
+ * After open is called, the LiveQueryClient will try to send a connect request
109
+ * to the LiveQuery server.
110
+ *
111
+ */
112
+ open(): void;
113
+ resubscribe(): void;
114
+ /**
115
+ * This method will close the WebSocket connection to this LiveQueryClient,
116
+ * cancel the auto reconnect and unsubscribe all subscriptions based on it.
117
+ *
118
+ * @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event}
119
+ */
120
+ close(): Promise<void>;
121
+ _handleReset(): void;
122
+ _handleWebSocketOpen(): void;
123
+ _handleWebSocketMessage(event: any): void;
124
+ _handleWebSocketClose(): void;
125
+ _handleWebSocketError(error: any): void;
126
+ _handleReconnect(): void;
127
+ }
128
+ export default LiveQueryClient;
@@ -0,0 +1,103 @@
1
+ import type ParseQuery from './ParseQuery';
2
+ import type { EventEmitter } from 'events';
3
+ /**
4
+ * Creates a new LiveQuery Subscription.
5
+ * <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
6
+ *
7
+ * <p>Response Object - Contains data from the client that made the request
8
+ * <ul>
9
+ * <li>clientId</li>
10
+ * <li>installationId - requires Parse Server 4.0.0+</li>
11
+ * </ul>
12
+ * </p>
13
+ *
14
+ * <p>Open Event - When you call query.subscribe(), we send a subscribe request to
15
+ * the LiveQuery server, when we get the confirmation from the LiveQuery server,
16
+ * this event will be emitted. When the client loses WebSocket connection to the
17
+ * LiveQuery server, we will try to auto reconnect the LiveQuery server. If we
18
+ * reconnect the LiveQuery server and successfully resubscribe the ParseQuery,
19
+ * you'll also get this event.
20
+ *
21
+ * <pre>
22
+ * subscription.on('open', (response) => {
23
+ *
24
+ * });</pre></p>
25
+ *
26
+ * <p>Create Event - When a new ParseObject is created and it fulfills the ParseQuery you subscribe,
27
+ * you'll get this event. The object is the ParseObject which is created.
28
+ *
29
+ * <pre>
30
+ * subscription.on('create', (object, response) => {
31
+ *
32
+ * });</pre></p>
33
+ *
34
+ * <p>Update Event - When an existing ParseObject (original) which fulfills the ParseQuery you subscribe
35
+ * is updated (The ParseObject fulfills the ParseQuery before and after changes),
36
+ * you'll get this event. The object is the ParseObject which is updated.
37
+ * Its content is the latest value of the ParseObject.
38
+ *
39
+ * Parse-Server 3.1.3+ Required for original object parameter
40
+ *
41
+ * <pre>
42
+ * subscription.on('update', (object, original, response) => {
43
+ *
44
+ * });</pre></p>
45
+ *
46
+ * <p>Enter Event - When an existing ParseObject's (original) old value doesn't fulfill the ParseQuery
47
+ * but its new value fulfills the ParseQuery, you'll get this event. The object is the
48
+ * ParseObject which enters the ParseQuery. Its content is the latest value of the ParseObject.
49
+ *
50
+ * Parse-Server 3.1.3+ Required for original object parameter
51
+ *
52
+ * <pre>
53
+ * subscription.on('enter', (object, original, response) => {
54
+ *
55
+ * });</pre></p>
56
+ *
57
+ *
58
+ * <p>Update Event - When an existing ParseObject's old value fulfills the ParseQuery but its new value
59
+ * doesn't fulfill the ParseQuery, you'll get this event. The object is the ParseObject
60
+ * which leaves the ParseQuery. Its content is the latest value of the ParseObject.
61
+ *
62
+ * <pre>
63
+ * subscription.on('leave', (object, response) => {
64
+ *
65
+ * });</pre></p>
66
+ *
67
+ *
68
+ * <p>Delete Event - When an existing ParseObject which fulfills the ParseQuery is deleted, you'll
69
+ * get this event. The object is the ParseObject which is deleted.
70
+ *
71
+ * <pre>
72
+ * subscription.on('delete', (object, response) => {
73
+ *
74
+ * });</pre></p>
75
+ *
76
+ *
77
+ * <p>Close Event - When the client loses the WebSocket connection to the LiveQuery
78
+ * server and we stop receiving events, you'll get this event.
79
+ *
80
+ * <pre>
81
+ * subscription.on('close', () => {
82
+ *
83
+ * });</pre></p>
84
+ */
85
+ declare class LiveQuerySubscription {
86
+ id: string | number;
87
+ query: ParseQuery;
88
+ sessionToken?: string;
89
+ subscribePromise: any;
90
+ unsubscribePromise: any;
91
+ subscribed: boolean;
92
+ emitter: EventEmitter;
93
+ on: EventEmitter['on'];
94
+ emit: EventEmitter['emit'];
95
+ constructor(id: string | number, query: ParseQuery, sessionToken?: string);
96
+ /**
97
+ * Close the subscription
98
+ *
99
+ * @returns {Promise}
100
+ */
101
+ unsubscribe(): Promise<void>;
102
+ }
103
+ export default LiveQuerySubscription;
@@ -0,0 +1,56 @@
1
+ import type ParseObject from './ParseObject';
2
+ /**
3
+ * Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
4
+ * To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
5
+ *
6
+ * Pin object to add to local datastore
7
+ *
8
+ * <pre>await object.pin();</pre>
9
+ * <pre>await object.pinWithName('pinName');</pre>
10
+ *
11
+ * Query pinned objects
12
+ *
13
+ * <pre>query.fromLocalDatastore();</pre>
14
+ * <pre>query.fromPin();</pre>
15
+ * <pre>query.fromPinWithName();</pre>
16
+ *
17
+ * <pre>const localObjects = await query.find();</pre>
18
+ *
19
+ * @class Parse.LocalDatastore
20
+ * @static
21
+ */
22
+ declare const LocalDatastore: {
23
+ isEnabled: boolean;
24
+ isSyncing: boolean;
25
+ fromPinWithName(name: string): Promise<Array<any>>;
26
+ pinWithName(name: string, value: any): Promise<void>;
27
+ unPinWithName(name: string): Promise<void>;
28
+ _getAllContents(): Promise<any>;
29
+ _getRawStorage(): Promise<any>;
30
+ _clear(): Promise<void>;
31
+ _handlePinAllWithName(name: string, objects: Array<ParseObject>): Promise<void>;
32
+ _handleUnPinAllWithName(name: string, objects: Array<ParseObject>): Promise<any[]>;
33
+ _getChildren(object: ParseObject): any;
34
+ _traverse(object: any, encountered: any): void;
35
+ _serializeObjectsFromPinName(name: string): Promise<any[]>;
36
+ _serializeObject(objectKey: string, localDatastore: any): Promise<any>;
37
+ _updateObjectIfPinned(object: ParseObject): Promise<void>;
38
+ _destroyObjectIfPinned(object: ParseObject): Promise<any[]>;
39
+ _updateLocalIdForObject(localId: string, object: ParseObject): Promise<any[]>;
40
+ /**
41
+ * Updates Local Datastore from Server
42
+ *
43
+ * <pre>
44
+ * await Parse.LocalDatastore.updateFromServer();
45
+ * </pre>
46
+ *
47
+ * @function updateFromServer
48
+ * @name Parse.LocalDatastore.updateFromServer
49
+ * @static
50
+ */
51
+ updateFromServer(): Promise<void>;
52
+ getKeyForObject(object: any): string;
53
+ getPinName(pinName?: string): string;
54
+ checkIfEnabled(): any;
55
+ };
56
+ export default LocalDatastore;
@@ -0,0 +1,2 @@
1
+ declare let LocalDatastoreController: any;
2
+ export default LocalDatastoreController;
@@ -0,0 +1,9 @@
1
+ declare const LocalDatastoreController: {
2
+ fromPinWithName(name: string): Promise<Array<any>>;
3
+ pinWithName(name: string, value: any): Promise<void>;
4
+ unPinWithName(name: string): Promise<void>;
5
+ getAllContents(): Promise<any>;
6
+ getRawStorage(): Promise<any>;
7
+ clear(): Promise<any>;
8
+ };
9
+ export default LocalDatastoreController;
@@ -0,0 +1,9 @@
1
+ declare const LocalDatastoreController: {
2
+ fromPinWithName(name: string): Promise<Array<any>>;
3
+ pinWithName(name: string, value: any): Promise<void>;
4
+ unPinWithName(name: string): Promise<void>;
5
+ getAllContents(): Promise<any>;
6
+ getRawStorage(): Promise<any>;
7
+ clear(): Promise<void>;
8
+ };
9
+ export default LocalDatastoreController;
@@ -0,0 +1,5 @@
1
+ declare const DEFAULT_PIN = "_default";
2
+ declare const PIN_PREFIX = "parsePin_";
3
+ declare const OBJECT_PREFIX = "Parse_LDS_";
4
+ declare function isLocalDatastoreKey(key: string): boolean;
5
+ export { DEFAULT_PIN, PIN_PREFIX, OBJECT_PREFIX, isLocalDatastoreKey };
@@ -0,0 +1,28 @@
1
+ import TaskQueue from './TaskQueue';
2
+ import type { Op } from './ParseOp';
3
+ import type ParseObject from './ParseObject';
4
+ export type AttributeMap = {
5
+ [attr: string]: any;
6
+ };
7
+ export type OpsMap = {
8
+ [attr: string]: Op;
9
+ };
10
+ export type ObjectCache = {
11
+ [attr: string]: string;
12
+ };
13
+ export type State = {
14
+ serverData: AttributeMap;
15
+ pendingOps: Array<OpsMap>;
16
+ objectCache: ObjectCache;
17
+ tasks: TaskQueue;
18
+ existed: boolean;
19
+ };
20
+ export declare function defaultState(): State;
21
+ export declare function setServerData(serverData: AttributeMap, attributes: AttributeMap): void;
22
+ export declare function setPendingOp(pendingOps: Array<OpsMap>, attr: string, op?: Op): void;
23
+ export declare function pushPendingState(pendingOps: Array<OpsMap>): void;
24
+ export declare function popPendingState(pendingOps: Array<OpsMap>): OpsMap;
25
+ export declare function mergeFirstPendingState(pendingOps: Array<OpsMap>): void;
26
+ export declare function estimateAttribute(serverData: AttributeMap, pendingOps: Array<OpsMap>, object: ParseObject, attr: string): any;
27
+ export declare function estimateAttributes(serverData: AttributeMap, pendingOps: Array<OpsMap>, object: ParseObject): AttributeMap;
28
+ export declare function commitServerChanges(serverData: AttributeMap, objectCache: ObjectCache, changes: AttributeMap): void;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * matchesQuery -- Determines if an object would be returned by a Parse Query
3
+ * It's a lightweight, where-clause only implementation of a full query engine.
4
+ * Since we find queries that match objects, rather than objects that match
5
+ * queries, we can avoid building a full-blown query tool.
6
+ *
7
+ * @param className
8
+ * @param object
9
+ * @param objects
10
+ * @param query
11
+ * @private
12
+ * @returns {boolean}
13
+ */
14
+ declare function matchesQuery(className: any, object: any, objects: any, query: any): boolean;
15
+ declare function validateQuery(query: any): void;
16
+ declare const OfflineQuery: {
17
+ matchesQuery: typeof matchesQuery;
18
+ validateQuery: typeof validateQuery;
19
+ };
20
+ export default OfflineQuery;