parse 5.1.0-alpha.1 → 5.1.0-alpha.10

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 (139) hide show
  1. package/README.md +13 -0
  2. package/dist/parse.js +1452 -1043
  3. package/dist/parse.min.js +2 -2
  4. package/dist/parse.weapp.js +2355 -1082
  5. package/dist/parse.weapp.min.js +2 -2
  6. package/lib/browser/CoreManager.js +48 -171
  7. package/lib/browser/InstallationController.js +134 -23
  8. package/lib/browser/LiveQueryClient.js +43 -35
  9. package/lib/browser/LiveQuerySubscription.js +15 -5
  10. package/lib/browser/LocalDatastoreController.default.js +248 -0
  11. package/lib/browser/LocalDatastoreController.js +1 -246
  12. package/lib/browser/ObjectStateMutations.js +6 -5
  13. package/lib/browser/OfflineQuery.js +3 -2
  14. package/lib/browser/Parse.js +31 -7
  15. package/lib/browser/ParseACL.js +21 -11
  16. package/lib/browser/ParseFile.js +4 -0
  17. package/lib/browser/ParseHooks.js +2 -0
  18. package/lib/browser/ParseInstallation.js +274 -13
  19. package/lib/browser/ParseLiveQuery.js +32 -23
  20. package/lib/browser/ParseObject.js +37 -40
  21. package/lib/browser/ParseOp.js +21 -7
  22. package/lib/browser/ParseQuery.js +1 -0
  23. package/lib/browser/ParseRelation.js +12 -7
  24. package/lib/browser/ParseRole.js +2 -0
  25. package/lib/browser/ParseSession.js +1 -1
  26. package/lib/browser/ParseUser.js +51 -15
  27. package/lib/browser/RESTController.js +6 -5
  28. package/lib/browser/SingleInstanceStateController.js +2 -4
  29. package/lib/browser/Storage.js +1 -2
  30. package/lib/browser/StorageController.js +3 -0
  31. package/lib/browser/WebSocketController.js +13 -0
  32. package/lib/browser/arrayContainsObject.js +4 -3
  33. package/lib/browser/canBeSerialized.js +6 -4
  34. package/lib/browser/decode.js +8 -5
  35. package/lib/browser/encode.js +6 -4
  36. package/lib/browser/equals.js +4 -3
  37. package/lib/browser/unique.js +3 -2
  38. package/lib/browser/unsavedChildren.js +4 -2
  39. package/lib/browser/uuid.js +11 -5
  40. package/lib/node/CoreManager.js +48 -171
  41. package/lib/node/InstallationController.js +65 -21
  42. package/lib/node/LiveQueryClient.js +2 -5
  43. package/lib/node/LiveQuerySubscription.js +2 -2
  44. package/lib/node/LocalDatastoreController.default.js +67 -0
  45. package/lib/node/LocalDatastoreController.js +1 -65
  46. package/lib/node/ObjectStateMutations.js +8 -9
  47. package/lib/node/OfflineQuery.js +3 -2
  48. package/lib/node/Parse.js +31 -7
  49. package/lib/node/ParseACL.js +21 -11
  50. package/lib/node/ParseFile.js +4 -0
  51. package/lib/node/ParseHooks.js +2 -0
  52. package/lib/node/ParseInstallation.js +207 -7
  53. package/lib/node/ParseLiveQuery.js +2 -3
  54. package/lib/node/ParseObject.js +9 -12
  55. package/lib/node/ParseOp.js +21 -7
  56. package/lib/node/ParseQuery.js +1 -0
  57. package/lib/node/ParseRelation.js +14 -8
  58. package/lib/node/ParseRole.js +2 -0
  59. package/lib/node/ParseSession.js +1 -1
  60. package/lib/node/ParseUser.js +20 -13
  61. package/lib/node/RESTController.js +5 -5
  62. package/lib/node/SingleInstanceStateController.js +2 -8
  63. package/lib/node/Storage.js +1 -2
  64. package/lib/node/StorageController.js +3 -0
  65. package/lib/node/WebSocketController.js +10 -0
  66. package/lib/node/arrayContainsObject.js +4 -3
  67. package/lib/node/canBeSerialized.js +6 -4
  68. package/lib/node/decode.js +9 -5
  69. package/lib/node/encode.js +7 -4
  70. package/lib/node/equals.js +4 -3
  71. package/lib/node/unique.js +3 -2
  72. package/lib/node/unsavedChildren.js +4 -2
  73. package/lib/node/uuid.js +10 -8
  74. package/lib/react-native/CoreManager.js +39 -2
  75. package/lib/react-native/InstallationController.js +77 -9
  76. package/lib/react-native/LiveQueryClient.js +28 -20
  77. package/lib/react-native/LiveQuerySubscription.js +14 -5
  78. package/lib/react-native/LocalDatastoreController.default.js +91 -0
  79. package/lib/react-native/LocalDatastoreController.js +1 -91
  80. package/lib/react-native/ObjectStateMutations.js +6 -5
  81. package/lib/react-native/OfflineQuery.js +3 -2
  82. package/lib/react-native/Parse.js +23 -7
  83. package/lib/react-native/ParseACL.js +19 -11
  84. package/lib/react-native/ParseInstallation.js +115 -10
  85. package/lib/react-native/ParseLiveQuery.js +11 -2
  86. package/lib/react-native/ParseObject.js +28 -31
  87. package/lib/react-native/ParseOp.js +20 -6
  88. package/lib/react-native/ParseQuery.js +1 -0
  89. package/lib/react-native/ParseRelation.js +10 -7
  90. package/lib/react-native/ParseRole.js +2 -0
  91. package/lib/react-native/ParseUser.js +6 -2
  92. package/lib/react-native/RESTController.js +5 -5
  93. package/lib/react-native/SingleInstanceStateController.js +0 -2
  94. package/lib/react-native/Storage.js +1 -2
  95. package/lib/react-native/StorageController.js +1 -0
  96. package/lib/react-native/WebSocketController.js +5 -0
  97. package/lib/react-native/arrayContainsObject.js +3 -2
  98. package/lib/react-native/canBeSerialized.js +5 -3
  99. package/lib/react-native/decode.js +7 -5
  100. package/lib/react-native/encode.js +6 -4
  101. package/lib/react-native/equals.js +4 -3
  102. package/lib/react-native/unique.js +3 -2
  103. package/lib/react-native/unsavedChildren.js +3 -2
  104. package/lib/react-native/uuid.js +9 -4
  105. package/lib/weapp/CoreManager.js +48 -171
  106. package/lib/weapp/InstallationController.js +134 -23
  107. package/lib/weapp/LiveQueryClient.js +43 -35
  108. package/lib/weapp/LiveQuerySubscription.js +15 -5
  109. package/lib/weapp/LocalDatastoreController.default.js +248 -0
  110. package/lib/weapp/LocalDatastoreController.js +1 -246
  111. package/lib/weapp/ObjectStateMutations.js +6 -5
  112. package/lib/weapp/OfflineQuery.js +3 -2
  113. package/lib/weapp/Parse.js +31 -7
  114. package/lib/weapp/ParseACL.js +21 -11
  115. package/lib/weapp/ParseFile.js +4 -0
  116. package/lib/weapp/ParseHooks.js +2 -0
  117. package/lib/weapp/ParseInstallation.js +274 -13
  118. package/lib/weapp/ParseLiveQuery.js +32 -23
  119. package/lib/weapp/ParseObject.js +37 -40
  120. package/lib/weapp/ParseOp.js +21 -7
  121. package/lib/weapp/ParseQuery.js +1 -0
  122. package/lib/weapp/ParseRelation.js +12 -7
  123. package/lib/weapp/ParseRole.js +2 -0
  124. package/lib/weapp/ParseSession.js +1 -1
  125. package/lib/weapp/ParseUser.js +51 -15
  126. package/lib/weapp/RESTController.js +6 -5
  127. package/lib/weapp/SingleInstanceStateController.js +2 -4
  128. package/lib/weapp/Storage.js +1 -2
  129. package/lib/weapp/StorageController.js +3 -0
  130. package/lib/weapp/WebSocketController.js +13 -0
  131. package/lib/weapp/arrayContainsObject.js +4 -3
  132. package/lib/weapp/canBeSerialized.js +6 -4
  133. package/lib/weapp/decode.js +8 -5
  134. package/lib/weapp/encode.js +6 -4
  135. package/lib/weapp/equals.js +4 -3
  136. package/lib/weapp/unique.js +3 -2
  137. package/lib/weapp/unsavedChildren.js +4 -2
  138. package/lib/weapp/uuid.js +12 -5
  139. package/package.json +3 -1
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.default = canBeSerialized;
6
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
6
7
  var _ParseFile = _interopRequireDefault(require("./ParseFile"));
7
- var _ParseObject = _interopRequireDefault(require("./ParseObject"));
8
8
  var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
9
9
  function canBeSerialized(obj) {
10
- if (!(obj instanceof _ParseObject.default)) {
10
+ var ParseObject = _CoreManager.default.getParseObject();
11
+ if (!(obj instanceof ParseObject)) {
11
12
  return true;
12
13
  }
13
14
  var attributes = obj.attributes;
@@ -26,7 +27,8 @@ function canBeSerializedHelper(value) {
26
27
  if (value instanceof _ParseRelation.default) {
27
28
  return true;
28
29
  }
29
- if (value instanceof _ParseObject.default) {
30
+ var ParseObject = _CoreManager.default.getParseObject();
31
+ if (value instanceof ParseObject) {
30
32
  return !!value.id;
31
33
  }
32
34
  if (value instanceof _ParseFile.default) {
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.default = decode;
6
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
6
7
  var _ParseACL = _interopRequireDefault(require("./ParseACL"));
7
8
  var _ParseFile = _interopRequireDefault(require("./ParseFile"));
8
9
  var _ParseGeoPoint = _interopRequireDefault(require("./ParseGeoPoint"));
9
10
  var _ParsePolygon = _interopRequireDefault(require("./ParsePolygon"));
10
- var _ParseObject = _interopRequireDefault(require("./ParseObject"));
11
- var _ParseOp = require("./ParseOp");
12
11
  var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
13
12
  function decode(value) {
14
13
  if (value === null || typeof value !== 'object' || value instanceof Date) {
@@ -22,13 +21,16 @@ function decode(value) {
22
21
  return dup;
23
22
  }
24
23
  if (typeof value.__op === 'string') {
25
- return (0, _ParseOp.opFromJSON)(value);
24
+ var _CoreManager$getParse = _CoreManager.default.getParseOp(),
25
+ opFromJSON = _CoreManager$getParse.opFromJSON;
26
+ return opFromJSON(value);
26
27
  }
28
+ var ParseObject = _CoreManager.default.getParseObject();
27
29
  if (value.__type === 'Pointer' && value.className) {
28
- return _ParseObject.default.fromJSON(value);
30
+ return ParseObject.fromJSON(value);
29
31
  }
30
32
  if (value.__type === 'Object' && value.className) {
31
- return _ParseObject.default.fromJSON(value);
33
+ return ParseObject.fromJSON(value);
32
34
  }
33
35
  if (value.__type === 'Relation') {
34
36
  var relation = new _ParseRelation.default(null, null);
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.default = _default;
6
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
6
7
  var _ParseACL = _interopRequireDefault(require("./ParseACL"));
7
8
  var _ParseFile = _interopRequireDefault(require("./ParseFile"));
8
9
  var _ParseGeoPoint = _interopRequireDefault(require("./ParseGeoPoint"));
9
10
  var _ParsePolygon = _interopRequireDefault(require("./ParsePolygon"));
10
- var _ParseObject = _interopRequireDefault(require("./ParseObject"));
11
- var _ParseOp = require("./ParseOp");
12
11
  var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
13
12
  function encode(value, disallowObjects, forcePointers, seen, offline) {
14
- if (value instanceof _ParseObject.default) {
13
+ var ParseObject = _CoreManager.default.getParseObject();
14
+ if (value instanceof ParseObject) {
15
15
  if (disallowObjects) {
16
16
  throw new Error('Parse Objects not allowed here');
17
17
  }
@@ -25,7 +25,9 @@ function encode(value, disallowObjects, forcePointers, seen, offline) {
25
25
  seen = seen.concat(seenEntry);
26
26
  return value._toFullJSON(seen, offline);
27
27
  }
28
- if (value instanceof _ParseOp.Op || value instanceof _ParseACL.default || value instanceof _ParseGeoPoint.default || value instanceof _ParsePolygon.default || value instanceof _ParseRelation.default) {
28
+ var _CoreManager$getParse = _CoreManager.default.getParseOp(),
29
+ Op = _CoreManager$getParse.Op;
30
+ if (value instanceof Op || value instanceof _ParseACL.default || value instanceof _ParseGeoPoint.default || value instanceof _ParsePolygon.default || value instanceof _ParseRelation.default) {
29
31
  return value.toJSON();
30
32
  }
31
33
  if (value instanceof _ParseFile.default) {
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.default = equals;
6
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
6
7
  var _ParseACL = _interopRequireDefault(require("./ParseACL"));
7
8
  var _ParseFile = _interopRequireDefault(require("./ParseFile"));
8
9
  var _ParseGeoPoint = _interopRequireDefault(require("./ParseGeoPoint"));
9
- var _ParseObject = _interopRequireDefault(require("./ParseObject"));
10
10
  function equals(a, b) {
11
11
  var toString = Object.prototype.toString;
12
12
  if (toString.call(a) === '[object Date]' || toString.call(b) === '[object Date]') {
@@ -34,10 +34,11 @@ function equals(a, b) {
34
34
  }
35
35
  return true;
36
36
  }
37
- if (a instanceof _ParseACL.default || a instanceof _ParseFile.default || a instanceof _ParseGeoPoint.default || a instanceof _ParseObject.default) {
37
+ var ParseObject = _CoreManager.default.getParseObject();
38
+ if (a instanceof _ParseACL.default || a instanceof _ParseFile.default || a instanceof _ParseGeoPoint.default || a instanceof ParseObject) {
38
39
  return a.equals(b);
39
40
  }
40
- if (b instanceof _ParseObject.default) {
41
+ if (b instanceof ParseObject) {
41
42
  if (a.__type === 'Object' || a.__type === 'Pointer') {
42
43
  return a.objectId === b.id && a.className === b.className;
43
44
  }
@@ -4,11 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.default = unique;
6
6
  var _arrayContainsObject = _interopRequireDefault(require("./arrayContainsObject"));
7
- var _ParseObject = _interopRequireDefault(require("./ParseObject"));
7
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
8
8
  function unique(arr) {
9
9
  var uniques = [];
10
10
  arr.forEach(function (value) {
11
- if (value instanceof _ParseObject.default) {
11
+ var ParseObject = _CoreManager.default.getParseObject();
12
+ if (value instanceof ParseObject) {
12
13
  if (!(0, _arrayContainsObject.default)(uniques, value)) {
13
14
  uniques.push(value);
14
15
  }
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.default = unsavedChildren;
6
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
6
7
  var _ParseFile = _interopRequireDefault(require("./ParseFile"));
7
- var _ParseObject = _interopRequireDefault(require("./ParseObject"));
8
8
  var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
9
9
  function unsavedChildren(obj, allowDeepUnsaved) {
10
10
  var encountered = {
@@ -28,7 +28,8 @@ function unsavedChildren(obj, allowDeepUnsaved) {
28
28
  return unsaved.concat(encountered.files);
29
29
  }
30
30
  function traverse(obj, encountered, shouldThrow, allowDeepUnsaved) {
31
- if (obj instanceof _ParseObject.default) {
31
+ var ParseObject = _CoreManager.default.getParseObject();
32
+ if (obj instanceof ParseObject) {
32
33
  if (!obj.id && shouldThrow) {
33
34
  throw new Error('Cannot create a pointer to an unsaved Object.');
34
35
  }
@@ -1,5 +1,10 @@
1
+ Object.defineProperty(exports, "__esModule", {
2
+ value: true
3
+ });
4
+ exports.default = void 0;
5
+ var _uuid = require("uuid");
1
6
  var uuid = null;
2
- var _require = require('uuid'),
3
- v4 = _require.v4;
4
- uuid = v4;
5
- module.exports = uuid;
7
+ uuid = _uuid.v4;
8
+ module.exports = uuid;
9
+ var _default = uuid;
10
+ exports.default = _default;
@@ -8,176 +8,16 @@ _Object$defineProperty(exports, "__esModule", {
8
8
  exports.default = void 0;
9
9
  var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
10
10
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
11
- /*
12
- * @flow
13
- */
14
- /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
15
- /*:: import type ParseFile from './ParseFile';*/
16
- /*:: import type { FileSource } from './ParseFile';*/
17
- /*:: import type { Op } from './ParseOp';*/
18
- /*:: import type ParseObject from './ParseObject';*/
19
- /*:: import type { QueryJSON } from './ParseQuery';*/
20
- /*:: import type ParseUser from './ParseUser';*/
21
- /*:: import type { AuthData } from './ParseUser';*/
22
- /*:: import type { PushData } from './Push';*/
23
- /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
24
- /*:: type AnalyticsController = {
25
- track: (name: string, dimensions: { [key: string]: string }) => Promise,
26
- };*/
27
- /*:: type CloudController = {
28
- run: (name: string, data: mixed, options: RequestOptions) => Promise,
29
- getJobsData: (options: RequestOptions) => Promise,
30
- startJob: (name: string, data: mixed, options: RequestOptions) => Promise,
31
- };*/
32
- /*:: type ConfigController = {
33
- current: () => Promise,
34
- get: () => Promise,
35
- save: (attrs: { [key: string]: any }) => Promise,
36
- };*/
37
- /*:: type CryptoController = {
38
- encrypt: (obj: any, secretKey: string) => string,
39
- decrypt: (encryptedText: string, secretKey: any) => string,
40
- };*/
41
- /*:: type FileController = {
42
- saveFile: (name: string, source: FileSource, options: FullOptions) => Promise,
43
- saveBase64: (name: string, source: FileSource, options: FullOptions) => Promise,
44
- download: (uri: string) => Promise,
45
- };*/
46
- /*:: type InstallationController = {
47
- currentInstallationId: () => Promise,
48
- };*/
49
- /*:: type ObjectController = {
50
- fetch: (
51
- object: ParseObject | Array<ParseObject>,
52
- forceFetch: boolean,
53
- options: RequestOptions
54
- ) => Promise,
55
- save: (object: ParseObject | Array<ParseObject | ParseFile>, options: RequestOptions) => Promise,
56
- destroy: (object: ParseObject | Array<ParseObject>, options: RequestOptions) => Promise,
57
- };*/
58
- /*:: type ObjectStateController = {
59
- getState: (obj: any) => ?State,
60
- initializeState: (obj: any, initial?: State) => State,
61
- removeState: (obj: any) => ?State,
62
- getServerData: (obj: any) => AttributeMap,
63
- setServerData: (obj: any, attributes: AttributeMap) => void,
64
- getPendingOps: (obj: any) => Array<OpsMap>,
65
- setPendingOp: (obj: any, attr: string, op: ?Op) => void,
66
- pushPendingState: (obj: any) => void,
67
- popPendingState: (obj: any) => OpsMap,
68
- mergeFirstPendingState: (obj: any) => void,
69
- getObjectCache: (obj: any) => ObjectCache,
70
- estimateAttribute: (obj: any, attr: string) => mixed,
71
- estimateAttributes: (obj: any) => AttributeMap,
72
- commitServerChanges: (obj: any, changes: AttributeMap) => void,
73
- enqueueTask: (obj: any, task: () => Promise) => Promise,
74
- clearAllState: () => void,
75
- duplicateState: (source: any, dest: any) => void,
76
- };*/
77
- /*:: type PushController = {
78
- send: (data: PushData) => Promise,
79
- };*/
80
- /*:: type QueryController = {
81
- find: (className: string, params: QueryJSON, options: RequestOptions) => Promise,
82
- aggregate: (className: string, params: any, options: RequestOptions) => Promise,
83
- };*/
84
- /*:: type RESTController = {
85
- request: (method: string, path: string, data: mixed, options: RequestOptions) => Promise,
86
- ajax: (method: string, url: string, data: any, headers?: any, options: FullOptions) => Promise,
87
- };*/
88
- /*:: type SchemaController = {
89
- purge: (className: string) => Promise,
90
- get: (className: string, options: RequestOptions) => Promise,
91
- delete: (className: string, options: RequestOptions) => Promise,
92
- create: (className: string, params: any, options: RequestOptions) => Promise,
93
- update: (className: string, params: any, options: RequestOptions) => Promise,
94
- send(className: string, method: string, params: any, options: RequestOptions): Promise,
95
- };*/
96
- /*:: type SessionController = {
97
- getSession: (token: RequestOptions) => Promise,
98
- };*/
99
- /*:: type StorageController =
100
- | {
101
- async: 0,
102
- getItem: (path: string) => ?string,
103
- setItem: (path: string, value: string) => void,
104
- removeItem: (path: string) => void,
105
- getItemAsync?: (path: string) => Promise,
106
- setItemAsync?: (path: string, value: string) => Promise,
107
- removeItemAsync?: (path: string) => Promise,
108
- clear: () => void,
109
- }
110
- | {
111
- async: 1,
112
- getItem?: (path: string) => ?string,
113
- setItem?: (path: string, value: string) => void,
114
- removeItem?: (path: string) => void,
115
- getItemAsync: (path: string) => Promise,
116
- setItemAsync: (path: string, value: string) => Promise,
117
- removeItemAsync: (path: string) => Promise,
118
- clear: () => void,
119
- };*/
120
- /*:: type LocalDatastoreController = {
121
- fromPinWithName: (name: string) => ?any,
122
- pinWithName: (name: string, objects: any) => void,
123
- unPinWithName: (name: string) => void,
124
- getAllContents: () => ?any,
125
- clear: () => void,
126
- };*/
127
- /*:: type UserController = {
128
- setCurrentUser: (user: ParseUser) => Promise,
129
- currentUser: () => ?ParseUser,
130
- currentUserAsync: () => Promise,
131
- signUp: (user: ParseUser, attrs: AttributeMap, options: RequestOptions) => Promise,
132
- logIn: (user: ParseUser, options: RequestOptions) => Promise,
133
- become: (options: RequestOptions) => Promise,
134
- hydrate: (userJSON: AttributeMap) => Promise,
135
- logOut: (options: RequestOptions) => Promise,
136
- me: (options: RequestOptions) => Promise,
137
- requestPasswordReset: (email: string, options: RequestOptions) => Promise,
138
- updateUserOnDisk: (user: ParseUser) => Promise,
139
- upgradeToRevocableSession: (user: ParseUser, options: RequestOptions) => Promise,
140
- linkWith: (user: ParseUser, authData: AuthData) => Promise,
141
- removeUserFromDisk: () => Promise,
142
- verifyPassword: (username: string, password: string, options: RequestOptions) => Promise,
143
- requestEmailVerification: (email: string, options: RequestOptions) => Promise,
144
- };*/
145
- /*:: type HooksController = {
146
- get: (type: string, functionName?: string, triggerName?: string) => Promise,
147
- create: (hook: mixed) => Promise,
148
- delete: (hook: mixed) => Promise,
149
- update: (hook: mixed) => Promise,
150
- send: (method: string, path: string, body?: mixed) => Promise,
151
- };*/
152
- /*:: type WebSocketController = {
11
+ /** Based on https://github.com/react-native-async-storage/async-storage/blob/main/packages/default-storage-backend/src/types.ts */
12
+ /*:: export type WebSocketController = {
153
13
  onopen: () => void,
154
14
  onmessage: (message: any) => void,
155
- onclose: () => void,
15
+ onclose: (arg?: any) => void,
156
16
  onerror: (error: any) => void,
157
17
  send: (data: any) => void,
158
18
  close: () => void,
159
19
  };*/
160
- /*:: type Config = {
161
- AnalyticsController?: AnalyticsController,
162
- CloudController?: CloudController,
163
- ConfigController?: ConfigController,
164
- FileController?: FileController,
165
- InstallationController?: InstallationController,
166
- ObjectController?: ObjectController,
167
- ObjectStateController?: ObjectStateController,
168
- PushController?: PushController,
169
- QueryController?: QueryController,
170
- RESTController?: RESTController,
171
- SchemaController?: SchemaController,
172
- SessionController?: SessionController,
173
- StorageController?: StorageController,
174
- LocalDatastoreController?: LocalDatastoreController,
175
- UserController?: UserController,
176
- HooksController?: HooksController,
177
- WebSocketController?: WebSocketController,
178
- };*/
179
- var config /*: Config & { [key: string]: mixed }*/ = {
180
- // Defaults
20
+ var config /*: Config & { [key: string]: any }*/ = {
181
21
  IS_NODE: typeof process !== 'undefined' && !!process.versions && !!process.versions.node && !process.versions.electron,
182
22
  REQUEST_ATTEMPT_LIMIT: 5,
183
23
  REQUEST_BATCH_SIZE: 20,
@@ -187,7 +27,7 @@ var config /*: Config & { [key: string]: mixed }*/ = {
187
27
  SERVER_AUTH_TOKEN: null,
188
28
  LIVEQUERY_SERVER_URL: null,
189
29
  ENCRYPTED_KEY: null,
190
- VERSION: 'js' + "5.1.0-alpha.1",
30
+ VERSION: 'js' + "5.1.0-alpha.10",
191
31
  APPLICATION_ID: null,
192
32
  JAVASCRIPT_KEY: null,
193
33
  MASTER_KEY: null,
@@ -261,11 +101,18 @@ var CoreManager = {
261
101
  requireMethods('FileController', ['saveFile', 'saveBase64'], controller);
262
102
  config['FileController'] = controller;
263
103
  },
104
+ setEventuallyQueue: function (controller /*: EventuallyQueue*/) {
105
+ requireMethods('EventuallyQueue', ['poll', 'save', 'destroy'], controller);
106
+ config['EventuallyQueue'] = controller;
107
+ },
108
+ getEventuallyQueue: function () /*: EventuallyQueue*/{
109
+ return config['EventuallyQueue'];
110
+ },
264
111
  getFileController: function () /*: FileController*/{
265
112
  return config['FileController'];
266
113
  },
267
114
  setInstallationController: function (controller /*: InstallationController*/) {
268
- requireMethods('InstallationController', ['currentInstallationId'], controller);
115
+ requireMethods('InstallationController', ['currentInstallationId', 'currentInstallation', 'updateInstallationOnDisk'], controller);
269
116
  config['InstallationController'] = controller;
270
117
  },
271
118
  getInstallationController: function () /*: InstallationController*/{
@@ -350,16 +197,16 @@ var CoreManager = {
350
197
  getStorageController: function () /*: StorageController*/{
351
198
  return config['StorageController'];
352
199
  },
353
- setAsyncStorage: function (storage /*: any*/) {
200
+ setAsyncStorage: function (storage /*: AsyncStorageType*/) {
354
201
  config['AsyncStorage'] = storage;
355
202
  },
356
203
  getAsyncStorage: function () {
357
204
  return config['AsyncStorage'];
358
205
  },
359
- setWebSocketController: function (controller /*: WebSocketController*/) {
206
+ setWebSocketController: function (controller /*: new (url: string | URL, protocols?: string | string[] | undefined) => WebSocketController*/) {
360
207
  config['WebSocketController'] = controller;
361
208
  },
362
- getWebSocketController: function () /*: WebSocketController*/{
209
+ getWebSocketController: function () /*: new (url: string | URL, protocols?: string | string[] | undefined) => WebSocketController*/{
363
210
  return config['WebSocketController'];
364
211
  },
365
212
  setUserController: function (controller /*: UserController*/) {
@@ -369,11 +216,11 @@ var CoreManager = {
369
216
  getUserController: function () /*: UserController*/{
370
217
  return config['UserController'];
371
218
  },
372
- setLiveQueryController: function (controller /*: any*/) {
219
+ setLiveQueryController: function (controller /*: LiveQueryControllerType*/) {
373
220
  requireMethods('LiveQueryController', ['setDefaultLiveQueryClient', 'getDefaultLiveQueryClient', '_clearCachedDefaultClient'], controller);
374
221
  config['LiveQueryController'] = controller;
375
222
  },
376
- getLiveQueryController: function () /*: any*/{
223
+ getLiveQueryController: function () /*: LiveQueryControllerType*/{
377
224
  return config['LiveQueryController'];
378
225
  },
379
226
  setHooksController: function (controller /*: HooksController*/) {
@@ -382,6 +229,36 @@ var CoreManager = {
382
229
  },
383
230
  getHooksController: function () /*: HooksController*/{
384
231
  return config['HooksController'];
232
+ },
233
+ setParseOp: function (op /*: ParseOp*/) {
234
+ config['ParseOp'] = op;
235
+ },
236
+ getParseOp: function () {
237
+ return config['ParseOp'];
238
+ },
239
+ setParseObject: function (object /*: ParseObject*/) {
240
+ config['ParseObject'] = object;
241
+ },
242
+ getParseObject: function () /*: ParseObject*/{
243
+ return config['ParseObject'];
244
+ },
245
+ setParseQuery: function (query /*: ParseQuery*/) {
246
+ config['ParseQuery'] = query;
247
+ },
248
+ getParseQuery: function () {
249
+ return config['ParseQuery'];
250
+ },
251
+ setParseRole: function (role /*: ParseRole*/) {
252
+ config['ParseRole'] = role;
253
+ },
254
+ getParseRole: function () /*: ParseRole*/{
255
+ return config['ParseRole'];
256
+ },
257
+ setParseUser: function (user /*: ParseUser*/) {
258
+ config['ParseUser'] = user;
259
+ },
260
+ getParseUser: function () /*: ParseUser*/{
261
+ return config['ParseUser'];
385
262
  }
386
263
  };
387
264
  module.exports = CoreManager;
@@ -1,37 +1,148 @@
1
1
  "use strict";
2
2
 
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
3
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
- var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
5
+ _Object$defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
10
+ var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
11
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
12
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
5
13
  var _Storage = _interopRequireDefault(require("./Storage"));
6
- /**
7
- * @flow
8
- */
9
-
10
- var uuidv4 = require('./uuid');
11
- var iidCache = null;
14
+ var _ParseInstallation = _interopRequireDefault(require("./ParseInstallation"));
15
+ var _uuid = _interopRequireDefault(require("./uuid"));
16
+ var CURRENT_INSTALLATION_KEY = 'currentInstallation';
17
+ var CURRENT_INSTALLATION_ID_KEY = 'currentInstallationId';
18
+ var iidCache /*: string | null*/ = null;
19
+ var currentInstallationCache = null;
20
+ var currentInstallationCacheMatchesDisk = false;
12
21
  var InstallationController = {
22
+ updateInstallationOnDisk: function (installation /*: ParseInstallation*/) /*: Promise<void>*/{
23
+ var _this = this;
24
+ return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
25
+ var path;
26
+ return _regenerator.default.wrap(function (_context) {
27
+ while (1) switch (_context.prev = _context.next) {
28
+ case 0:
29
+ path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
30
+ _context.next = 3;
31
+ return _Storage.default.setItemAsync(path, (0, _stringify.default)(installation.toJSON()));
32
+ case 3:
33
+ _this._setCurrentInstallationCache(installation);
34
+ case 4:
35
+ case "end":
36
+ return _context.stop();
37
+ }
38
+ }, _callee);
39
+ }))();
40
+ },
13
41
  currentInstallationId: function () /*: Promise<string>*/{
14
- if (typeof iidCache === 'string') {
15
- return _promise.default.resolve(iidCache);
16
- }
17
- var path = _Storage.default.generatePath('installationId');
18
- return _Storage.default.getItemAsync(path).then(function (iid) {
19
- if (!iid) {
20
- iid = uuidv4();
21
- return _Storage.default.setItemAsync(path, iid).then(function () {
22
- iidCache = iid;
23
- return iid;
24
- });
25
- }
26
- iidCache = iid;
27
- return iid;
28
- });
42
+ return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
43
+ var path, iid;
44
+ return _regenerator.default.wrap(function (_context2) {
45
+ while (1) switch (_context2.prev = _context2.next) {
46
+ case 0:
47
+ if (!(typeof iidCache === 'string')) {
48
+ _context2.next = 2;
49
+ break;
50
+ }
51
+ return _context2.abrupt("return", iidCache);
52
+ case 2:
53
+ path = _Storage.default.generatePath(CURRENT_INSTALLATION_ID_KEY);
54
+ _context2.next = 5;
55
+ return _Storage.default.getItemAsync(path);
56
+ case 5:
57
+ iid = _context2.sent;
58
+ if (iid) {
59
+ _context2.next = 9;
60
+ break;
61
+ }
62
+ iid = (0, _uuid.default)();
63
+ return _context2.abrupt("return", _Storage.default.setItemAsync(path, iid).then(function () {
64
+ iidCache = iid;
65
+ return iid;
66
+ }));
67
+ case 9:
68
+ iidCache = iid;
69
+ return _context2.abrupt("return", iid);
70
+ case 11:
71
+ case "end":
72
+ return _context2.stop();
73
+ }
74
+ }, _callee2);
75
+ }))();
76
+ },
77
+ currentInstallation: function () /*: Promise<ParseInstallation | null>*/{
78
+ var _this2 = this;
79
+ return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
80
+ var path, installationData, current, installationId, installation;
81
+ return _regenerator.default.wrap(function (_context3) {
82
+ while (1) switch (_context3.prev = _context3.next) {
83
+ case 0:
84
+ if (!currentInstallationCache) {
85
+ _context3.next = 2;
86
+ break;
87
+ }
88
+ return _context3.abrupt("return", currentInstallationCache);
89
+ case 2:
90
+ if (!currentInstallationCacheMatchesDisk) {
91
+ _context3.next = 4;
92
+ break;
93
+ }
94
+ return _context3.abrupt("return", null);
95
+ case 4:
96
+ path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
97
+ _context3.next = 7;
98
+ return _Storage.default.getItemAsync(path);
99
+ case 7:
100
+ installationData = _context3.sent;
101
+ currentInstallationCacheMatchesDisk = true;
102
+ if (!installationData) {
103
+ _context3.next = 15;
104
+ break;
105
+ }
106
+ installationData = JSON.parse(installationData);
107
+ installationData.className = '_Installation';
108
+ current = _ParseInstallation.default.fromJSON(installationData);
109
+ currentInstallationCache = current;
110
+ return _context3.abrupt("return", current);
111
+ case 15:
112
+ _context3.next = 17;
113
+ return _this2.currentInstallationId();
114
+ case 17:
115
+ installationId = _context3.sent;
116
+ installation = new _ParseInstallation.default();
117
+ installation.set('deviceType', _ParseInstallation.default.DEVICE_TYPES.WEB);
118
+ installation.set('installationId', installationId);
119
+ installation.set('parseVersion', _CoreManager.default.get('VERSION'));
120
+ currentInstallationCache = installation;
121
+ _context3.next = 25;
122
+ return _Storage.default.setItemAsync(path, (0, _stringify.default)(installation.toJSON()));
123
+ case 25:
124
+ return _context3.abrupt("return", installation);
125
+ case 26:
126
+ case "end":
127
+ return _context3.stop();
128
+ }
129
+ }, _callee3);
130
+ }))();
29
131
  },
30
132
  _clearCache: function () {
31
133
  iidCache = null;
134
+ currentInstallationCache = null;
135
+ currentInstallationCacheMatchesDisk = false;
32
136
  },
33
137
  _setInstallationIdCache: function (iid /*: string*/) {
34
138
  iidCache = iid;
139
+ },
140
+ _setCurrentInstallationCache: function (installation /*: ParseInstallation*/) {
141
+ var matchesDisk /*: boolean*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
142
+ currentInstallationCache = installation;
143
+ currentInstallationCacheMatchesDisk = matchesDisk;
35
144
  }
36
145
  };
37
- module.exports = InstallationController;
146
+ module.exports = InstallationController;
147
+ var _default = InstallationController;
148
+ exports.default = _default;