Skip to content

Commit 75cf216

Browse files
committed
switch tests to integration
1 parent 455a1b6 commit 75cf216

10 files changed

+434
-26
lines changed

src/CoreManager.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function requireMethods(name: string, methods: Array<string>, controller: any) {
204204
});
205205
}
206206

207-
module.exports = {
207+
const CoreManager = {
208208
get: function (key: string): any {
209209
if (config.hasOwnProperty(key)) {
210210
return config[key];
@@ -468,3 +468,6 @@ module.exports = {
468468
return config['HooksController'];
469469
},
470470
};
471+
472+
module.exports = CoreManager;
473+
export default CoreManager;

src/EventuallyQueue.js

+1
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,4 @@ const EventuallyQueue = {
373373
};
374374

375375
module.exports = EventuallyQueue;
376+
export default EventuallyQueue;

src/LocalDatastore.js

+1
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ const LocalDatastore = {
392392
};
393393

394394
module.exports = LocalDatastore;
395+
export default LocalDatastore;
395396

396397
if (process.env.PARSE_BUILD === 'react-native') {
397398
CoreManager.setLocalDatastoreController(require('./LocalDatastoreController.react-native'));

src/Storage.js

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ const Storage = {
9696
};
9797

9898
module.exports = Storage;
99+
export default Storage;
99100

100101
if (process.env.PARSE_BUILD === 'react-native') {
101102
CoreManager.setStorageController(require('./StorageController.react-native'));

types/CoreManager.d.ts

+184-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,184 @@
1-
export {};
1+
// @ts-nocheck
2+
export default CoreManager;
3+
declare namespace CoreManager {
4+
function get(key: string): any;
5+
function set(key: string, value: any): void;
6+
function setAnalyticsController(controller: AnalyticsController): void;
7+
function getAnalyticsController(): AnalyticsController;
8+
function setCloudController(controller: CloudController): void;
9+
function getCloudController(): CloudController;
10+
function setConfigController(controller: ConfigController): void;
11+
function getConfigController(): ConfigController;
12+
function setCryptoController(controller: CryptoController): void;
13+
function getCryptoController(): CryptoController;
14+
function setFileController(controller: FileController): void;
15+
function getFileController(): FileController;
16+
function setInstallationController(controller: InstallationController): void;
17+
function getInstallationController(): InstallationController;
18+
function setObjectController(controller: ObjectController): void;
19+
function getObjectController(): ObjectController;
20+
function setObjectStateController(controller: ObjectStateController): void;
21+
function getObjectStateController(): ObjectStateController;
22+
function setPushController(controller: PushController): void;
23+
function getPushController(): PushController;
24+
function setQueryController(controller: QueryController): void;
25+
function getQueryController(): QueryController;
26+
function setRESTController(controller: RESTController): void;
27+
function getRESTController(): RESTController;
28+
function setSchemaController(controller: SchemaController): void;
29+
function getSchemaController(): SchemaController;
30+
function setSessionController(controller: SessionController): void;
31+
function getSessionController(): SessionController;
32+
function setStorageController(controller: StorageController): void;
33+
function setLocalDatastoreController(controller: LocalDatastoreController): void;
34+
function getLocalDatastoreController(): LocalDatastoreController;
35+
function setLocalDatastore(store: any): void;
36+
function getLocalDatastore(): mixed;
37+
function getStorageController(): StorageController;
38+
function setAsyncStorage(storage: any): void;
39+
function getAsyncStorage(): mixed;
40+
function setWebSocketController(controller: WebSocketController): void;
41+
function getWebSocketController(): WebSocketController;
42+
function setUserController(controller: UserController): void;
43+
function getUserController(): UserController;
44+
function setLiveQueryController(controller: any): void;
45+
function getLiveQueryController(): any;
46+
function setHooksController(controller: HooksController): void;
47+
function getHooksController(): HooksController;
48+
}
49+
type AnalyticsController = {
50+
track: (name: string, dimensions: {
51+
[key: string]: string;
52+
}) => Promise<any>;
53+
};
54+
type CloudController = {
55+
run: (name: string, data: mixed, options: RequestOptions) => Promise<any>;
56+
getJobsData: (options: RequestOptions) => Promise<any>;
57+
startJob: (name: string, data: mixed, options: RequestOptions) => Promise<any>;
58+
};
59+
type ConfigController = {
60+
current: () => Promise<any>;
61+
get: () => Promise<any>;
62+
save: (attrs: {
63+
[key: string]: any;
64+
}) => Promise<any>;
65+
};
66+
type CryptoController = {
67+
encrypt: (obj: any, secretKey: string) => string;
68+
decrypt: (encryptedText: string, secretKey: any) => string;
69+
};
70+
type FileController = {
71+
saveFile: (name: string, source: FileSource, options: FullOptions) => Promise<any>;
72+
saveBase64: (name: string, source: FileSource, options: FullOptions) => Promise<any>;
73+
download: (uri: string) => Promise<any>;
74+
};
75+
type InstallationController = {
76+
currentInstallationId: () => Promise<any>;
77+
};
78+
type ObjectController = {
79+
fetch: (object: ParseObject | ParseObject[], forceFetch: boolean, options: RequestOptions) => Promise<any>;
80+
save: (object: ParseObject | (ParseFile | ParseObject)[], options: RequestOptions) => Promise<any>;
81+
destroy: (object: ParseObject | ParseObject[], options: RequestOptions) => Promise<any>;
82+
};
83+
type ObjectStateController = {
84+
getState: (obj: any) => State;
85+
initializeState: (obj: any, initial?: State) => State;
86+
removeState: (obj: any) => State;
87+
getServerData: (obj: any) => AttributeMap;
88+
setServerData: (obj: any, attributes: AttributeMap) => void;
89+
getPendingOps: (obj: any) => OpsMap[];
90+
setPendingOp: (obj: any, attr: string, op: Op) => void;
91+
pushPendingState: (obj: any) => void;
92+
popPendingState: (obj: any) => OpsMap;
93+
mergeFirstPendingState: (obj: any) => void;
94+
getObjectCache: (obj: any) => ObjectCache;
95+
estimateAttribute: (obj: any, attr: string) => mixed;
96+
estimateAttributes: (obj: any) => AttributeMap;
97+
commitServerChanges: (obj: any, changes: AttributeMap) => void;
98+
enqueueTask: (obj: any, task: () => Promise<any>) => Promise<any>;
99+
clearAllState: () => void;
100+
duplicateState: (source: any, dest: any) => void;
101+
};
102+
type PushController = {
103+
send: (data: PushData) => Promise<any>;
104+
};
105+
type QueryController = {
106+
find: (className: string, params: QueryJSON, options: RequestOptions) => Promise<any>;
107+
aggregate: (className: string, params: any, options: RequestOptions) => Promise<any>;
108+
};
109+
type RESTController = {
110+
request: (method: string, path: string, data: mixed, options: RequestOptions) => Promise<any>;
111+
ajax: (method: string, url: string, data: any, headers?: any, options: FullOptions) => Promise<any>;
112+
};
113+
type SchemaController = {
114+
purge: (className: string) => Promise<any>;
115+
get: (className: string, options: RequestOptions) => Promise<any>;
116+
delete: (className: string, options: RequestOptions) => Promise<any>;
117+
create: (className: string, params: any, options: RequestOptions) => Promise<any>;
118+
update: (className: string, params: any, options: RequestOptions) => Promise<any>;
119+
send(className: string, method: string, params: any, options: RequestOptions): Promise<any>;
120+
};
121+
type SessionController = {
122+
getSession: (token: RequestOptions) => Promise<any>;
123+
};
124+
type StorageController = {
125+
async: 0;
126+
getItem: (path: string) => string;
127+
setItem: (path: string, value: string) => void;
128+
removeItem: (path: string) => void;
129+
getItemAsync?: (path: string) => Promise<any>;
130+
setItemAsync?: (path: string, value: string) => Promise<any>;
131+
removeItemAsync?: (path: string) => Promise<any>;
132+
clear: () => void;
133+
} | {
134+
async: 1;
135+
getItem?: (path: string) => string;
136+
setItem?: (path: string, value: string) => void;
137+
removeItem?: (path: string) => void;
138+
getItemAsync: (path: string) => Promise<any>;
139+
setItemAsync: (path: string, value: string) => Promise<any>;
140+
removeItemAsync: (path: string) => Promise<any>;
141+
clear: () => void;
142+
};
143+
type LocalDatastoreController = {
144+
fromPinWithName: (name: string) => any;
145+
pinWithName: (name: string, objects: any) => void;
146+
unPinWithName: (name: string) => void;
147+
getAllContents: () => any;
148+
clear: () => void;
149+
};
150+
type WebSocketController = {
151+
onopen: () => void;
152+
onmessage: (message: any) => void;
153+
onclose: () => void;
154+
onerror: (error: any) => void;
155+
send: (data: any) => void;
156+
close: () => void;
157+
};
158+
type UserController = {
159+
setCurrentUser: (user: ParseUser) => Promise<any>;
160+
currentUser: () => ParseUser;
161+
currentUserAsync: () => Promise<any>;
162+
signUp: (user: ParseUser, attrs: AttributeMap, options: RequestOptions) => Promise<any>;
163+
logIn: (user: ParseUser, options: RequestOptions) => Promise<any>;
164+
become: (options: RequestOptions) => Promise<any>;
165+
hydrate: (userJSON: AttributeMap) => Promise<any>;
166+
logOut: (options: RequestOptions) => Promise<any>;
167+
me: (options: RequestOptions) => Promise<any>;
168+
requestPasswordReset: (email: string, options: RequestOptions) => Promise<any>;
169+
updateUserOnDisk: (user: ParseUser) => Promise<any>;
170+
upgradeToRevocableSession: (user: ParseUser, options: RequestOptions) => Promise<any>;
171+
linkWith: (user: ParseUser, authData: {
172+
[key: string]: mixed;
173+
}) => Promise<any>;
174+
removeUserFromDisk: () => Promise<any>;
175+
verifyPassword: (username: string, password: string, options: RequestOptions) => Promise<any>;
176+
requestEmailVerification: (email: string, options: RequestOptions) => Promise<any>;
177+
};
178+
type HooksController = {
179+
get: (type: string, functionName?: string, triggerName?: string) => Promise<any>;
180+
create: (hook: mixed) => Promise<any>;
181+
delete: (hook: mixed) => Promise<any>;
182+
update: (hook: mixed) => Promise<any>;
183+
send: (method: string, path: string, body?: mixed) => Promise<any>;
184+
};

types/EventuallyQueue.d.ts

+171-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,171 @@
1-
export {};
1+
export default EventuallyQueue;
2+
declare namespace EventuallyQueue {
3+
/**
4+
* Add object to queue with save operation.
5+
*
6+
* @function save
7+
* @name Parse.EventuallyQueue.save
8+
* @param {ParseObject} object Parse.Object to be saved eventually
9+
* @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#save Parse.Object.save} options.
10+
* @returns {Promise} A promise that is fulfilled if object is added to queue.
11+
* @static
12+
* @see Parse.Object#saveEventually
13+
*/
14+
function save(object: ParseObject, serverOptions?: SaveOptions): Promise<any>;
15+
/**
16+
* Add object to queue with save operation.
17+
*
18+
* @function destroy
19+
* @name Parse.EventuallyQueue.destroy
20+
* @param {ParseObject} object Parse.Object to be destroyed eventually
21+
* @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#destroy Parse.Object.destroy} options
22+
* @returns {Promise} A promise that is fulfilled if object is added to queue.
23+
* @static
24+
* @see Parse.Object#destroyEventually
25+
*/
26+
function destroy(object: ParseObject, serverOptions?: RequestOptions): Promise<any>;
27+
/**
28+
* Generate unique identifier to avoid duplicates and maintain previous state.
29+
*
30+
* @param {string} action save / destroy
31+
* @param {object} object Parse.Object to be queued
32+
* @returns {string}
33+
* @static
34+
* @ignore
35+
*/
36+
function generateQueueId(action: string, object: ParseObject): string;
37+
/**
38+
* Build queue object and add to queue.
39+
*
40+
* @param {string} action save / destroy
41+
* @param {object} object Parse.Object to be queued
42+
* @param {object} [serverOptions]
43+
* @returns {Promise} A promise that is fulfilled if object is added to queue.
44+
* @static
45+
* @ignore
46+
*/
47+
function enqueue(action: string, object: ParseObject, serverOptions?: RequestOptions | SaveOptions): Promise<any>;
48+
function store(data: any): Promise<void>;
49+
function load(): Promise<string>;
50+
/**
51+
* Sets the in-memory queue from local storage and returns.
52+
*
53+
* @function getQueue
54+
* @name Parse.EventuallyQueue.getQueue
55+
* @returns {Promise<Array>}
56+
* @static
57+
*/
58+
function getQueue(): Promise<any[]>;
59+
/**
60+
* Saves the queue to local storage
61+
*
62+
* @param {Queue} queue Queue containing Parse.Object data.
63+
* @returns {Promise} A promise that is fulfilled when queue is stored.
64+
* @static
65+
* @ignore
66+
*/
67+
function setQueue(queue: Queue): Promise<void>;
68+
/**
69+
* Removes Parse.Object data from queue.
70+
*
71+
* @param {string} queueId Unique identifier for Parse.Object data.
72+
* @returns {Promise} A promise that is fulfilled when queue is stored.
73+
* @static
74+
* @ignore
75+
*/
76+
function remove(queueId: string): Promise<void>;
77+
/**
78+
* Removes all objects from queue.
79+
*
80+
* @function clear
81+
* @name Parse.EventuallyQueue.clear
82+
* @returns {Promise} A promise that is fulfilled when queue is cleared.
83+
* @static
84+
*/
85+
function clear(): Promise<any>;
86+
/**
87+
* Return the index of a queueId in the queue. Returns -1 if not found.
88+
*
89+
* @param {Queue} queue Queue containing Parse.Object data.
90+
* @param {string} queueId Unique identifier for Parse.Object data.
91+
* @returns {number}
92+
* @static
93+
* @ignore
94+
*/
95+
function queueItemExists(queue: Queue, queueId: string): number;
96+
/**
97+
* Return the number of objects in the queue.
98+
*
99+
* @function length
100+
* @name Parse.EventuallyQueue.length
101+
* @returns {number}
102+
* @static
103+
*/
104+
function length(): number;
105+
/**
106+
* Sends the queue to the server.
107+
*
108+
* @function sendQueue
109+
* @name Parse.EventuallyQueue.sendQueue
110+
* @returns {Promise<boolean>} Returns true if queue was sent successfully.
111+
* @static
112+
*/
113+
function sendQueue(): Promise<boolean>;
114+
/**
115+
* Build queue object and add to queue.
116+
*
117+
* @param {ParseObject} object Parse.Object to be processed
118+
* @param {QueueObject} queueObject Parse.Object data from the queue
119+
* @returns {Promise} A promise that is fulfilled when operation is performed.
120+
* @static
121+
* @ignore
122+
*/
123+
function sendQueueCallback(object: ParseObject, queueObject: QueueObject): Promise<void>;
124+
/**
125+
* Start polling server for network connection.
126+
* Will send queue if connection is established.
127+
*
128+
* @function poll
129+
* @name Parse.EventuallyQueue.poll
130+
* @param [ms] Milliseconds to ping the server. Default 2000ms
131+
* @static
132+
*/
133+
function poll(ms?: number): void;
134+
/**
135+
* Turns off polling.
136+
*
137+
* @function stopPoll
138+
* @name Parse.EventuallyQueue.stopPoll
139+
* @static
140+
*/
141+
function stopPoll(): void;
142+
/**
143+
* Return true if pinging the server.
144+
*
145+
* @function isPolling
146+
* @name Parse.EventuallyQueue.isPolling
147+
* @returns {boolean}
148+
* @static
149+
*/
150+
function isPolling(): boolean;
151+
function _setPolling(flag: boolean): void;
152+
namespace process {
153+
function create(ObjectType: any, queueObject: any): Promise<void>;
154+
function byId(ObjectType: any, queueObject: any): Promise<void>;
155+
function byHash(ObjectType: any, queueObject: any): Promise<void>;
156+
}
157+
}
158+
import ParseObject from './ParseObject';
159+
import { SaveOptions } from './ParseObject';
160+
import { RequestOptions } from './RESTController';
161+
type Queue = QueueObject[];
162+
type QueueObject = {
163+
queueId: string;
164+
action: string;
165+
object: ParseObject;
166+
serverOptions: RequestOptions | SaveOptions;
167+
id: string;
168+
className: string;
169+
hash: string;
170+
createdAt: Date;
171+
};

0 commit comments

Comments
 (0)