diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81c922c3b..99e2997aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,8 +27,6 @@ jobs: with: cache: npm - run: npm ci - - name: Build Types - run: npm run build:types - name: Test Types run: npm run test:types 2>&1 | tee silent.txt; check-docs: diff --git a/package.json b/package.json index 2acbc5a43..90ec2b8ca 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ }, "scripts": { "build": "node build_releases.js", - "build:types": "tsc && prettier --write 'types/{**/*,*}.ts' && npm run lint:fix", + "build:types": "tsc", "release": "node build_releases.js && npm publish", "test": "cross-env PARSE_BUILD=node jest", "test:mongodb": "npm run test:mongodb:runnerstart && npm run integration", @@ -114,7 +114,7 @@ "docs": "jsdoc -c ./jsdoc-conf.json ./src", "madge:circular": "madge ./src --extensions js,ts --circular", "prepare": "husky && npm run build", - "pre-commit": "lint-staged", + "pre-commit": "lint-staged && npm run build:types", "release_docs": "./release_docs.sh", "gulp": "gulp", "prettier": "prettier --write '{src,integration,types}/{**/*,*}.{js,ts}' && npm run lint:fix", diff --git a/types/Analytics.d.ts b/types/Analytics.d.ts index ae2ff3ac9..498c9c912 100644 --- a/types/Analytics.d.ts +++ b/types/Analytics.d.ts @@ -37,9 +37,6 @@ * @returns {Promise} A promise that is resolved when the round-trip * to the server completes. */ -export declare function track( - name: string, - dimensions: { +export declare function track(name: string, dimensions: { [key: string]: string; - } -): Promise; +}): Promise; diff --git a/types/AnonymousUtils.d.ts b/types/AnonymousUtils.d.ts index d7517bf94..aedb277d4 100644 --- a/types/AnonymousUtils.d.ts +++ b/types/AnonymousUtils.d.ts @@ -29,56 +29,56 @@ import type { RequestOptions } from './RESTController'; * @static */ declare const AnonymousUtils: { - /** - * Gets whether the user has their account linked to anonymous user. - * - * @function isLinked - * @name Parse.AnonymousUtils.isLinked - * @param {Parse.User} user User to check for. - * The user must be logged in on this device. - * @returns {boolean} true if the user has their account - * linked to an anonymous user. - * @static - */ - isLinked(user: ParseUser): boolean; - /** - * Logs in a user Anonymously. - * - * @function logIn - * @name Parse.AnonymousUtils.logIn - * @param {object} options MasterKey / SessionToken. - * @returns {Promise} Logged in user - * @static - */ - logIn(options?: RequestOptions): Promise; - /** - * Links Anonymous User to an existing PFUser. - * - * @function link - * @name Parse.AnonymousUtils.link - * @param {Parse.User} user User to link. This must be the current user. - * @param {object} options MasterKey / SessionToken. - * @returns {Promise} Linked with User - * @static - */ - link(user: ParseUser, options?: RequestOptions): Promise; - /** - * Returns true if Authentication Provider has been registered for use. - * - * @function isRegistered - * @name Parse.AnonymousUtils.isRegistered - * @returns {boolean} - * @static - */ - isRegistered(): boolean; - _getAuthProvider(): { - restoreAuthentication(): boolean; - getAuthType(): string; - getAuthData(): { - authData: { - id: string; - }; + /** + * Gets whether the user has their account linked to anonymous user. + * + * @function isLinked + * @name Parse.AnonymousUtils.isLinked + * @param {Parse.User} user User to check for. + * The user must be logged in on this device. + * @returns {boolean} true if the user has their account + * linked to an anonymous user. + * @static + */ + isLinked(user: ParseUser): boolean; + /** + * Logs in a user Anonymously. + * + * @function logIn + * @name Parse.AnonymousUtils.logIn + * @param {object} options MasterKey / SessionToken. + * @returns {Promise} Logged in user + * @static + */ + logIn(options?: RequestOptions): Promise; + /** + * Links Anonymous User to an existing PFUser. + * + * @function link + * @name Parse.AnonymousUtils.link + * @param {Parse.User} user User to link. This must be the current user. + * @param {object} options MasterKey / SessionToken. + * @returns {Promise} Linked with User + * @static + */ + link(user: ParseUser, options?: RequestOptions): Promise; + /** + * Returns true if Authentication Provider has been registered for use. + * + * @function isRegistered + * @name Parse.AnonymousUtils.isRegistered + * @returns {boolean} + * @static + */ + isRegistered(): boolean; + _getAuthProvider(): { + restoreAuthentication(): boolean; + getAuthType(): string; + getAuthData(): { + authData: { + id: string; + }; + }; }; - }; }; export default AnonymousUtils; diff --git a/types/CoreManager.d.ts b/types/CoreManager.d.ts index f7aeefda3..d2bbd484f 100644 --- a/types/CoreManager.d.ts +++ b/types/CoreManager.d.ts @@ -16,364 +16,283 @@ import type LiveQueryClient from './LiveQueryClient'; import type ParseSchema from './ParseSchema'; import type ParseInstallation from './ParseInstallation'; type AnalyticsController = { - track: ( - name: string, - dimensions: { - [key: string]: string; - } - ) => Promise; + track: (name: string, dimensions: { + [key: string]: string; + }) => Promise; }; type CloudController = { - run: (name: string, data: any, options: RequestOptions) => Promise; - getJobsData: (options: RequestOptions) => Promise; - /** Returns promise which resolves with JobStatusId of the job */ - startJob: (name: string, data: any, options: RequestOptions) => Promise; + run: (name: string, data: any, options: RequestOptions) => Promise; + getJobsData: (options: RequestOptions) => Promise; + /** Returns promise which resolves with JobStatusId of the job */ + startJob: (name: string, data: any, options: RequestOptions) => Promise; }; type ConfigController = { - current: () => Promise | ParseConfig; - get: (opts?: RequestOptions) => Promise; - save: ( - attrs: { - [key: string]: any; - }, - masterKeyOnlyFlags?: { - [key: string]: any; - } - ) => Promise; + current: () => Promise | ParseConfig; + get: (opts?: RequestOptions) => Promise; + save: (attrs: { + [key: string]: any; + }, masterKeyOnlyFlags?: { + [key: string]: any; + }) => Promise; }; type CryptoController = { - encrypt: (obj: any, secretKey: string) => string; - decrypt: (encryptedText: string, secretKey: any) => string; + encrypt: (obj: any, secretKey: string) => string; + decrypt: (encryptedText: string, secretKey: any) => string; }; type FileController = { - saveFile: (name: string, source: FileSource, options?: FullOptions) => Promise; - saveBase64: ( - name: string, - source: FileSource, - options?: FileSaveOptions - ) => Promise<{ - name: string; - url: string; - }>; - download: ( - uri: string, - options?: any - ) => Promise<{ - base64?: string; - contentType?: string; - }>; - deleteFile: ( - name: string, - options?: { - useMasterKey?: boolean; - } - ) => Promise; + saveFile: (name: string, source: FileSource, options?: FullOptions) => Promise; + saveBase64: (name: string, source: FileSource, options?: FileSaveOptions) => Promise<{ + name: string; + url: string; + }>; + download: (uri: string, options?: any) => Promise<{ + base64?: string; + contentType?: string; + }>; + deleteFile: (name: string, options?: { + useMasterKey?: boolean; + }) => Promise; }; type InstallationController = { - currentInstallationId: () => Promise; - currentInstallation: () => Promise; - updateInstallationOnDisk: (installation: ParseInstallation) => Promise; + currentInstallationId: () => Promise; + currentInstallation: () => Promise; + updateInstallationOnDisk: (installation: ParseInstallation) => Promise; }; type ObjectController = { - fetch: ( - object: ParseObject | Array, - forceFetch: boolean, - options: RequestOptions - ) => Promise | ParseObject | undefined>; - save: ( - object: ParseObject | Array | null, - options: RequestOptions - ) => Promise | ParseFile | undefined>; - destroy: ( - object: ParseObject | Array, - options: RequestOptions - ) => Promise>; + fetch: (object: ParseObject | Array, forceFetch: boolean, options: RequestOptions) => Promise | ParseObject | undefined>; + save: (object: ParseObject | Array | null, options: RequestOptions) => Promise | ParseFile | undefined>; + destroy: (object: ParseObject | Array, options: RequestOptions) => Promise>; }; type ObjectStateController = { - getState: (obj: any) => State | null; - initializeState: (obj: any, initial?: State) => State; - removeState: (obj: any) => State | null; - getServerData: (obj: any) => AttributeMap; - setServerData: (obj: any, attributes: AttributeMap) => void; - getPendingOps: (obj: any) => Array; - setPendingOp: (obj: any, attr: string, op?: Op) => void; - pushPendingState: (obj: any) => void; - popPendingState: (obj: any) => OpsMap | undefined; - mergeFirstPendingState: (obj: any) => void; - getObjectCache: (obj: any) => ObjectCache; - estimateAttribute: (obj: any, attr: string) => any; - estimateAttributes: (obj: any) => AttributeMap; - commitServerChanges: (obj: any, changes: AttributeMap) => void; - enqueueTask: (obj: any, task: () => Promise) => Promise; - clearAllState: () => void; - duplicateState: (source: any, dest: any) => void; + getState: (obj: any) => State | null; + initializeState: (obj: any, initial?: State) => State; + removeState: (obj: any) => State | null; + getServerData: (obj: any) => AttributeMap; + setServerData: (obj: any, attributes: AttributeMap) => void; + getPendingOps: (obj: any) => Array; + setPendingOp: (obj: any, attr: string, op?: Op) => void; + pushPendingState: (obj: any) => void; + popPendingState: (obj: any) => OpsMap | undefined; + mergeFirstPendingState: (obj: any) => void; + getObjectCache: (obj: any) => ObjectCache; + estimateAttribute: (obj: any, attr: string) => any; + estimateAttributes: (obj: any) => AttributeMap; + commitServerChanges: (obj: any, changes: AttributeMap) => void; + enqueueTask: (obj: any, task: () => Promise) => Promise; + clearAllState: () => void; + duplicateState: (source: any, dest: any) => void; }; type PushController = { - send: (data: PushData, options?: FullOptions) => Promise; + send: (data: PushData, options?: FullOptions) => Promise; }; type QueryController = { - find( - className: string, - params: QueryJSON, - options: RequestOptions - ): Promise<{ - results?: Array; - className?: string; - count?: number; - }>; - aggregate( - className: string, - params: any, - options: RequestOptions - ): Promise<{ - results?: Array; - }>; + find(className: string, params: QueryJSON, options: RequestOptions): Promise<{ + results?: Array; + className?: string; + count?: number; + }>; + aggregate(className: string, params: any, options: RequestOptions): Promise<{ + results?: Array; + }>; }; type EventuallyQueue = { - save: (object: ParseObject, serverOptions: SaveOptions) => Promise; - destroy: (object: ParseObject, serverOptions: RequestOptions) => Promise; - poll: (ms?: number) => void; + save: (object: ParseObject, serverOptions: SaveOptions) => Promise; + destroy: (object: ParseObject, serverOptions: RequestOptions) => Promise; + poll: (ms?: number) => void; }; type RESTController = { - request: (method: string, path: string, data?: any, options?: RequestOptions) => Promise; - ajax: ( - method: string, - url: string, - data: any, - headers?: any, - options?: FullOptions - ) => Promise; - handleError: (err?: any) => void; + request: (method: string, path: string, data?: any, options?: RequestOptions) => Promise; + ajax: (method: string, url: string, data: any, headers?: any, options?: FullOptions) => Promise; + handleError: (err?: any) => void; }; type SchemaController = { - purge: (className: string) => Promise; - get: ( - className: string, - options?: RequestOptions - ) => Promise<{ - results: ParseSchema[]; - }>; - delete: (className: string, options?: RequestOptions) => Promise; - create: (className: string, params: any, options?: RequestOptions) => Promise; - update: (className: string, params: any, options?: RequestOptions) => Promise; - send(className: string, method: string, params: any, options: RequestOptions): Promise; + purge: (className: string) => Promise; + get: (className: string, options?: RequestOptions) => Promise<{ + results: ParseSchema[]; + }>; + delete: (className: string, options?: RequestOptions) => Promise; + create: (className: string, params: any, options?: RequestOptions) => Promise; + update: (className: string, params: any, options?: RequestOptions) => Promise; + send(className: string, method: string, params: any, options: RequestOptions): Promise; }; type SessionController = { - getSession: (token: RequestOptions) => Promise; + getSession: (token: RequestOptions) => Promise; +}; +type StorageController = { + async: 0; + getItem: (path: string) => string | null; + setItem: (path: string, value: string) => void; + removeItem: (path: string) => void; + getItemAsync?: (path: string) => Promise; + setItemAsync?: (path: string, value: string) => Promise; + removeItemAsync?: (path: string) => Promise; + clear: () => void; + getAllKeys?: () => Array; + getAllKeysAsync?: () => Promise>; +} | { + async: 1; + getItem?: (path: string) => string | null; + setItem?: (path: string, value: string) => void; + removeItem?: (path: string) => void; + getItemAsync: (path: string) => Promise; + setItemAsync: (path: string, value: string) => Promise; + removeItemAsync: (path: string) => Promise; + clear: () => void; + getAllKeys?: () => Array; + getAllKeysAsync?: () => Promise>; }; -type StorageController = - | { - async: 0; - getItem: (path: string) => string | null; - setItem: (path: string, value: string) => void; - removeItem: (path: string) => void; - getItemAsync?: (path: string) => Promise; - setItemAsync?: (path: string, value: string) => Promise; - removeItemAsync?: (path: string) => Promise; - clear: () => void; - getAllKeys?: () => Array; - getAllKeysAsync?: () => Promise>; - } - | { - async: 1; - getItem?: (path: string) => string | null; - setItem?: (path: string, value: string) => void; - removeItem?: (path: string) => void; - getItemAsync: (path: string) => Promise; - setItemAsync: (path: string, value: string) => Promise; - removeItemAsync: (path: string) => Promise; - clear: () => void; - getAllKeys?: () => Array; - getAllKeysAsync?: () => Promise>; - }; type LocalDatastoreController = { - fromPinWithName: (name: string) => any | undefined; - pinWithName: (name: string, objects: any) => void; - unPinWithName: (name: string) => void; - getAllContents: () => any | undefined; - clear: () => void; + fromPinWithName: (name: string) => any | undefined; + pinWithName: (name: string, objects: any) => void; + unPinWithName: (name: string) => void; + getAllContents: () => any | undefined; + clear: () => void; }; type UserController = { - setCurrentUser: (user: ParseUser) => Promise; - currentUser: () => ParseUser | null; - currentUserAsync: () => Promise; - signUp: (user: ParseUser, attrs: AttributeMap, options: RequestOptions) => Promise; - logIn: (user: ParseUser, options: RequestOptions) => Promise; - loginAs: (user: ParseUser, userId: string) => Promise; - become: (user: ParseUser, options: RequestOptions) => Promise; - hydrate: (user: ParseUser, userJSON: AttributeMap) => Promise; - logOut: (options: RequestOptions) => Promise; - me: (user: ParseUser, options: RequestOptions) => Promise; - requestPasswordReset: (email: string, options: RequestOptions) => Promise; - updateUserOnDisk: (user: ParseUser) => Promise; - upgradeToRevocableSession: (user: ParseUser, options: RequestOptions) => Promise; - linkWith: (user: ParseUser, authData: AuthData, options?: FullOptions) => Promise; - removeUserFromDisk: () => Promise; - verifyPassword: ( - username: string, - password: string, - options: RequestOptions - ) => Promise; - requestEmailVerification: (email: string, options: RequestOptions) => Promise; + setCurrentUser: (user: ParseUser) => Promise; + currentUser: () => ParseUser | null; + currentUserAsync: () => Promise; + signUp: (user: ParseUser, attrs: AttributeMap, options: RequestOptions) => Promise; + logIn: (user: ParseUser, options: RequestOptions) => Promise; + loginAs: (user: ParseUser, userId: string) => Promise; + become: (user: ParseUser, options: RequestOptions) => Promise; + hydrate: (user: ParseUser, userJSON: AttributeMap) => Promise; + logOut: (options: RequestOptions) => Promise; + me: (user: ParseUser, options: RequestOptions) => Promise; + requestPasswordReset: (email: string, options: RequestOptions) => Promise; + updateUserOnDisk: (user: ParseUser) => Promise; + upgradeToRevocableSession: (user: ParseUser, options: RequestOptions) => Promise; + linkWith: (user: ParseUser, authData: AuthData, options?: FullOptions) => Promise; + removeUserFromDisk: () => Promise; + verifyPassword: (username: string, password: string, options: RequestOptions) => Promise; + requestEmailVerification: (email: string, options: RequestOptions) => Promise; }; type HooksController = { - get: (type: string, functionName?: string, triggerName?: string) => Promise; - create: (hook: HookDeclaration) => Promise; - remove: (hook: HookDeleteArg) => Promise; - update: (hook: HookDeclaration) => Promise; - sendRequest?: (method: string, path: string, body?: any) => Promise; + get: (type: string, functionName?: string, triggerName?: string) => Promise; + create: (hook: HookDeclaration) => Promise; + remove: (hook: HookDeleteArg) => Promise; + update: (hook: HookDeclaration) => Promise; + sendRequest?: (method: string, path: string, body?: any) => Promise; }; type LiveQueryControllerType = { - setDefaultLiveQueryClient(liveQueryClient: LiveQueryClient): void; - getDefaultLiveQueryClient(): Promise; - _clearCachedDefaultClient(): void; + setDefaultLiveQueryClient(liveQueryClient: LiveQueryClient): void; + getDefaultLiveQueryClient(): Promise; + _clearCachedDefaultClient(): void; }; /** Based on https://github.com/react-native-async-storage/async-storage/blob/main/packages/default-storage-backend/src/types.ts */ type AsyncStorageType = { - /** Fetches an item for a `key` and invokes a callback upon completion. */ - getItem: ( - key: string, - callback?: (error?: Error | null, result?: string | null) => void - ) => Promise; - /** Sets the value for a `key` and invokes a callback upon completion. */ - setItem: (key: string, value: string, callback?: (error?: Error | null) => void) => Promise; - /** Removes an item for a `key` and invokes a callback upon completion. */ - removeItem: (key: string, callback?: (error?: Error | null) => void) => Promise; - /** Merges an existing `key` value with an input value, assuming both values are stringified JSON. */ - mergeItem: ( - key: string, - value: string, - callback?: (error?: Error | null) => void - ) => Promise; - /** - * Erases *all* `AsyncStorage` for all clients, libraries, etc. You probably - * don't want to call this; use `removeItem` or `multiRemove` to clear only - * your app's keys. - */ - clear: (callback?: (error?: Error | null) => void) => Promise; - /** Gets *all* keys known to your app; for all callers, libraries, etc. */ - getAllKeys: ( - callback?: (error?: Error | null, result?: readonly string[] | null) => void - ) => Promise; - /** - * This allows you to batch the fetching of items given an array of `key` - * inputs. Your callback will be invoked with an array of corresponding - * key-value pairs found. - */ - multiGet: ( - keys: readonly string[], - callback?: ( - errors?: readonly (Error | null)[] | null, - result?: readonly [string, string][] - ) => void - ) => Promise; - /** - * Use this as a batch operation for storing multiple key-value pairs. When - * the operation completes you'll get a single callback with any errors. - * - * See https://react-native-async-storage.github.io/async-storage/docs/api#multiset - */ - multiSet: ( - keyValuePairs: [string, string][], - callback?: (errors?: readonly (Error | null)[] | null) => void - ) => Promise; - /** - * Call this to batch the deletion of all keys in the `keys` array. - * - * See https://react-native-async-storage.github.io/async-storage/docs/api#multiremove - */ - multiRemove: ( - keys: readonly string[], - callback?: (errors?: readonly (Error | null)[] | null) => void - ) => Promise; - /** - * Batch operation to merge in existing and new values for a given set of - * keys. This assumes that the values are stringified JSON. - * - * See https://react-native-async-storage.github.io/async-storage/docs/api#multimerge - */ - multiMerge: ( - keyValuePairs: [string, string][], - callback?: (errors?: readonly (Error | null)[] | null) => void - ) => Promise; + /** Fetches an item for a `key` and invokes a callback upon completion. */ + getItem: (key: string, callback?: (error?: Error | null, result?: string | null) => void) => Promise; + /** Sets the value for a `key` and invokes a callback upon completion. */ + setItem: (key: string, value: string, callback?: (error?: Error | null) => void) => Promise; + /** Removes an item for a `key` and invokes a callback upon completion. */ + removeItem: (key: string, callback?: (error?: Error | null) => void) => Promise; + /** Merges an existing `key` value with an input value, assuming both values are stringified JSON. */ + mergeItem: (key: string, value: string, callback?: (error?: Error | null) => void) => Promise; + /** + * Erases *all* `AsyncStorage` for all clients, libraries, etc. You probably + * don't want to call this; use `removeItem` or `multiRemove` to clear only + * your app's keys. + */ + clear: (callback?: (error?: Error | null) => void) => Promise; + /** Gets *all* keys known to your app; for all callers, libraries, etc. */ + getAllKeys: (callback?: (error?: Error | null, result?: readonly string[] | null) => void) => Promise; + /** + * This allows you to batch the fetching of items given an array of `key` + * inputs. Your callback will be invoked with an array of corresponding + * key-value pairs found. + */ + multiGet: (keys: readonly string[], callback?: (errors?: readonly (Error | null)[] | null, result?: readonly [string, string][]) => void) => Promise; + /** + * Use this as a batch operation for storing multiple key-value pairs. When + * the operation completes you'll get a single callback with any errors. + * + * See https://react-native-async-storage.github.io/async-storage/docs/api#multiset + */ + multiSet: (keyValuePairs: [string, string][], callback?: (errors?: readonly (Error | null)[] | null) => void) => Promise; + /** + * Call this to batch the deletion of all keys in the `keys` array. + * + * See https://react-native-async-storage.github.io/async-storage/docs/api#multiremove + */ + multiRemove: (keys: readonly string[], callback?: (errors?: readonly (Error | null)[] | null) => void) => Promise; + /** + * Batch operation to merge in existing and new values for a given set of + * keys. This assumes that the values are stringified JSON. + * + * See https://react-native-async-storage.github.io/async-storage/docs/api#multimerge + */ + multiMerge: (keyValuePairs: [string, string][], callback?: (errors?: readonly (Error | null)[] | null) => void) => Promise; }; export type WebSocketController = { - onopen: () => void; - onmessage: (message: any) => void; - onclose: (arg?: any) => void; - onerror: (error: any) => void; - send: (data: any) => void; - close: () => void; + onopen: () => void; + onmessage: (message: any) => void; + onclose: (arg?: any) => void; + onerror: (error: any) => void; + send: (data: any) => void; + close: () => void; }; declare const CoreManager: { - get: (key: string) => any; - set: (key: string, value: any) => void; - setIfNeeded: (key: string, value: any) => any; - setAnalyticsController(controller: AnalyticsController): void; - getAnalyticsController(): AnalyticsController; - setCloudController(controller: CloudController): void; - getCloudController(): CloudController; - setConfigController(controller: ConfigController): void; - getConfigController(): ConfigController; - setCryptoController(controller: CryptoController): void; - getCryptoController(): CryptoController; - setEventEmitter(eventEmitter: any): void; - getEventEmitter(): any; - setFileController(controller: FileController): void; - setEventuallyQueue(controller: EventuallyQueue): void; - getEventuallyQueue(): EventuallyQueue; - getFileController(): FileController; - setInstallationController(controller: InstallationController): void; - getInstallationController(): InstallationController; - setLiveQuery(liveQuery: any): void; - getLiveQuery(): any; - setObjectController(controller: ObjectController): void; - getObjectController(): ObjectController; - setObjectStateController(controller: ObjectStateController): void; - getObjectStateController(): ObjectStateController; - setPushController(controller: PushController): void; - getPushController(): PushController; - setQueryController(controller: QueryController): void; - getQueryController(): QueryController; - setRESTController(controller: RESTController): void; - getRESTController(): RESTController; - setSchemaController(controller: SchemaController): void; - getSchemaController(): SchemaController; - setSessionController(controller: SessionController): void; - getSessionController(): SessionController; - setStorageController(controller: StorageController): void; - setLocalDatastoreController(controller: LocalDatastoreController): void; - getLocalDatastoreController(): LocalDatastoreController; - setLocalDatastore(store: any): void; - getLocalDatastore(): any; - getStorageController(): StorageController; - setAsyncStorage(storage: AsyncStorageType): void; - getAsyncStorage(): AsyncStorageType; - setWebSocketController( - controller: new ( - url: string | URL, - protocols?: string | string[] | undefined - ) => WebSocketController - ): void; - getWebSocketController(): new ( - url: string | URL, - protocols?: string | string[] | undefined - ) => WebSocketController; - setUserController(controller: UserController): void; - getUserController(): UserController; - setLiveQueryController(controller: LiveQueryControllerType): void; - getLiveQueryController(): LiveQueryControllerType; - setHooksController(controller: HooksController): void; - getHooksController(): HooksController; - setParseOp(op: any): void; - getParseOp(): any; - setParseObject(object: any): void; - getParseObject(): any; - setParseQuery(query: any): void; - getParseQuery(): any; - setParseRole(role: any): void; - getParseRole(): any; - setParseUser(user: any): void; - getParseUser(): any; + get: (key: string) => any; + set: (key: string, value: any) => void; + setIfNeeded: (key: string, value: any) => any; + setAnalyticsController(controller: AnalyticsController): void; + getAnalyticsController(): AnalyticsController; + setCloudController(controller: CloudController): void; + getCloudController(): CloudController; + setConfigController(controller: ConfigController): void; + getConfigController(): ConfigController; + setCryptoController(controller: CryptoController): void; + getCryptoController(): CryptoController; + setEventEmitter(eventEmitter: any): void; + getEventEmitter(): any; + setFileController(controller: FileController): void; + setEventuallyQueue(controller: EventuallyQueue): void; + getEventuallyQueue(): EventuallyQueue; + getFileController(): FileController; + setInstallationController(controller: InstallationController): void; + getInstallationController(): InstallationController; + setLiveQuery(liveQuery: any): void; + getLiveQuery(): any; + setObjectController(controller: ObjectController): void; + getObjectController(): ObjectController; + setObjectStateController(controller: ObjectStateController): void; + getObjectStateController(): ObjectStateController; + setPushController(controller: PushController): void; + getPushController(): PushController; + setQueryController(controller: QueryController): void; + getQueryController(): QueryController; + setRESTController(controller: RESTController): void; + getRESTController(): RESTController; + setSchemaController(controller: SchemaController): void; + getSchemaController(): SchemaController; + setSessionController(controller: SessionController): void; + getSessionController(): SessionController; + setStorageController(controller: StorageController): void; + setLocalDatastoreController(controller: LocalDatastoreController): void; + getLocalDatastoreController(): LocalDatastoreController; + setLocalDatastore(store: any): void; + getLocalDatastore(): any; + getStorageController(): StorageController; + setAsyncStorage(storage: AsyncStorageType): void; + getAsyncStorage(): AsyncStorageType; + setWebSocketController(controller: new (url: string | URL, protocols?: string | string[] | undefined) => WebSocketController): void; + getWebSocketController(): new (url: string | URL, protocols?: string | string[] | undefined) => WebSocketController; + setUserController(controller: UserController): void; + getUserController(): UserController; + setLiveQueryController(controller: LiveQueryControllerType): void; + getLiveQueryController(): LiveQueryControllerType; + setHooksController(controller: HooksController): void; + getHooksController(): HooksController; + setParseOp(op: any): void; + getParseOp(): any; + setParseObject(object: any): void; + getParseObject(): any; + setParseQuery(query: any): void; + getParseQuery(): any; + setParseRole(role: any): void; + getParseRole(): any; + setParseUser(user: any): void; + getParseUser(): any; }; export default CoreManager; diff --git a/types/CryptoController.d.ts b/types/CryptoController.d.ts index 362d3eca7..1f6e27162 100644 --- a/types/CryptoController.d.ts +++ b/types/CryptoController.d.ts @@ -1,5 +1,5 @@ declare const CryptoController: { - encrypt(obj: any, secretKey: string): string; - decrypt(encryptedText: string, secretKey: string): string; + encrypt(obj: any, secretKey: string): string; + decrypt(encryptedText: string, secretKey: string): string; }; export default CryptoController; diff --git a/types/EventuallyQueue.d.ts b/types/EventuallyQueue.d.ts index 78d76d077..c5ffbcf49 100644 --- a/types/EventuallyQueue.d.ts +++ b/types/EventuallyQueue.d.ts @@ -2,14 +2,14 @@ import ParseObject from './ParseObject'; import type { SaveOptions } from './ParseObject'; import type { RequestOptions } from './RESTController'; type QueueObject = { - queueId: string; - action: string; - object: ParseObject; - serverOptions: SaveOptions | RequestOptions; - id: string; - className: string; - hash: string; - createdAt: Date; + queueId: string; + action: string; + object: ParseObject; + serverOptions: SaveOptions | RequestOptions; + id: string; + className: string; + hash: string; + createdAt: Date; }; type Queue = Array; /** @@ -20,163 +20,159 @@ type Queue = Array; * @static */ declare const EventuallyQueue: { - /** - * Add object to queue with save operation. - * - * @function save - * @name Parse.EventuallyQueue.save - * @param {ParseObject} object Parse.Object to be saved eventually - * @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#save Parse.Object.save} options. - * @returns {Promise} A promise that is fulfilled if object is added to queue. - * @static - * @see Parse.Object#saveEventually - */ - save(object: ParseObject, serverOptions?: SaveOptions): Promise; - /** - * Add object to queue with save operation. - * - * @function destroy - * @name Parse.EventuallyQueue.destroy - * @param {ParseObject} object Parse.Object to be destroyed eventually - * @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#destroy Parse.Object.destroy} options - * @returns {Promise} A promise that is fulfilled if object is added to queue. - * @static - * @see Parse.Object#destroyEventually - */ - destroy(object: ParseObject, serverOptions?: RequestOptions): Promise; - /** - * Generate unique identifier to avoid duplicates and maintain previous state. - * - * @param {string} action save / destroy - * @param {object} object Parse.Object to be queued - * @returns {string} - * @static - * @ignore - */ - generateQueueId(action: string, object: ParseObject): string; - /** - * Build queue object and add to queue. - * - * @param {string} action save / destroy - * @param {object} object Parse.Object to be queued - * @param {object} [serverOptions] - * @returns {Promise} A promise that is fulfilled if object is added to queue. - * @static - * @ignore - */ - enqueue( - action: string, - object: ParseObject, - serverOptions: SaveOptions | RequestOptions - ): Promise; - store(data: QueueObject[]): Promise; - load(): Promise; - /** - * Sets the in-memory queue from local storage and returns. - * - * @function getQueue - * @name Parse.EventuallyQueue.getQueue - * @returns {Promise} - * @static - */ - getQueue(): Promise; - /** - * Saves the queue to local storage - * - * @param {Queue} queue Queue containing Parse.Object data. - * @returns {Promise} A promise that is fulfilled when queue is stored. - * @static - * @ignore - */ - setQueue(queue: Queue): Promise; - /** - * Removes Parse.Object data from queue. - * - * @param {string} queueId Unique identifier for Parse.Object data. - * @returns {Promise} A promise that is fulfilled when queue is stored. - * @static - * @ignore - */ - remove(queueId: string): Promise; - /** - * Removes all objects from queue. - * - * @function clear - * @name Parse.EventuallyQueue.clear - * @returns {Promise} A promise that is fulfilled when queue is cleared. - * @static - */ - clear(): Promise; - /** - * Return the index of a queueId in the queue. Returns -1 if not found. - * - * @param {Queue} queue Queue containing Parse.Object data. - * @param {string} queueId Unique identifier for Parse.Object data. - * @returns {number} - * @static - * @ignore - */ - queueItemExists(queue: Queue, queueId: string): number; - /** - * Return the number of objects in the queue. - * - * @function length - * @name Parse.EventuallyQueue.length - * @returns {Promise} - * @static - */ - length(): Promise; - /** - * Sends the queue to the server. - * - * @function sendQueue - * @name Parse.EventuallyQueue.sendQueue - * @returns {Promise} Returns true if queue was sent successfully. - * @static - */ - sendQueue(): Promise; - /** - * Build queue object and add to queue. - * - * @param {ParseObject} object Parse.Object to be processed - * @param {QueueObject} queueObject Parse.Object data from the queue - * @returns {Promise} A promise that is fulfilled when operation is performed. - * @static - * @ignore - */ - sendQueueCallback(object: ParseObject, queueObject: QueueObject): Promise; - /** - * Start polling server for network connection. - * Will send queue if connection is established. - * - * @function poll - * @name Parse.EventuallyQueue.poll - * @param [ms] Milliseconds to ping the server. Default 2000ms - * @static - */ - poll(ms?: number): void; - /** - * Turns off polling. - * - * @function stopPoll - * @name Parse.EventuallyQueue.stopPoll - * @static - */ - stopPoll(): void; - /** - * Return true if pinging the server. - * - * @function isPolling - * @name Parse.EventuallyQueue.isPolling - * @returns {boolean} - * @static - */ - isPolling(): boolean; - _setPolling(flag: boolean): void; - process: { - create(ObjectType: any, queueObject: any): Promise; - byId(ObjectType: any, queueObject: any): Promise; - byHash(ObjectType: any, queueObject: any): Promise; - }; + /** + * Add object to queue with save operation. + * + * @function save + * @name Parse.EventuallyQueue.save + * @param {ParseObject} object Parse.Object to be saved eventually + * @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#save Parse.Object.save} options. + * @returns {Promise} A promise that is fulfilled if object is added to queue. + * @static + * @see Parse.Object#saveEventually + */ + save(object: ParseObject, serverOptions?: SaveOptions): Promise; + /** + * Add object to queue with save operation. + * + * @function destroy + * @name Parse.EventuallyQueue.destroy + * @param {ParseObject} object Parse.Object to be destroyed eventually + * @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#destroy Parse.Object.destroy} options + * @returns {Promise} A promise that is fulfilled if object is added to queue. + * @static + * @see Parse.Object#destroyEventually + */ + destroy(object: ParseObject, serverOptions?: RequestOptions): Promise; + /** + * Generate unique identifier to avoid duplicates and maintain previous state. + * + * @param {string} action save / destroy + * @param {object} object Parse.Object to be queued + * @returns {string} + * @static + * @ignore + */ + generateQueueId(action: string, object: ParseObject): string; + /** + * Build queue object and add to queue. + * + * @param {string} action save / destroy + * @param {object} object Parse.Object to be queued + * @param {object} [serverOptions] + * @returns {Promise} A promise that is fulfilled if object is added to queue. + * @static + * @ignore + */ + enqueue(action: string, object: ParseObject, serverOptions: SaveOptions | RequestOptions): Promise; + store(data: QueueObject[]): Promise; + load(): Promise; + /** + * Sets the in-memory queue from local storage and returns. + * + * @function getQueue + * @name Parse.EventuallyQueue.getQueue + * @returns {Promise} + * @static + */ + getQueue(): Promise; + /** + * Saves the queue to local storage + * + * @param {Queue} queue Queue containing Parse.Object data. + * @returns {Promise} A promise that is fulfilled when queue is stored. + * @static + * @ignore + */ + setQueue(queue: Queue): Promise; + /** + * Removes Parse.Object data from queue. + * + * @param {string} queueId Unique identifier for Parse.Object data. + * @returns {Promise} A promise that is fulfilled when queue is stored. + * @static + * @ignore + */ + remove(queueId: string): Promise; + /** + * Removes all objects from queue. + * + * @function clear + * @name Parse.EventuallyQueue.clear + * @returns {Promise} A promise that is fulfilled when queue is cleared. + * @static + */ + clear(): Promise; + /** + * Return the index of a queueId in the queue. Returns -1 if not found. + * + * @param {Queue} queue Queue containing Parse.Object data. + * @param {string} queueId Unique identifier for Parse.Object data. + * @returns {number} + * @static + * @ignore + */ + queueItemExists(queue: Queue, queueId: string): number; + /** + * Return the number of objects in the queue. + * + * @function length + * @name Parse.EventuallyQueue.length + * @returns {Promise} + * @static + */ + length(): Promise; + /** + * Sends the queue to the server. + * + * @function sendQueue + * @name Parse.EventuallyQueue.sendQueue + * @returns {Promise} Returns true if queue was sent successfully. + * @static + */ + sendQueue(): Promise; + /** + * Build queue object and add to queue. + * + * @param {ParseObject} object Parse.Object to be processed + * @param {QueueObject} queueObject Parse.Object data from the queue + * @returns {Promise} A promise that is fulfilled when operation is performed. + * @static + * @ignore + */ + sendQueueCallback(object: ParseObject, queueObject: QueueObject): Promise; + /** + * Start polling server for network connection. + * Will send queue if connection is established. + * + * @function poll + * @name Parse.EventuallyQueue.poll + * @param [ms] Milliseconds to ping the server. Default 2000ms + * @static + */ + poll(ms?: number): void; + /** + * Turns off polling. + * + * @function stopPoll + * @name Parse.EventuallyQueue.stopPoll + * @static + */ + stopPoll(): void; + /** + * Return true if pinging the server. + * + * @function isPolling + * @name Parse.EventuallyQueue.isPolling + * @returns {boolean} + * @static + */ + isPolling(): boolean; + _setPolling(flag: boolean): void; + process: { + create(ObjectType: any, queueObject: any): Promise; + byId(ObjectType: any, queueObject: any): Promise; + byHash(ObjectType: any, queueObject: any): Promise; + }; }; export default EventuallyQueue; diff --git a/types/FacebookUtils.d.ts b/types/FacebookUtils.d.ts index 3cfebcaff..f4cd41a2d 100644 --- a/types/FacebookUtils.d.ts +++ b/types/FacebookUtils.d.ts @@ -8,100 +8,100 @@ import type { AuthProviderType } from './ParseUser'; * @hideconstructor */ declare const FacebookUtils: { - /** - * Initializes Parse Facebook integration. Call this function after you - * have loaded the Facebook Javascript SDK with the same parameters - * as you would pass to - * - * FB.init(). Parse.FacebookUtils will invoke FB.init() for you - * with these arguments. - * - * @function init - * @name Parse.FacebookUtils.init - * @param {object} options Facebook options argument as described here: - * - * FB.init(). The status flag will be coerced to 'false' because it - * interferes with Parse Facebook integration. Call FB.getLoginStatus() - * explicitly if this behavior is required by your application. - */ - init(options: any): void; - /** - * Gets whether the user has their account linked to Facebook. - * - * @function isLinked - * @name Parse.FacebookUtils.isLinked - * @param {Parse.User} user User to check for a facebook link. - * The user must be logged in on this device. - * @returns {boolean} true if the user has their account - * linked to Facebook. - */ - isLinked(user: any): any; - /** - * Logs in a user using Facebook. This method delegates to the Facebook - * SDK to authenticate the user, and then automatically logs in (or - * creates, in the case where it is a new user) a Parse.User. - * - * Standard API: - * - * logIn(permission: string, authData: Object); - * - * Advanced API: Used for handling your own oAuth tokens - * {@link https://docs.parseplatform.org/rest/guide/#linking-users} - * - * logIn(authData: Object, options?: Object); - * - * @function logIn - * @name Parse.FacebookUtils.logIn - * @param {(string | object)} permissions The permissions required for Facebook - * log in. This is a comma-separated string of permissions. - * Alternatively, supply a Facebook authData object as described in our - * REST API docs if you want to handle getting facebook auth tokens - * yourself. - * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string - * @returns {Promise} - */ - logIn(permissions: any, options: any): Promise; - /** - * Links Facebook to an existing PFUser. This method delegates to the - * Facebook SDK to authenticate the user, and then automatically links - * the account to the Parse.User. - * - * Standard API: - * - * link(user: Parse.User, permission: string, authData?: Object); - * - * Advanced API: Used for handling your own oAuth tokens - * {@link https://docs.parseplatform.org/rest/guide/#linking-users} - * - * link(user: Parse.User, authData: Object, options?: FullOptions); - * - * @function link - * @name Parse.FacebookUtils.link - * @param {Parse.User} user User to link to Facebook. This must be the - * current user. - * @param {(string | object)} permissions The permissions required for Facebook - * log in. This is a comma-separated string of permissions. - * Alternatively, supply a Facebook authData object as described in our - * REST API docs if you want to handle getting facebook auth tokens - * yourself. - * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string - * @returns {Promise} - */ - link(user: any, permissions: any, options: any): any; - /** - * Unlinks the Parse.User from a Facebook account. - * - * @function unlink - * @name Parse.FacebookUtils.unlink - * @param {Parse.User} user User to unlink from Facebook. This must be the - * current user. - * @param {object} options Standard options object with success and error - * callbacks. - * @returns {Promise} - */ - unlink: (user: any, options: any) => any; - _getAuthProvider(): AuthProviderType; + /** + * Initializes Parse Facebook integration. Call this function after you + * have loaded the Facebook Javascript SDK with the same parameters + * as you would pass to + * + * FB.init(). Parse.FacebookUtils will invoke FB.init() for you + * with these arguments. + * + * @function init + * @name Parse.FacebookUtils.init + * @param {object} options Facebook options argument as described here: + * + * FB.init(). The status flag will be coerced to 'false' because it + * interferes with Parse Facebook integration. Call FB.getLoginStatus() + * explicitly if this behavior is required by your application. + */ + init(options: any): void; + /** + * Gets whether the user has their account linked to Facebook. + * + * @function isLinked + * @name Parse.FacebookUtils.isLinked + * @param {Parse.User} user User to check for a facebook link. + * The user must be logged in on this device. + * @returns {boolean} true if the user has their account + * linked to Facebook. + */ + isLinked(user: any): any; + /** + * Logs in a user using Facebook. This method delegates to the Facebook + * SDK to authenticate the user, and then automatically logs in (or + * creates, in the case where it is a new user) a Parse.User. + * + * Standard API: + * + * logIn(permission: string, authData: Object); + * + * Advanced API: Used for handling your own oAuth tokens + * {@link https://docs.parseplatform.org/rest/guide/#linking-users} + * + * logIn(authData: Object, options?: Object); + * + * @function logIn + * @name Parse.FacebookUtils.logIn + * @param {(string | object)} permissions The permissions required for Facebook + * log in. This is a comma-separated string of permissions. + * Alternatively, supply a Facebook authData object as described in our + * REST API docs if you want to handle getting facebook auth tokens + * yourself. + * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string + * @returns {Promise} + */ + logIn(permissions: any, options: any): Promise; + /** + * Links Facebook to an existing PFUser. This method delegates to the + * Facebook SDK to authenticate the user, and then automatically links + * the account to the Parse.User. + * + * Standard API: + * + * link(user: Parse.User, permission: string, authData?: Object); + * + * Advanced API: Used for handling your own oAuth tokens + * {@link https://docs.parseplatform.org/rest/guide/#linking-users} + * + * link(user: Parse.User, authData: Object, options?: FullOptions); + * + * @function link + * @name Parse.FacebookUtils.link + * @param {Parse.User} user User to link to Facebook. This must be the + * current user. + * @param {(string | object)} permissions The permissions required for Facebook + * log in. This is a comma-separated string of permissions. + * Alternatively, supply a Facebook authData object as described in our + * REST API docs if you want to handle getting facebook auth tokens + * yourself. + * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string + * @returns {Promise} + */ + link(user: any, permissions: any, options: any): any; + /** + * Unlinks the Parse.User from a Facebook account. + * + * @function unlink + * @name Parse.FacebookUtils.unlink + * @param {Parse.User} user User to unlink from Facebook. This must be the + * current user. + * @param {object} options Standard options object with success and error + * callbacks. + * @returns {Promise} + */ + unlink: (user: any, options: any) => any; + _getAuthProvider(): AuthProviderType; }; export default FacebookUtils; diff --git a/types/InstallationController.d.ts b/types/InstallationController.d.ts index 9797e9d93..1409c39db 100644 --- a/types/InstallationController.d.ts +++ b/types/InstallationController.d.ts @@ -1,10 +1,10 @@ import ParseInstallation from './ParseInstallation'; declare const InstallationController: { - updateInstallationOnDisk(installation: ParseInstallation): Promise; - currentInstallationId(): Promise; - currentInstallation(): Promise; - _clearCache(): void; - _setInstallationIdCache(iid: string): void; - _setCurrentInstallationCache(installation: ParseInstallation, matchesDisk?: boolean): void; + updateInstallationOnDisk(installation: ParseInstallation): Promise; + currentInstallationId(): Promise; + currentInstallation(): Promise; + _clearCache(): void; + _setInstallationIdCache(iid: string): void; + _setCurrentInstallationCache(installation: ParseInstallation, matchesDisk?: boolean): void; }; export default InstallationController; diff --git a/types/LiveQueryClient.d.ts b/types/LiveQueryClient.d.ts index 49fbe38c5..4f41545dc 100644 --- a/types/LiveQueryClient.d.ts +++ b/types/LiveQueryClient.d.ts @@ -44,92 +44,85 @@ import type ParseQuery from './ParseQuery'; * @alias Parse.LiveQueryClient */ declare class LiveQueryClient { - attempts: number; - id: number; - requestId: number; - applicationId: string; - serverURL: string; - javascriptKey?: string; - masterKey?: string; - sessionToken?: string; - installationId?: string; - additionalProperties: boolean; - connectPromise: any; - subscriptions: Map; - socket: WebSocketController & { - closingPromise?: any; - }; - state: string; - reconnectHandle: any; - emitter: any; - on: any; - emit: any; - /** - * @param {object} options - * @param {string} options.applicationId - applicationId of your Parse app - * @param {string} options.serverURL - the URL of your LiveQuery server - * @param {string} options.javascriptKey (optional) - * @param {string} options.masterKey (optional) Your Parse Master Key. (Node.js only!) - * @param {string} options.sessionToken (optional) - * @param {string} options.installationId (optional) - */ - constructor({ - applicationId, - serverURL, - javascriptKey, - masterKey, - sessionToken, - installationId, - }: { - applicationId: any; - serverURL: any; - javascriptKey: any; - masterKey: any; - sessionToken: any; - installationId: any; - }); - shouldOpen(): any; - /** - * Subscribes to a ParseQuery - * - * If you provide the sessionToken, when the LiveQuery server gets ParseObject's - * updates from parse server, it'll try to check whether the sessionToken fulfills - * the ParseObject's ACL. The LiveQuery server will only send updates to clients whose - * sessionToken is fit for the ParseObject's ACL. You can check the LiveQuery protocol - * here for more details. The subscription you get is the same subscription you get - * from our Standard API. - * - * @param {ParseQuery} query - the ParseQuery you want to subscribe to - * @param {string} sessionToken (optional) - * @returns {LiveQuerySubscription | undefined} - */ - subscribe(query: ParseQuery, sessionToken?: string): LiveQuerySubscription | undefined; - /** - * After calling unsubscribe you'll stop receiving events from the subscription object. - * - * @param {object} subscription - subscription you would like to unsubscribe from. - * @returns {Promise | undefined} - */ - unsubscribe(subscription: LiveQuerySubscription): Promise; - /** - * After open is called, the LiveQueryClient will try to send a connect request - * to the LiveQuery server. - * - */ - open(): void; - resubscribe(): void; - /** - * This method will close the WebSocket connection to this LiveQueryClient, - * cancel the auto reconnect and unsubscribe all subscriptions based on it. - * - * @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event} - */ - close(): Promise; - _handleReset(): void; - _handleWebSocketOpen(): void; - _handleWebSocketMessage(event: any): void; - _handleWebSocketClose(): void; - _handleWebSocketError(error: any): void; - _handleReconnect(): void; + attempts: number; + id: number; + requestId: number; + applicationId: string; + serverURL: string; + javascriptKey?: string; + masterKey?: string; + sessionToken?: string; + installationId?: string; + additionalProperties: boolean; + connectPromise: any; + subscriptions: Map; + socket: WebSocketController & { + closingPromise?: any; + }; + state: string; + reconnectHandle: any; + emitter: any; + on: any; + emit: any; + /** + * @param {object} options + * @param {string} options.applicationId - applicationId of your Parse app + * @param {string} options.serverURL - the URL of your LiveQuery server + * @param {string} options.javascriptKey (optional) + * @param {string} options.masterKey (optional) Your Parse Master Key. (Node.js only!) + * @param {string} options.sessionToken (optional) + * @param {string} options.installationId (optional) + */ + constructor({ applicationId, serverURL, javascriptKey, masterKey, sessionToken, installationId, }: { + applicationId: any; + serverURL: any; + javascriptKey: any; + masterKey: any; + sessionToken: any; + installationId: any; + }); + shouldOpen(): any; + /** + * Subscribes to a ParseQuery + * + * If you provide the sessionToken, when the LiveQuery server gets ParseObject's + * updates from parse server, it'll try to check whether the sessionToken fulfills + * the ParseObject's ACL. The LiveQuery server will only send updates to clients whose + * sessionToken is fit for the ParseObject's ACL. You can check the LiveQuery protocol + * here for more details. The subscription you get is the same subscription you get + * from our Standard API. + * + * @param {ParseQuery} query - the ParseQuery you want to subscribe to + * @param {string} sessionToken (optional) + * @returns {LiveQuerySubscription | undefined} + */ + subscribe(query: ParseQuery, sessionToken?: string): LiveQuerySubscription | undefined; + /** + * After calling unsubscribe you'll stop receiving events from the subscription object. + * + * @param {object} subscription - subscription you would like to unsubscribe from. + * @returns {Promise | undefined} + */ + unsubscribe(subscription: LiveQuerySubscription): Promise; + /** + * After open is called, the LiveQueryClient will try to send a connect request + * to the LiveQuery server. + * + */ + open(): void; + resubscribe(): void; + /** + * This method will close the WebSocket connection to this LiveQueryClient, + * cancel the auto reconnect and unsubscribe all subscriptions based on it. + * + * @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event} + */ + close(): Promise; + _handleReset(): void; + _handleWebSocketOpen(): void; + _handleWebSocketMessage(event: any): void; + _handleWebSocketClose(): void; + _handleWebSocketError(error: any): void; + _handleReconnect(): void; } export default LiveQueryClient; diff --git a/types/LiveQuerySubscription.d.ts b/types/LiveQuerySubscription.d.ts index e312d2a86..1eb9293cf 100644 --- a/types/LiveQuerySubscription.d.ts +++ b/types/LiveQuerySubscription.d.ts @@ -82,21 +82,21 @@ import type ParseQuery from './ParseQuery'; * });

*/ declare class Subscription { - id: string | number; - query: ParseQuery; - sessionToken?: string; - subscribePromise: any; - unsubscribePromise: any; - subscribed: boolean; - emitter: any; - on: any; - emit: any; - constructor(id: string | number, query: ParseQuery, sessionToken?: string); - /** - * Close the subscription - * - * @returns {Promise} - */ - unsubscribe(): Promise; + id: string | number; + query: ParseQuery; + sessionToken?: string; + subscribePromise: any; + unsubscribePromise: any; + subscribed: boolean; + emitter: any; + on: any; + emit: any; + constructor(id: string | number, query: ParseQuery, sessionToken?: string); + /** + * Close the subscription + * + * @returns {Promise} + */ + unsubscribe(): Promise; } export default Subscription; diff --git a/types/LocalDatastore.d.ts b/types/LocalDatastore.d.ts index 4559910a9..d6f795de0 100644 --- a/types/LocalDatastore.d.ts +++ b/types/LocalDatastore.d.ts @@ -20,37 +20,37 @@ import type ParseObject from './ParseObject'; * @static */ declare const LocalDatastore: { - isEnabled: boolean; - isSyncing: boolean; - fromPinWithName(name: string): Promise>; - pinWithName(name: string, value: any): Promise; - unPinWithName(name: string): Promise; - _getAllContents(): Promise; - _getRawStorage(): Promise; - _clear(): Promise; - _handlePinAllWithName(name: string, objects: Array): Promise; - _handleUnPinAllWithName(name: string, objects: Array): Promise; - _getChildren(object: ParseObject): any; - _traverse(object: any, encountered: any): void; - _serializeObjectsFromPinName(name: string): Promise; - _serializeObject(objectKey: string, localDatastore: any): Promise; - _updateObjectIfPinned(object: ParseObject): Promise; - _destroyObjectIfPinned(object: ParseObject): Promise; - _updateLocalIdForObject(localId: string, object: ParseObject): Promise; - /** - * Updates Local Datastore from Server - * - *
-   * await Parse.LocalDatastore.updateFromServer();
-   * 
- * - * @function updateFromServer - * @name Parse.LocalDatastore.updateFromServer - * @static - */ - updateFromServer(): Promise; - getKeyForObject(object: any): string; - getPinName(pinName?: string): string; - checkIfEnabled(): any; + isEnabled: boolean; + isSyncing: boolean; + fromPinWithName(name: string): Promise>; + pinWithName(name: string, value: any): Promise; + unPinWithName(name: string): Promise; + _getAllContents(): Promise; + _getRawStorage(): Promise; + _clear(): Promise; + _handlePinAllWithName(name: string, objects: Array): Promise; + _handleUnPinAllWithName(name: string, objects: Array): Promise; + _getChildren(object: ParseObject): any; + _traverse(object: any, encountered: any): void; + _serializeObjectsFromPinName(name: string): Promise; + _serializeObject(objectKey: string, localDatastore: any): Promise; + _updateObjectIfPinned(object: ParseObject): Promise; + _destroyObjectIfPinned(object: ParseObject): Promise; + _updateLocalIdForObject(localId: string, object: ParseObject): Promise; + /** + * Updates Local Datastore from Server + * + *
+     * await Parse.LocalDatastore.updateFromServer();
+     * 
+ * + * @function updateFromServer + * @name Parse.LocalDatastore.updateFromServer + * @static + */ + updateFromServer(): Promise; + getKeyForObject(object: any): string; + getPinName(pinName?: string): string; + checkIfEnabled(): any; }; export default LocalDatastore; diff --git a/types/LocalDatastoreController.default.d.ts b/types/LocalDatastoreController.default.d.ts index 3737f59a7..14416a1b7 100644 --- a/types/LocalDatastoreController.default.d.ts +++ b/types/LocalDatastoreController.default.d.ts @@ -1,9 +1,9 @@ declare const LocalDatastoreController: { - fromPinWithName(name: string): Promise>; - pinWithName(name: string, value: any): Promise; - unPinWithName(name: string): Promise; - getAllContents(): Promise; - getRawStorage(): Promise; - clear(): Promise; + fromPinWithName(name: string): Promise>; + pinWithName(name: string, value: any): Promise; + unPinWithName(name: string): Promise; + getAllContents(): Promise; + getRawStorage(): Promise; + clear(): Promise; }; export default LocalDatastoreController; diff --git a/types/LocalDatastoreController.react-native.d.ts b/types/LocalDatastoreController.react-native.d.ts index 96b58dfd5..2db09d794 100644 --- a/types/LocalDatastoreController.react-native.d.ts +++ b/types/LocalDatastoreController.react-native.d.ts @@ -1,9 +1,9 @@ declare const LocalDatastoreController: { - fromPinWithName(name: string): Promise>; - pinWithName(name: string, value: any): Promise; - unPinWithName(name: string): Promise; - getAllContents(): Promise; - getRawStorage(): Promise; - clear(): Promise; + fromPinWithName(name: string): Promise>; + pinWithName(name: string, value: any): Promise; + unPinWithName(name: string): Promise; + getAllContents(): Promise; + getRawStorage(): Promise; + clear(): Promise; }; export default LocalDatastoreController; diff --git a/types/LocalDatastoreUtils.d.ts b/types/LocalDatastoreUtils.d.ts index db607c44e..7472e6570 100644 --- a/types/LocalDatastoreUtils.d.ts +++ b/types/LocalDatastoreUtils.d.ts @@ -1,5 +1,5 @@ -declare const DEFAULT_PIN = '_default'; -declare const PIN_PREFIX = 'parsePin_'; -declare const OBJECT_PREFIX = 'Parse_LDS_'; +declare const DEFAULT_PIN = "_default"; +declare const PIN_PREFIX = "parsePin_"; +declare const OBJECT_PREFIX = "Parse_LDS_"; declare function isLocalDatastoreKey(key: string): boolean; export { DEFAULT_PIN, PIN_PREFIX, OBJECT_PREFIX, isLocalDatastoreKey }; diff --git a/types/ObjectStateMutations.d.ts b/types/ObjectStateMutations.d.ts index 75d1793eb..7a2086d80 100644 --- a/types/ObjectStateMutations.d.ts +++ b/types/ObjectStateMutations.d.ts @@ -2,20 +2,20 @@ import TaskQueue from './TaskQueue'; import type { Op } from './ParseOp'; import type ParseObject from './ParseObject'; export type AttributeMap = { - [attr: string]: any; + [attr: string]: any; }; export type OpsMap = { - [attr: string]: Op; + [attr: string]: Op; }; export type ObjectCache = { - [attr: string]: string; + [attr: string]: string; }; export type State = { - serverData: AttributeMap; - pendingOps: Array; - objectCache: ObjectCache; - tasks: TaskQueue; - existed: boolean; + serverData: AttributeMap; + pendingOps: Array; + objectCache: ObjectCache; + tasks: TaskQueue; + existed: boolean; }; export declare function defaultState(): State; export declare function setServerData(serverData: AttributeMap, attributes: AttributeMap): void; @@ -23,19 +23,6 @@ export declare function setPendingOp(pendingOps: Array, attr: string, op export declare function pushPendingState(pendingOps: Array): void; export declare function popPendingState(pendingOps: Array): OpsMap; export declare function mergeFirstPendingState(pendingOps: Array): void; -export declare function estimateAttribute( - serverData: AttributeMap, - pendingOps: Array, - object: ParseObject, - attr: string -): any; -export declare function estimateAttributes( - serverData: AttributeMap, - pendingOps: Array, - object: ParseObject -): AttributeMap; -export declare function commitServerChanges( - serverData: AttributeMap, - objectCache: ObjectCache, - changes: AttributeMap -): void; +export declare function estimateAttribute(serverData: AttributeMap, pendingOps: Array, object: ParseObject, attr: string): any; +export declare function estimateAttributes(serverData: AttributeMap, pendingOps: Array, object: ParseObject): AttributeMap; +export declare function commitServerChanges(serverData: AttributeMap, objectCache: ObjectCache, changes: AttributeMap): void; diff --git a/types/OfflineQuery.d.ts b/types/OfflineQuery.d.ts index 1361e7efc..9cca71c1b 100644 --- a/types/OfflineQuery.d.ts +++ b/types/OfflineQuery.d.ts @@ -14,7 +14,7 @@ declare function matchesQuery(className: any, object: any, objects: any, query: any): boolean; declare function validateQuery(query: any): void; declare const OfflineQuery: { - matchesQuery: typeof matchesQuery; - validateQuery: typeof validateQuery; + matchesQuery: typeof matchesQuery; + validateQuery: typeof validateQuery; }; export default OfflineQuery; diff --git a/types/Parse.d.ts b/types/Parse.d.ts index 4500ea0ab..893fe34da 100644 --- a/types/Parse.d.ts +++ b/types/Parse.d.ts @@ -22,434 +22,254 @@ import User from './ParseUser'; import ParseLiveQuery from './ParseLiveQuery'; import LiveQueryClient from './LiveQueryClient'; declare const Parse: { - ACL: typeof ACL; - Analytics: typeof Analytics; - AnonymousUtils: { - isLinked(user: User): boolean; - logIn(options?: import('./RESTController').RequestOptions): Promise; - link(user: User, options?: import('./RESTController').RequestOptions): Promise; - isRegistered(): boolean; - _getAuthProvider(): { - restoreAuthentication(): boolean; - getAuthType(): string; - getAuthData(): { - authData: { - id: string; + ACL: typeof ACL; + Analytics: typeof Analytics; + AnonymousUtils: { + isLinked(user: User): boolean; + logIn(options?: import("./RESTController").RequestOptions): Promise; + link(user: User, options?: import("./RESTController").RequestOptions): Promise; + isRegistered(): boolean; + _getAuthProvider(): { + restoreAuthentication(): boolean; + getAuthType(): string; + getAuthData(): { + authData: { + id: string; + }; + }; }; - }; }; - }; - Cloud: typeof Cloud; - CLP: typeof CLP; - CoreManager: { - get: (key: string) => any; - set: (key: string, value: any) => void; - setIfNeeded: (key: string, value: any) => any; - setAnalyticsController(controller: { - track: ( - name: string, - dimensions: { - [key: string]: string; - } - ) => Promise; - }): void; - getAnalyticsController(): { - track: ( - name: string, - dimensions: { - [key: string]: string; - } - ) => Promise; - }; - setCloudController(controller: { - run: ( - name: string, - data: any, - options: import('./RESTController').RequestOptions - ) => Promise; - getJobsData: (options: import('./RESTController').RequestOptions) => Promise; - startJob: ( - name: string, - data: any, - options: import('./RESTController').RequestOptions - ) => Promise; - }): void; - getCloudController(): { - run: ( - name: string, - data: any, - options: import('./RESTController').RequestOptions - ) => Promise; - getJobsData: (options: import('./RESTController').RequestOptions) => Promise; - startJob: ( - name: string, - data: any, - options: import('./RESTController').RequestOptions - ) => Promise; - }; - setConfigController(controller: { - current: () => Promise | Config; - get: (opts?: import('./RESTController').RequestOptions) => Promise; - save: ( - attrs: { - [key: string]: any; - }, - masterKeyOnlyFlags?: { - [key: string]: any; - } - ) => Promise; - }): void; - getConfigController(): { - current: () => Promise | Config; - get: (opts?: import('./RESTController').RequestOptions) => Promise; - save: ( - attrs: { - [key: string]: any; - }, - masterKeyOnlyFlags?: { - [key: string]: any; - } - ) => Promise; - }; - setCryptoController(controller: { - encrypt: (obj: any, secretKey: string) => string; - decrypt: (encryptedText: string, secretKey: any) => string; - }): void; - getCryptoController(): { - encrypt: (obj: any, secretKey: string) => string; - decrypt: (encryptedText: string, secretKey: any) => string; - }; - setEventEmitter(eventEmitter: any): void; - getEventEmitter(): any; - setFileController(controller: { - saveFile: ( - name: string, - source: import('./ParseFile').FileSource, - options?: import('./RESTController').FullOptions - ) => Promise; - saveBase64: ( - name: string, - source: import('./ParseFile').FileSource, - options?: import('./ParseFile').FileSaveOptions - ) => Promise<{ - name: string; - url: string; - }>; - download: ( - uri: string, - options?: any - ) => Promise<{ - base64?: string; - contentType?: string; - }>; - deleteFile: ( - name: string, - options?: { - useMasterKey?: boolean; - } - ) => Promise; - }): void; - setEventuallyQueue(controller: { - save: ( - object: ParseObject, - serverOptions: import('./ParseObject').SaveOptions - ) => Promise; - destroy: ( - object: ParseObject, - serverOptions: import('./RESTController').RequestOptions - ) => Promise; - poll: (ms?: number) => void; - }): void; - getEventuallyQueue(): { - save: ( - object: ParseObject, - serverOptions: import('./ParseObject').SaveOptions - ) => Promise; - destroy: ( - object: ParseObject, - serverOptions: import('./RESTController').RequestOptions - ) => Promise; - poll: (ms?: number) => void; - }; - getFileController(): { - saveFile: ( - name: string, - source: import('./ParseFile').FileSource, - options?: import('./RESTController').FullOptions - ) => Promise; - saveBase64: ( - name: string, - source: import('./ParseFile').FileSource, - options?: import('./ParseFile').FileSaveOptions - ) => Promise<{ - name: string; - url: string; - }>; - download: ( - uri: string, - options?: any - ) => Promise<{ - base64?: string; - contentType?: string; - }>; - deleteFile: ( - name: string, - options?: { - useMasterKey?: boolean; - } - ) => Promise; - }; - setInstallationController(controller: { - currentInstallationId: () => Promise; - currentInstallation: () => Promise; - updateInstallationOnDisk: (installation: Installation) => Promise; - }): void; - getInstallationController(): { - currentInstallationId: () => Promise; - currentInstallation: () => Promise; - updateInstallationOnDisk: (installation: Installation) => Promise; - }; - setLiveQuery(liveQuery: any): void; - getLiveQuery(): any; - setObjectController(controller: { - fetch: ( - object: ParseObject | Array, - forceFetch: boolean, - options: import('./RESTController').RequestOptions - ) => Promise | ParseObject | undefined>; - save: ( - object: ParseObject | Array | null, - options: import('./RESTController').RequestOptions - ) => Promise | File | undefined>; - destroy: ( - object: ParseObject | Array, - options: import('./RESTController').RequestOptions - ) => Promise>; - }): void; - getObjectController(): { - fetch: ( - object: ParseObject | Array, - forceFetch: boolean, - options: import('./RESTController').RequestOptions - ) => Promise | ParseObject | undefined>; - save: ( - object: ParseObject | Array | null, - options: import('./RESTController').RequestOptions - ) => Promise | File | undefined>; - destroy: ( - object: ParseObject | Array, - options: import('./RESTController').RequestOptions - ) => Promise>; - }; - setObjectStateController(controller: { - getState: (obj: any) => import('./ObjectStateMutations').State | null; - initializeState: ( - obj: any, - initial?: import('./ObjectStateMutations').State - ) => import('./ObjectStateMutations').State; - removeState: (obj: any) => import('./ObjectStateMutations').State | null; - getServerData: (obj: any) => import('./ObjectStateMutations').AttributeMap; - setServerData: (obj: any, attributes: import('./ObjectStateMutations').AttributeMap) => void; - getPendingOps: (obj: any) => Array; - setPendingOp: (obj: any, attr: string, op?: ParseOp.Op) => void; - pushPendingState: (obj: any) => void; - popPendingState: (obj: any) => import('./ObjectStateMutations').OpsMap | undefined; - mergeFirstPendingState: (obj: any) => void; - getObjectCache: (obj: any) => import('./ObjectStateMutations').ObjectCache; - estimateAttribute: (obj: any, attr: string) => any; - estimateAttributes: (obj: any) => import('./ObjectStateMutations').AttributeMap; - commitServerChanges: ( - obj: any, - changes: import('./ObjectStateMutations').AttributeMap - ) => void; - enqueueTask: (obj: any, task: () => Promise) => Promise; - clearAllState: () => void; - duplicateState: (source: any, dest: any) => void; - }): void; - getObjectStateController(): { - getState: (obj: any) => import('./ObjectStateMutations').State | null; - initializeState: ( - obj: any, - initial?: import('./ObjectStateMutations').State - ) => import('./ObjectStateMutations').State; - removeState: (obj: any) => import('./ObjectStateMutations').State | null; - getServerData: (obj: any) => import('./ObjectStateMutations').AttributeMap; - setServerData: (obj: any, attributes: import('./ObjectStateMutations').AttributeMap) => void; - getPendingOps: (obj: any) => Array; - setPendingOp: (obj: any, attr: string, op?: ParseOp.Op) => void; - pushPendingState: (obj: any) => void; - popPendingState: (obj: any) => import('./ObjectStateMutations').OpsMap | undefined; - mergeFirstPendingState: (obj: any) => void; - getObjectCache: (obj: any) => import('./ObjectStateMutations').ObjectCache; - estimateAttribute: (obj: any, attr: string) => any; - estimateAttributes: (obj: any) => import('./ObjectStateMutations').AttributeMap; - commitServerChanges: ( - obj: any, - changes: import('./ObjectStateMutations').AttributeMap - ) => void; - enqueueTask: (obj: any, task: () => Promise) => Promise; - clearAllState: () => void; - duplicateState: (source: any, dest: any) => void; - }; - setPushController(controller: { - send: (data: Push.PushData, options?: import('./RESTController').FullOptions) => Promise; - }): void; - getPushController(): { - send: (data: Push.PushData, options?: import('./RESTController').FullOptions) => Promise; - }; - setQueryController(controller: { - find( - className: string, - params: import('./ParseQuery').QueryJSON, - options: import('./RESTController').RequestOptions - ): Promise<{ - results?: Array; - className?: string; - count?: number; - }>; - aggregate( - className: string, - params: any, - options: import('./RESTController').RequestOptions - ): Promise<{ - results?: Array; - }>; - }): void; - getQueryController(): { - find( - className: string, - params: import('./ParseQuery').QueryJSON, - options: import('./RESTController').RequestOptions - ): Promise<{ - results?: Array; - className?: string; - count?: number; - }>; - aggregate( - className: string, - params: any, - options: import('./RESTController').RequestOptions - ): Promise<{ - results?: Array; - }>; - }; - setRESTController(controller: { - request: ( - method: string, - path: string, - data?: any, - options?: import('./RESTController').RequestOptions - ) => Promise; - ajax: ( - method: string, - url: string, - data: any, - headers?: any, - options?: import('./RESTController').FullOptions - ) => Promise; - handleError: ( - err? /** - * Call this method to set your LocalDatastoreStorage engine - * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()} - * - * @param {LocalDatastoreController} controller a data storage. - * @static - */ - : any - ) => void; - }): void; - getRESTController(): { - request: ( - method: string, - path: string, - data?: any, - options?: import('./RESTController').RequestOptions - ) => Promise; - ajax: ( - method: string, - url: string, - data: any, - headers?: any, - options?: import('./RESTController').FullOptions - ) => Promise; - handleError: ( - err? /** - * Call this method to set your LocalDatastoreStorage engine - * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()} - * - * @param {LocalDatastoreController} controller a data storage. - * @static - */ - : any - ) => void; - }; - setSchemaController(controller: { - purge: (className: string) => Promise; - get: ( - className: string, - options?: import('./RESTController').RequestOptions - ) => Promise<{ - results: Schema[]; - }>; - delete: ( - className: string, - options?: import('./RESTController').RequestOptions - ) => Promise; - create: ( - className: string, - params: any, - options?: import('./RESTController').RequestOptions - ) => Promise; - update: ( - className: string, - params: any, - options?: import('./RESTController').RequestOptions - ) => Promise; - send( - className: string, - method: string, - params: any, - options: import('./RESTController').RequestOptions - ): Promise; - }): void; - getSchemaController(): { - purge: (className: string) => Promise; - get: ( - className: string, - options?: import('./RESTController').RequestOptions - ) => Promise<{ - results: Schema[]; - }>; - delete: ( - className: string, - options?: import('./RESTController').RequestOptions - ) => Promise; - create: ( - className: string, - params: any, - options?: import('./RESTController').RequestOptions - ) => Promise; - update: ( - className: string, - params: any, - options?: import('./RESTController').RequestOptions - ) => Promise; - send( - className: string, - method: string, - params: any, - options: import('./RESTController').RequestOptions - ): Promise; - }; - setSessionController(controller: { - getSession: (token: import('./RESTController').RequestOptions) => Promise; - }): void; - getSessionController(): { - getSession: (token: import('./RESTController').RequestOptions) => Promise; - }; - setStorageController( - controller: - | { + Cloud: typeof Cloud; + CLP: typeof CLP; + CoreManager: { + get: (key: string) => any; + set: (key: string, value: any) => void; + setIfNeeded: (key: string, value: any) => any; + setAnalyticsController(controller: { + track: (name: string, dimensions: { + [key: string]: string; + }) => Promise; + }): void; + getAnalyticsController(): { + track: (name: string, dimensions: { + [key: string]: string; + }) => Promise; + }; + setCloudController(controller: { + run: (name: string, data: any, options: import("./RESTController").RequestOptions) => Promise; + getJobsData: (options: import("./RESTController").RequestOptions) => Promise; + startJob: (name: string, data: any, options: import("./RESTController").RequestOptions) => Promise; + }): void; + getCloudController(): { + run: (name: string, data: any, options: import("./RESTController").RequestOptions) => Promise; + getJobsData: (options: import("./RESTController").RequestOptions) => Promise; + startJob: (name: string, data: any, options: import("./RESTController").RequestOptions) => Promise; + }; + setConfigController(controller: { + current: () => Promise | Config; + get: (opts?: import("./RESTController").RequestOptions) => Promise; + save: (attrs: { + [key: string]: any; + }, masterKeyOnlyFlags?: { + [key: string]: any; + }) => Promise; + }): void; + getConfigController(): { + current: () => Promise | Config; + get: (opts?: import("./RESTController").RequestOptions) => Promise; + save: (attrs: { + [key: string]: any; + }, masterKeyOnlyFlags?: { + [key: string]: any; + }) => Promise; + }; + setCryptoController(controller: { + encrypt: (obj: any, secretKey: string) => string; + decrypt: (encryptedText: string, secretKey: any) => string; + }): void; + getCryptoController(): { + encrypt: (obj: any, secretKey: string) => string; + decrypt: (encryptedText: string, secretKey: any) => string; + }; + setEventEmitter(eventEmitter: any): void; + getEventEmitter(): any; + setFileController(controller: { + saveFile: (name: string, source: import("./ParseFile").FileSource, options?: import("./RESTController").FullOptions) => Promise; + saveBase64: (name: string, source: import("./ParseFile").FileSource, options?: import("./ParseFile").FileSaveOptions) => Promise<{ + name: string; + url: string; + }>; + download: (uri: string, options?: any) => Promise<{ + base64?: string; + contentType?: string; + }>; + deleteFile: (name: string, options?: { + useMasterKey?: boolean; + }) => Promise; + }): void; + setEventuallyQueue(controller: { + save: (object: ParseObject, serverOptions: import("./ParseObject").SaveOptions) => Promise; + destroy: (object: ParseObject, serverOptions: import("./RESTController").RequestOptions) => Promise; + poll: (ms?: number) => void; + }): void; + getEventuallyQueue(): { + save: (object: ParseObject, serverOptions: import("./ParseObject").SaveOptions) => Promise; + destroy: (object: ParseObject, serverOptions: import("./RESTController").RequestOptions) => Promise; + poll: (ms?: number) => void; + }; + getFileController(): { + saveFile: (name: string, source: import("./ParseFile").FileSource, options?: import("./RESTController").FullOptions) => Promise; + saveBase64: (name: string, source: import("./ParseFile").FileSource, options?: import("./ParseFile").FileSaveOptions) => Promise<{ + name: string; + url: string; + }>; + download: (uri: string, options?: any) => Promise<{ + base64?: string; + contentType?: string; + }>; + deleteFile: (name: string, options?: { + useMasterKey?: boolean; + }) => Promise; + }; + setInstallationController(controller: { + currentInstallationId: () => Promise; + currentInstallation: () => Promise; + updateInstallationOnDisk: (installation: Installation) => Promise; + }): void; + getInstallationController(): { + currentInstallationId: () => Promise; + currentInstallation: () => Promise; + updateInstallationOnDisk: (installation: Installation) => Promise; + }; + setLiveQuery(liveQuery: any): void; + getLiveQuery(): any; + setObjectController(controller: { + fetch: (object: ParseObject | Array, forceFetch: boolean, options: import("./RESTController").RequestOptions) => Promise | ParseObject | undefined>; + save: (object: ParseObject | Array | null, options: import("./RESTController").RequestOptions) => Promise | File | undefined>; + destroy: (object: ParseObject | Array, options: import("./RESTController").RequestOptions) => Promise>; + }): void; + getObjectController(): { + fetch: (object: ParseObject | Array, forceFetch: boolean, options: import("./RESTController").RequestOptions) => Promise | ParseObject | undefined>; + save: (object: ParseObject | Array | null, options: import("./RESTController").RequestOptions) => Promise | File | undefined>; + destroy: (object: ParseObject | Array, options: import("./RESTController").RequestOptions) => Promise>; + }; + setObjectStateController(controller: { + getState: (obj: any) => import("./ObjectStateMutations").State | null; + initializeState: (obj: any, initial?: import("./ObjectStateMutations").State) => import("./ObjectStateMutations").State; + removeState: (obj: any) => import("./ObjectStateMutations").State | null; + getServerData: (obj: any) => import("./ObjectStateMutations").AttributeMap; + setServerData: (obj: any, attributes: import("./ObjectStateMutations").AttributeMap) => void; + getPendingOps: (obj: any) => Array; + setPendingOp: (obj: any, attr: string, op?: ParseOp.Op) => void; + pushPendingState: (obj: any) => void; + popPendingState: (obj: any) => import("./ObjectStateMutations").OpsMap | undefined; + mergeFirstPendingState: (obj: any) => void; + getObjectCache: (obj: any) => import("./ObjectStateMutations").ObjectCache; + estimateAttribute: (obj: any, attr: string) => any; + estimateAttributes: (obj: any) => import("./ObjectStateMutations").AttributeMap; + commitServerChanges: (obj: any, changes: import("./ObjectStateMutations").AttributeMap) => void; + enqueueTask: (obj: any, task: () => Promise) => Promise; + clearAllState: () => void; + duplicateState: (source: any, dest: any) => void; + }): void; + getObjectStateController(): { + getState: (obj: any) => import("./ObjectStateMutations").State | null; + initializeState: (obj: any, initial?: import("./ObjectStateMutations").State) => import("./ObjectStateMutations").State; + removeState: (obj: any) => import("./ObjectStateMutations").State | null; + getServerData: (obj: any) => import("./ObjectStateMutations").AttributeMap; + setServerData: (obj: any, attributes: import("./ObjectStateMutations").AttributeMap) => void; + getPendingOps: (obj: any) => Array; + setPendingOp: (obj: any, attr: string, op?: ParseOp.Op) => void; + pushPendingState: (obj: any) => void; + popPendingState: (obj: any) => import("./ObjectStateMutations").OpsMap | undefined; + mergeFirstPendingState: (obj: any) => void; + getObjectCache: (obj: any) => import("./ObjectStateMutations").ObjectCache; + estimateAttribute: (obj: any, attr: string) => any; + estimateAttributes: (obj: any) => import("./ObjectStateMutations").AttributeMap; + commitServerChanges: (obj: any, changes: import("./ObjectStateMutations").AttributeMap) => void; + enqueueTask: (obj: any, task: () => Promise) => Promise; + clearAllState: () => void; + duplicateState: (source: any, dest: any) => void; + }; + setPushController(controller: { + send: (data: Push.PushData, options?: import("./RESTController").FullOptions) => Promise; + }): void; + getPushController(): { + send: (data: Push.PushData, options?: import("./RESTController").FullOptions) => Promise; + }; + setQueryController(controller: { + find(className: string, params: import("./ParseQuery").QueryJSON, options: import("./RESTController").RequestOptions): Promise<{ + results?: Array; + className?: string; + count?: number; + }>; + aggregate(className: string, params: any, options: import("./RESTController").RequestOptions): Promise<{ + results?: Array; + }>; + }): void; + getQueryController(): { + find(className: string, params: import("./ParseQuery").QueryJSON, options: import("./RESTController").RequestOptions): Promise<{ + results?: Array; + className?: string; + count?: number; + }>; + aggregate(className: string, params: any, options: import("./RESTController").RequestOptions): Promise<{ + results?: Array; + }>; + }; + setRESTController(controller: { + request: (method: string, path: string, data?: any, options?: import("./RESTController").RequestOptions) => Promise; + ajax: (method: string, url: string, data: any, headers?: any, options?: import("./RESTController").FullOptions) => Promise; + handleError: (err + /** + * Call this method to set your LocalDatastoreStorage engine + * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()} + * + * @param {LocalDatastoreController} controller a data storage. + * @static + */ + ?: any) => void; + }): void; + getRESTController(): { + request: (method: string, path: string, data?: any, options?: import("./RESTController").RequestOptions) => Promise; + ajax: (method: string, url: string, data: any, headers?: any, options?: import("./RESTController").FullOptions) => Promise; + handleError: (err + /** + * Call this method to set your LocalDatastoreStorage engine + * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()} + * + * @param {LocalDatastoreController} controller a data storage. + * @static + */ + ?: any) => void; + }; + setSchemaController(controller: { + purge: (className: string) => Promise; + get: (className: string, options?: import("./RESTController").RequestOptions) => Promise<{ + results: Schema[]; + }>; + delete: (className: string, options?: import("./RESTController").RequestOptions) => Promise; + create: (className: string, params: any, options?: import("./RESTController").RequestOptions) => Promise; + update: (className: string, params: any, options?: import("./RESTController").RequestOptions) => Promise; + send(className: string, method: string, params: any, options: import("./RESTController").RequestOptions): Promise; + }): void; + getSchemaController(): { + purge: (className: string) => Promise; + get: (className: string, options?: import("./RESTController").RequestOptions) => Promise<{ + results: Schema[]; + }>; + delete: (className: string, options?: import("./RESTController").RequestOptions) => Promise; + create: (className: string, params: any, options?: import("./RESTController").RequestOptions) => Promise; + update: (className: string, params: any, options?: import("./RESTController").RequestOptions) => Promise; + send(className: string, method: string, params: any, options: import("./RESTController").RequestOptions): Promise; + }; + setSessionController(controller: { + getSession: (token: import("./RESTController").RequestOptions) => Promise; + }): void; + getSessionController(): { + getSession: (token: import("./RESTController").RequestOptions) => Promise; + }; + setStorageController(controller: { async: 0; getItem: (path: string) => string | null; setItem: (path: string, value: string) => void; @@ -460,8 +280,7 @@ declare const Parse: { clear: () => void; getAllKeys?: () => Array; getAllKeysAsync?: () => Promise>; - } - | { + } | { async: 1; getItem?: (path: string) => string | null; setItem?: (path: string, value: string) => void; @@ -472,476 +291,361 @@ declare const Parse: { clear: () => void; getAllKeys?: () => Array; getAllKeysAsync?: () => Promise>; - } - ): void; - setLocalDatastoreController(controller: { - fromPinWithName: (name: string) => any | undefined; - pinWithName: (name: string, objects: any) => void; - unPinWithName: (name: string) => void; - getAllContents: () => any | undefined; - clear: () => void; - }): void; - getLocalDatastoreController(): { - fromPinWithName: (name: string) => any | undefined; - pinWithName: (name: string, objects: any) => void; - unPinWithName: (name: string) => void; - getAllContents: () => any | undefined; - clear: () => void; - }; - setLocalDatastore(store: any): void; - getLocalDatastore(): any; - getStorageController(): - | { - async: 0; - getItem: (path: string) => string | null; - setItem: (path: string, value: string) => void; - removeItem: (path: string) => void; - getItemAsync?: (path: string) => Promise; - setItemAsync?: (path: string, value: string) => Promise; - removeItemAsync?: (path: string) => Promise; - clear: () => void; - getAllKeys?: () => Array; - getAllKeysAsync?: () => Promise>; - } - | { - async: 1; - getItem?: (path: string) => string | null; - setItem?: (path: string, value: string) => void; - removeItem?: (path: string) => void; - getItemAsync: (path: string) => Promise; - setItemAsync: (path: string, value: string) => Promise; - removeItemAsync: (path: string) => Promise; - clear: () => void; - getAllKeys?: () => Array; - getAllKeysAsync?: () => Promise>; + }): void; + setLocalDatastoreController(controller: { + fromPinWithName: (name: string) => any | undefined; + pinWithName: (name: string, objects: any) => void; + unPinWithName: (name: string) => void; + getAllContents: () => any | undefined; + clear: () => void; + }): void; + getLocalDatastoreController(): { + fromPinWithName: (name: string) => any | undefined; + pinWithName: (name: string, objects: any) => void; + unPinWithName: (name: string) => void; + getAllContents: () => any | undefined; + clear: () => void; + }; + setLocalDatastore(store: any): void; + getLocalDatastore(): any; + getStorageController(): { + async: 0; + getItem: (path: string) => string | null; + setItem: (path: string, value: string) => void; + removeItem: (path: string) => void; + getItemAsync?: (path: string) => Promise; + setItemAsync?: (path: string, value: string) => Promise; + removeItemAsync?: (path: string) => Promise; + clear: () => void; + getAllKeys?: () => Array; + getAllKeysAsync?: () => Promise>; + } | { + async: 1; + getItem?: (path: string) => string | null; + setItem?: (path: string, value: string) => void; + removeItem?: (path: string) => void; + getItemAsync: (path: string) => Promise; + setItemAsync: (path: string, value: string) => Promise; + removeItemAsync: (path: string) => Promise; + clear: () => void; + getAllKeys?: () => Array; + getAllKeysAsync?: () => Promise>; + }; + setAsyncStorage(storage: { + getItem: (key: string, callback?: (error?: Error | null, result?: string | null) => void) => Promise; + setItem: (key: string, value: string, callback?: (error?: Error | null) => void) => Promise; + removeItem: (key: string, callback?: (error?: Error | null) => void) => Promise; + mergeItem: (key: string, value: string, callback?: (error?: Error | null) => void) => Promise; + clear: (callback?: (error?: Error | null) => void) => Promise; + getAllKeys: (callback?: (error?: Error | null, result?: readonly string[] | null) => void) => Promise; + multiGet: (keys: readonly string[], callback?: (errors?: readonly (Error | null)[] | null, result?: readonly [string, string][]) => void) => Promise; + multiSet: (keyValuePairs: [string, string][], callback?: (errors?: readonly (Error | null)[] | null) => void) => Promise; + multiRemove: (keys: readonly string[], callback?: (errors?: readonly (Error | null)[] | null) => void) => Promise; + multiMerge: (keyValuePairs: [string, string][], callback?: (errors?: readonly (Error | null)[] | null) => void) => Promise; + }): void; + getAsyncStorage(): { + getItem: (key: string, callback?: (error?: Error | null, result?: string | null) => void) => Promise; + setItem: (key: string, value: string, callback?: (error?: Error | null) => void) => Promise; + removeItem: (key: string, callback?: (error?: Error | null) => void) => Promise; + mergeItem: (key: string, value: string, callback?: (error?: Error | null) => void) => Promise; + clear: (callback?: (error?: Error | null) => void) => Promise; + getAllKeys: (callback?: (error?: Error | null, result?: readonly string[] | null) => void) => Promise; + multiGet: (keys: readonly string[], callback?: (errors?: readonly (Error | null)[] | null, result?: readonly [string, string][]) => void) => Promise; + multiSet: (keyValuePairs: [string, string][], callback?: (errors?: readonly (Error | null)[] | null) => void) => Promise; + multiRemove: (keys: readonly string[], callback?: (errors?: readonly (Error | null)[] | null) => void) => Promise; + multiMerge: (keyValuePairs: [string, string][], callback?: (errors?: readonly (Error | null)[] | null) => void) => Promise; + }; + setWebSocketController(controller: new (url: string | URL, protocols?: string | string[] | undefined) => import("./CoreManager").WebSocketController): void; + getWebSocketController(): new (url: string | URL, protocols?: string | string[] | undefined) => import("./CoreManager").WebSocketController; + setUserController(controller: { + setCurrentUser: (user: User) => Promise; + currentUser: () => User | null; + currentUserAsync: () => Promise; + signUp: (user: User, attrs: import("./ObjectStateMutations").AttributeMap, options: import("./RESTController").RequestOptions) => Promise; + logIn: (user: User, options: import("./RESTController").RequestOptions) => Promise; + loginAs: (user: User, userId: string) => Promise; + become: (user: User, options: import("./RESTController").RequestOptions) => Promise; + hydrate: (user: User, userJSON: import("./ObjectStateMutations").AttributeMap) => Promise; + logOut: (options: import("./RESTController").RequestOptions) => Promise; + me: (user: User, options: import("./RESTController").RequestOptions) => Promise; + requestPasswordReset: (email: string, options: import("./RESTController").RequestOptions) => Promise; + updateUserOnDisk: (user: User) => Promise; + upgradeToRevocableSession: (user: User, options: import("./RESTController").RequestOptions) => Promise; + linkWith: (user: User, authData: import("./ParseUser").AuthData, options?: import("./RESTController").FullOptions) => Promise; + removeUserFromDisk: () => Promise; + verifyPassword: (username: string, password: string, options: import("./RESTController").RequestOptions) => Promise; + requestEmailVerification: (email: string, options: import("./RESTController").RequestOptions) => Promise; + }): void; + getUserController(): { + setCurrentUser: (user: User) => Promise; + currentUser: () => User | null; + currentUserAsync: () => Promise; + signUp: (user: User, attrs: import("./ObjectStateMutations").AttributeMap, options: import("./RESTController").RequestOptions) => Promise; + logIn: (user: User, options: import("./RESTController").RequestOptions) => Promise; + loginAs: (user: User, userId: string) => Promise; + become: (user: User, options: import("./RESTController").RequestOptions) => Promise; + hydrate: (user: User, userJSON: import("./ObjectStateMutations").AttributeMap) => Promise; + logOut: (options: import("./RESTController").RequestOptions) => Promise; + me: (user: User, options: import("./RESTController").RequestOptions) => Promise; + requestPasswordReset: (email: string, options: import("./RESTController").RequestOptions) => Promise; + updateUserOnDisk: (user: User) => Promise; + upgradeToRevocableSession: (user: User, options: import("./RESTController").RequestOptions) => Promise; + linkWith: (user: User, authData: import("./ParseUser").AuthData, options?: import("./RESTController").FullOptions) => Promise; + removeUserFromDisk: () => Promise; + verifyPassword: (username: string, password: string, options: import("./RESTController").RequestOptions) => Promise; + requestEmailVerification: (email: string, options: import("./RESTController").RequestOptions) => Promise; }; - setAsyncStorage(storage: { - getItem: ( - key: string, - callback?: (error?: Error | null, result?: string | null) => void - ) => Promise; - setItem: ( - key: string, - value: string, - callback?: (error?: Error | null) => void - ) => Promise; - removeItem: (key: string, callback?: (error?: Error | null) => void) => Promise; - mergeItem: ( - key: string, - value: string, - callback?: (error?: Error | null) => void - ) => Promise; - clear: (callback?: (error?: Error | null) => void) => Promise; - getAllKeys: ( - callback?: (error?: Error | null, result?: readonly string[] | null) => void - ) => Promise; - multiGet: ( - keys: readonly string[], - callback?: ( - errors?: readonly (Error | null)[] | null, - result?: readonly [string, string][] - ) => void - ) => Promise; - multiSet: ( - keyValuePairs: [string, string][], - callback?: (errors?: readonly (Error | null)[] | null) => void - ) => Promise; - multiRemove: ( - keys: readonly string[], - callback?: (errors?: readonly (Error | null)[] | null) => void - ) => Promise; - multiMerge: ( - keyValuePairs: [string, string][], - callback?: (errors?: readonly (Error | null)[] | null) => void - ) => Promise; - }): void; - getAsyncStorage(): { - getItem: ( - key: string, - callback?: (error?: Error | null, result?: string | null) => void - ) => Promise; - setItem: ( - key: string, - value: string, - callback?: (error?: Error | null) => void - ) => Promise; - removeItem: (key: string, callback?: (error?: Error | null) => void) => Promise; - mergeItem: ( - key: string, - value: string, - callback?: (error?: Error | null) => void - ) => Promise; - clear: (callback?: (error?: Error | null) => void) => Promise; - getAllKeys: ( - callback?: (error?: Error | null, result?: readonly string[] | null) => void - ) => Promise; - multiGet: ( - keys: readonly string[], - callback?: ( - errors?: readonly (Error | null)[] | null, - result?: readonly [string, string][] - ) => void - ) => Promise; - multiSet: ( - keyValuePairs: [string, string][], - callback?: (errors?: readonly (Error | null)[] | null) => void - ) => Promise; - multiRemove: ( - keys: readonly string[], - callback?: (errors?: readonly (Error | null)[] | null) => void - ) => Promise; - multiMerge: ( - keyValuePairs: [string, string][], - callback?: (errors?: readonly (Error | null)[] | null) => void - ) => Promise; + setLiveQueryController(controller: { + setDefaultLiveQueryClient(liveQueryClient: LiveQueryClient): void; + getDefaultLiveQueryClient(): Promise; + _clearCachedDefaultClient(): void; + }): void; + getLiveQueryController(): { + setDefaultLiveQueryClient(liveQueryClient: LiveQueryClient): void; + getDefaultLiveQueryClient(): Promise; + _clearCachedDefaultClient(): void; + }; + setHooksController(controller: { + get: (type: string, functionName?: string, triggerName?: string) => Promise; + create: (hook: Hooks.HookDeclaration) => Promise; + remove: (hook: Hooks.HookDeleteArg) => Promise; + update: (hook: Hooks.HookDeclaration) => Promise; + sendRequest?: (method: string, path: string, body?: any) => Promise; + }): void; + getHooksController(): { + get: (type: string, functionName?: string, triggerName?: string) => Promise; + create: (hook: Hooks.HookDeclaration) => Promise; + remove: (hook: Hooks.HookDeleteArg) => Promise; + update: (hook: Hooks.HookDeclaration) => Promise; + sendRequest?: (method: string, path: string, body?: any) => Promise; + }; + setParseOp(op: any): void; + getParseOp(): any; + setParseObject(object: any): void; + getParseObject(): any; + setParseQuery(query: any): void; + getParseQuery(): any; + setParseRole(role: any): void; + getParseRole(): any; + setParseUser(user: any): void; + getParseUser(): any; + }; + Config: typeof Config; + Error: typeof ParseError; + FacebookUtils: { + init(options: any): void; + isLinked(user: any): any; + logIn(permissions: any, options: any): Promise; + link(user: any, permissions: any, options: any): any; + unlink: (user: any, options: any) => any; + _getAuthProvider(): import("./ParseUser").AuthProviderType; }; - setWebSocketController( - controller: new ( - url: string | URL, - protocols?: string | string[] | undefined - ) => import('./CoreManager').WebSocketController - ): void; - getWebSocketController(): new ( - url: string | URL, - protocols?: string | string[] | undefined - ) => import('./CoreManager').WebSocketController; - setUserController(controller: { - setCurrentUser: (user: User) => Promise; - currentUser: () => User | null; - currentUserAsync: () => Promise; - signUp: ( - user: User, - attrs: import('./ObjectStateMutations').AttributeMap, - options: import('./RESTController').RequestOptions - ) => Promise; - logIn: (user: User, options: import('./RESTController').RequestOptions) => Promise; - loginAs: (user: User, userId: string) => Promise; - become: (user: User, options: import('./RESTController').RequestOptions) => Promise; - hydrate: ( - user: User, - userJSON: import('./ObjectStateMutations').AttributeMap - ) => Promise; - logOut: (options: import('./RESTController').RequestOptions) => Promise; - me: (user: User, options: import('./RESTController').RequestOptions) => Promise; - requestPasswordReset: ( - email: string, - options: import('./RESTController').RequestOptions - ) => Promise; - updateUserOnDisk: (user: User) => Promise; - upgradeToRevocableSession: ( - user: User, - options: import('./RESTController').RequestOptions - ) => Promise; - linkWith: ( - user: User, - authData: import('./ParseUser').AuthData, - options?: import('./RESTController').FullOptions - ) => Promise; - removeUserFromDisk: () => Promise; - verifyPassword: ( - username: string, - password: string, - options: import('./RESTController').RequestOptions - ) => Promise; - requestEmailVerification: ( - email: string, - options: import('./RESTController').RequestOptions - ) => Promise; - }): void; - getUserController(): { - setCurrentUser: (user: User) => Promise; - currentUser: () => User | null; - currentUserAsync: () => Promise; - signUp: ( - user: User, - attrs: import('./ObjectStateMutations').AttributeMap, - options: import('./RESTController').RequestOptions - ) => Promise; - logIn: (user: User, options: import('./RESTController').RequestOptions) => Promise; - loginAs: (user: User, userId: string) => Promise; - become: (user: User, options: import('./RESTController').RequestOptions) => Promise; - hydrate: ( - user: User, - userJSON: import('./ObjectStateMutations').AttributeMap - ) => Promise; - logOut: (options: import('./RESTController').RequestOptions) => Promise; - me: (user: User, options: import('./RESTController').RequestOptions) => Promise; - requestPasswordReset: ( - email: string, - options: import('./RESTController').RequestOptions - ) => Promise; - updateUserOnDisk: (user: User) => Promise; - upgradeToRevocableSession: ( - user: User, - options: import('./RESTController').RequestOptions - ) => Promise; - linkWith: ( - user: User, - authData: import('./ParseUser').AuthData, - options?: import('./RESTController').FullOptions - ) => Promise; - removeUserFromDisk: () => Promise; - verifyPassword: ( - username: string, - password: string, - options: import('./RESTController').RequestOptions - ) => Promise; - requestEmailVerification: ( - email: string, - options: import('./RESTController').RequestOptions - ) => Promise; + File: typeof File; + GeoPoint: typeof GeoPoint; + Polygon: typeof Polygon; + Installation: typeof Installation; + LocalDatastore: { + isEnabled: boolean; + isSyncing: boolean; + fromPinWithName(name: string): Promise>; + pinWithName(name: string, value: any): Promise; + unPinWithName(name: string): Promise; + _getAllContents(): Promise; + _getRawStorage(): Promise; + _clear(): Promise; + _handlePinAllWithName(name: string, objects: Array): Promise; + _handleUnPinAllWithName(name: string, objects: Array): Promise; + _getChildren(object: ParseObject): any; + _traverse(object: any, encountered: any): void; + _serializeObjectsFromPinName(name: string): Promise; + _serializeObject(objectKey: string, localDatastore: any): Promise; + _updateObjectIfPinned(object: ParseObject): Promise; + _destroyObjectIfPinned(object: ParseObject): Promise; + _updateLocalIdForObject(localId: string, object: ParseObject): Promise; + updateFromServer(): Promise; + getKeyForObject(object: any): string; + getPinName(pinName?: string): string; + checkIfEnabled(): any; }; - setLiveQueryController(controller: { - setDefaultLiveQueryClient(liveQueryClient: LiveQueryClient): void; - getDefaultLiveQueryClient(): Promise; - _clearCachedDefaultClient(): void; - }): void; - getLiveQueryController(): { - setDefaultLiveQueryClient(liveQueryClient: LiveQueryClient): void; - getDefaultLiveQueryClient(): Promise; - _clearCachedDefaultClient(): void; + Object: typeof ParseObject; + Op: { + Set: typeof ParseOp.SetOp; + Unset: typeof ParseOp.UnsetOp; + Increment: typeof ParseOp.IncrementOp; + Add: typeof ParseOp.AddOp; + Remove: typeof ParseOp.RemoveOp; + AddUnique: typeof ParseOp.AddUniqueOp; + Relation: typeof ParseOp.RelationOp; }; - setHooksController(controller: { - get: (type: string, functionName?: string, triggerName?: string) => Promise; - create: (hook: Hooks.HookDeclaration) => Promise; - remove: (hook: Hooks.HookDeleteArg) => Promise; - update: (hook: Hooks.HookDeclaration) => Promise; - sendRequest?: (method: string, path: string, body?: any) => Promise; - }): void; - getHooksController(): { - get: (type: string, functionName?: string, triggerName?: string) => Promise; - create: (hook: Hooks.HookDeclaration) => Promise; - remove: (hook: Hooks.HookDeleteArg) => Promise; - update: (hook: Hooks.HookDeclaration) => Promise; - sendRequest?: (method: string, path: string, body?: any) => Promise; + Push: typeof Push; + Query: typeof Query; + Relation: typeof Relation; + Role: typeof Role; + Schema: typeof Schema; + Session: typeof Session; + Storage: { + async(): boolean; + getItem(path: string): string | null; + getItemAsync(path: string): Promise; + setItem(path: string, value: string): void; + setItemAsync(path: string, value: string): Promise; + removeItem(path: string): void; + removeItemAsync(path: string): Promise; + getAllKeys(): Array; + getAllKeysAsync(): Promise>; + generatePath(path: string): string; + _clear(): void; }; - setParseOp(op: any): void; - getParseOp(): any; - setParseObject(object: any): void; - getParseObject(): any; - setParseQuery(query: any): void; - getParseQuery(): any; - setParseRole(role: any): void; - getParseRole(): any; - setParseUser(user: any): void; - getParseUser(): any; - }; - Config: typeof Config; - Error: typeof ParseError; - FacebookUtils: { - init(options: any): void; - isLinked(user: any): any; - logIn(permissions: any, options: any): Promise; - link(user: any, permissions: any, options: any): any; - unlink: (user: any, options: any) => any; - _getAuthProvider(): import('./ParseUser').AuthProviderType; - }; - File: typeof File; - GeoPoint: typeof GeoPoint; - Polygon: typeof Polygon; - Installation: typeof Installation; - LocalDatastore: { - isEnabled: boolean; - isSyncing: boolean; - fromPinWithName(name: string): Promise>; - pinWithName(name: string, value: any): Promise; - unPinWithName(name: string): Promise; - _getAllContents(): Promise; - _getRawStorage(): Promise; - _clear(): Promise; - _handlePinAllWithName(name: string, objects: Array): Promise; - _handleUnPinAllWithName(name: string, objects: Array): Promise; - _getChildren(object: ParseObject): any; - _traverse(object: any, encountered: any): void; - _serializeObjectsFromPinName(name: string): Promise; - _serializeObject(objectKey: string, localDatastore: any): Promise; - _updateObjectIfPinned(object: ParseObject): Promise; - _destroyObjectIfPinned(object: ParseObject): Promise; - _updateLocalIdForObject(localId: string, object: ParseObject): Promise; - updateFromServer(): Promise; - getKeyForObject(object: any): string; - getPinName(pinName?: string): string; - checkIfEnabled(): any; - }; - Object: typeof ParseObject; - Op: { - Set: typeof ParseOp.SetOp; - Unset: typeof ParseOp.UnsetOp; - Increment: typeof ParseOp.IncrementOp; - Add: typeof ParseOp.AddOp; - Remove: typeof ParseOp.RemoveOp; - AddUnique: typeof ParseOp.AddUniqueOp; - Relation: typeof ParseOp.RelationOp; - }; - Push: typeof Push; - Query: typeof Query; - Relation: typeof Relation; - Role: typeof Role; - Schema: typeof Schema; - Session: typeof Session; - Storage: { - async(): boolean; - getItem(path: string): string | null; - getItemAsync(path: string): Promise; - setItem(path: string, value: string): void; - setItemAsync(path: string, value: string): Promise; - removeItem(path: string): void; - removeItemAsync(path: string): Promise; - getAllKeys(): Array; - getAllKeysAsync(): Promise>; - generatePath(path: string): string; - _clear(): void; - }; - User: typeof User; - LiveQueryClient: typeof LiveQueryClient; - IndexedDB: any; - Hooks: any; - Parse: any; - get EventuallyQueue(): any; - /** - * @member {EventuallyQueue} Parse.EventuallyQueue - * @static - */ - set EventuallyQueue(queue: typeof EventuallyQueue); - /** - * Call this method first to set up your authentication tokens for Parse. - * - * @param {string} applicationId Your Parse Application ID. - * @param {string} [javaScriptKey] Your Parse JavaScript Key (Not needed for parse-server) - * @param {string} [masterKey] Your Parse Master Key. (Node.js only!) - * @static - */ - initialize(applicationId: string, javaScriptKey: string): void; - _initialize(applicationId: string, javaScriptKey: string, masterKey?: string): void; - /** - * Call this method to set your AsyncStorage engine - * Starting Parse@1.11, the ParseSDK do not provide a React AsyncStorage as the ReactNative module - * is not provided at a stable path and changes over versions. - * - * @param {AsyncStorage} storage a react native async storage. - * @static - */ - setAsyncStorage(storage: any): void; - /** - * Call this method to set your LocalDatastoreStorage engine - * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()} - * - * @param {LocalDatastoreController} controller a data storage. - * @static - */ - setLocalDatastoreController(controller: any): void; - /** - * Returns information regarding the current server's health - * - * @returns {Promise} - * @static - */ - getServerHealth(): Promise; - /** - * @member {string} Parse.applicationId - * @static - */ - applicationId: any; - /** - * @member {string} Parse.javaScriptKey - * @static - */ - javaScriptKey: any; - /** - * @member {string} Parse.masterKey - * @static - */ - masterKey: any; - /** - * @member {string} Parse.serverURL - * @static - */ - serverURL: any; - /** - * @member {string} Parse.serverAuthToken - * @static - */ - serverAuthToken: any; - /** - * @member {string} Parse.serverAuthType - * @static - */ - serverAuthType: any; - /** - * @member {ParseLiveQuery} Parse.LiveQuery - * @static - */ - LiveQuery: ParseLiveQuery; - /** - * @member {string} Parse.liveQueryServerURL - * @static - */ - liveQueryServerURL: any; - /** - * @member {boolean} Parse.encryptedUser - * @static - */ - encryptedUser: boolean; - /** - * @member {string} Parse.secret - * @static - */ - secret: any; - /** - * @member {boolean} Parse.idempotency - * @static - */ - idempotency: any; - /** - * @member {boolean} Parse.allowCustomObjectId - * @static - */ - allowCustomObjectId: any; - _request(...args: any[]): any; - _ajax(...args: any[]): any; - _decode(_: any, value: any): any; - _encode(value: any, _: any, disallowObjects: any): any; - _getInstallationId(): Promise; - /** - * Enable pinning in your application. - * This must be called after `Parse.initialize` in your application. - * - * @param [polling] Allow pinging the server /health endpoint. Default true - * @param [ms] Milliseconds to ping the server. Default 2000ms - * @static - */ - enableLocalDatastore(polling?: boolean, ms?: number): void; - /** - * Flag that indicates whether Local Datastore is enabled. - * - * @static - * @returns {boolean} - */ - isLocalDatastoreEnabled(): any; - /** - * Gets all contents from Local Datastore - * - *
-   * await Parse.dumpLocalDatastore();
-   * 
- * - * @static - * @returns {object} - */ - dumpLocalDatastore(): Promise; - /** - * Enable the current user encryption. - * This must be called before login any user. - * - * @static - */ - enableEncryptedUser(): void; - /** - * Flag that indicates whether Encrypted User is enabled. - * - * @static - * @returns {boolean} - */ - isEncryptedUserEnabled(): any; + User: typeof User; + LiveQueryClient: typeof LiveQueryClient; + IndexedDB: any; + Hooks: any; + Parse: any; + get EventuallyQueue(): any; + /** + * @member {EventuallyQueue} Parse.EventuallyQueue + * @static + */ + set EventuallyQueue(queue: typeof EventuallyQueue); + /** + * Call this method first to set up your authentication tokens for Parse. + * + * @param {string} applicationId Your Parse Application ID. + * @param {string} [javaScriptKey] Your Parse JavaScript Key (Not needed for parse-server) + * @param {string} [masterKey] Your Parse Master Key. (Node.js only!) + * @static + */ + initialize(applicationId: string, javaScriptKey: string): void; + _initialize(applicationId: string, javaScriptKey: string, masterKey?: string): void; + /** + * Call this method to set your AsyncStorage engine + * Starting Parse@1.11, the ParseSDK do not provide a React AsyncStorage as the ReactNative module + * is not provided at a stable path and changes over versions. + * + * @param {AsyncStorage} storage a react native async storage. + * @static + */ + setAsyncStorage(storage: any): void; + /** + * Call this method to set your LocalDatastoreStorage engine + * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()} + * + * @param {LocalDatastoreController} controller a data storage. + * @static + */ + setLocalDatastoreController(controller: any): void; + /** + * Returns information regarding the current server's health + * + * @returns {Promise} + * @static + */ + getServerHealth(): Promise; + /** + * @member {string} Parse.applicationId + * @static + */ + applicationId: any; + /** + * @member {string} Parse.javaScriptKey + * @static + */ + javaScriptKey: any; + /** + * @member {string} Parse.masterKey + * @static + */ + masterKey: any; + /** + * @member {string} Parse.serverURL + * @static + */ + serverURL: any; + /** + * @member {string} Parse.serverAuthToken + * @static + */ + serverAuthToken: any; + /** + * @member {string} Parse.serverAuthType + * @static + */ + serverAuthType: any; + /** + * @member {ParseLiveQuery} Parse.LiveQuery + * @static + */ + LiveQuery: ParseLiveQuery; + /** + * @member {string} Parse.liveQueryServerURL + * @static + */ + liveQueryServerURL: any; + /** + * @member {boolean} Parse.encryptedUser + * @static + */ + encryptedUser: boolean; + /** + * @member {string} Parse.secret + * @static + */ + secret: any; + /** + * @member {boolean} Parse.idempotency + * @static + */ + idempotency: any; + /** + * @member {boolean} Parse.allowCustomObjectId + * @static + */ + allowCustomObjectId: any; + _request(...args: any[]): any; + _ajax(...args: any[]): any; + _decode(_: any, value: any): any; + _encode(value: any, _: any, disallowObjects: any): any; + _getInstallationId(): Promise; + /** + * Enable pinning in your application. + * This must be called after `Parse.initialize` in your application. + * + * @param [polling] Allow pinging the server /health endpoint. Default true + * @param [ms] Milliseconds to ping the server. Default 2000ms + * @static + */ + enableLocalDatastore(polling?: boolean, ms?: number): void; + /** + * Flag that indicates whether Local Datastore is enabled. + * + * @static + * @returns {boolean} + */ + isLocalDatastoreEnabled(): any; + /** + * Gets all contents from Local Datastore + * + *
+     * await Parse.dumpLocalDatastore();
+     * 
+ * + * @static + * @returns {object} + */ + dumpLocalDatastore(): Promise; + /** + * Enable the current user encryption. + * This must be called before login any user. + * + * @static + */ + enableEncryptedUser(): void; + /** + * Flag that indicates whether Encrypted User is enabled. + * + * @static + * @returns {boolean} + */ + isEncryptedUserEnabled(): any; }; export default Parse; diff --git a/types/ParseACL.d.ts b/types/ParseACL.d.ts index fc8da8570..3e3f13e95 100644 --- a/types/ParseACL.d.ts +++ b/types/ParseACL.d.ts @@ -1,10 +1,10 @@ import type ParseRole from './ParseRole'; import type ParseUser from './ParseUser'; type PermissionsMap = { - [permission: string]: boolean; + [permission: string]: boolean; }; type ByIdMap = { - [userId: string]: PermissionsMap; + [userId: string]: PermissionsMap; }; /** * Creates a new ACL. @@ -21,121 +21,121 @@ type ByIdMap = { * @alias Parse.ACL */ declare class ParseACL { - permissionsById: ByIdMap; - /** - * @param {(Parse.User | object)} arg1 The user to initialize the ACL for - */ - constructor(arg1: ParseUser | ByIdMap); - /** - * Returns a JSON-encoded version of the ACL. - * - * @returns {object} - */ - toJSON(): ByIdMap; - /** - * Returns whether this ACL is equal to another object - * - * @param {ParseACL} other The other object's ACL to compare to - * @returns {boolean} - */ - equals(other: ParseACL): boolean; - _setAccess(accessType: string, userId: ParseUser | ParseRole | string, allowed: boolean): void; - _getAccess(accessType: string, userId: ParseUser | ParseRole | string): boolean; - /** - * Sets whether the given user is allowed to read this object. - * - * @param userId An instance of Parse.User or its objectId. - * @param {boolean} allowed Whether that user should have read access. - */ - setReadAccess(userId: ParseUser | ParseRole | string, allowed: boolean): void; - /** - * Get whether the given user id is *explicitly* allowed to read this object. - * Even if this returns false, the user may still be able to access it if - * getPublicReadAccess returns true or a role that the user belongs to has - * write access. - * - * @param userId An instance of Parse.User or its objectId, or a Parse.Role. - * @returns {boolean} - */ - getReadAccess(userId: ParseUser | ParseRole | string): boolean; - /** - * Sets whether the given user id is allowed to write this object. - * - * @param userId An instance of Parse.User or its objectId, or a Parse.Role.. - * @param {boolean} allowed Whether that user should have write access. - */ - setWriteAccess(userId: ParseUser | ParseRole | string, allowed: boolean): void; - /** - * Gets whether the given user id is *explicitly* allowed to write this object. - * Even if this returns false, the user may still be able to write it if - * getPublicWriteAccess returns true or a role that the user belongs to has - * write access. - * - * @param userId An instance of Parse.User or its objectId, or a Parse.Role. - * @returns {boolean} - */ - getWriteAccess(userId: ParseUser | ParseRole | string): boolean; - /** - * Sets whether the public is allowed to read this object. - * - * @param {boolean} allowed - */ - setPublicReadAccess(allowed: boolean): void; - /** - * Gets whether the public is allowed to read this object. - * - * @returns {boolean} - */ - getPublicReadAccess(): boolean; - /** - * Sets whether the public is allowed to write this object. - * - * @param {boolean} allowed - */ - setPublicWriteAccess(allowed: boolean): void; - /** - * Gets whether the public is allowed to write this object. - * - * @returns {boolean} - */ - getPublicWriteAccess(): boolean; - /** - * Gets whether users belonging to the given role are allowed - * to read this object. Even if this returns false, the role may - * still be able to write it if a parent role has read access. - * - * @param role The name of the role, or a Parse.Role object. - * @returns {boolean} true if the role has read access. false otherwise. - * @throws {TypeError} If role is neither a Parse.Role nor a String. - */ - getRoleReadAccess(role: ParseRole | string): boolean; - /** - * Gets whether users belonging to the given role are allowed - * to write this object. Even if this returns false, the role may - * still be able to write it if a parent role has write access. - * - * @param role The name of the role, or a Parse.Role object. - * @returns {boolean} true if the role has write access. false otherwise. - * @throws {TypeError} If role is neither a Parse.Role nor a String. - */ - getRoleWriteAccess(role: ParseRole | string): boolean; - /** - * Sets whether users belonging to the given role are allowed - * to read this object. - * - * @param role The name of the role, or a Parse.Role object. - * @param {boolean} allowed Whether the given role can read this object. - * @throws {TypeError} If role is neither a Parse.Role nor a String. - */ - setRoleReadAccess(role: ParseRole | string, allowed: boolean): void; - /** - * Sets whether users belonging to the given role are allowed - * to write this object. - * - * @param role The name of the role, or a Parse.Role object. - * @param {boolean} allowed Whether the given role can write this object. - * @throws {TypeError} If role is neither a Parse.Role nor a String. - */ - setRoleWriteAccess(role: ParseRole | string, allowed: boolean): void; + permissionsById: ByIdMap; + /** + * @param {(Parse.User | object)} arg1 The user to initialize the ACL for + */ + constructor(arg1: ParseUser | ByIdMap); + /** + * Returns a JSON-encoded version of the ACL. + * + * @returns {object} + */ + toJSON(): ByIdMap; + /** + * Returns whether this ACL is equal to another object + * + * @param {ParseACL} other The other object's ACL to compare to + * @returns {boolean} + */ + equals(other: ParseACL): boolean; + _setAccess(accessType: string, userId: ParseUser | ParseRole | string, allowed: boolean): void; + _getAccess(accessType: string, userId: ParseUser | ParseRole | string): boolean; + /** + * Sets whether the given user is allowed to read this object. + * + * @param userId An instance of Parse.User or its objectId. + * @param {boolean} allowed Whether that user should have read access. + */ + setReadAccess(userId: ParseUser | ParseRole | string, allowed: boolean): void; + /** + * Get whether the given user id is *explicitly* allowed to read this object. + * Even if this returns false, the user may still be able to access it if + * getPublicReadAccess returns true or a role that the user belongs to has + * write access. + * + * @param userId An instance of Parse.User or its objectId, or a Parse.Role. + * @returns {boolean} + */ + getReadAccess(userId: ParseUser | ParseRole | string): boolean; + /** + * Sets whether the given user id is allowed to write this object. + * + * @param userId An instance of Parse.User or its objectId, or a Parse.Role.. + * @param {boolean} allowed Whether that user should have write access. + */ + setWriteAccess(userId: ParseUser | ParseRole | string, allowed: boolean): void; + /** + * Gets whether the given user id is *explicitly* allowed to write this object. + * Even if this returns false, the user may still be able to write it if + * getPublicWriteAccess returns true or a role that the user belongs to has + * write access. + * + * @param userId An instance of Parse.User or its objectId, or a Parse.Role. + * @returns {boolean} + */ + getWriteAccess(userId: ParseUser | ParseRole | string): boolean; + /** + * Sets whether the public is allowed to read this object. + * + * @param {boolean} allowed + */ + setPublicReadAccess(allowed: boolean): void; + /** + * Gets whether the public is allowed to read this object. + * + * @returns {boolean} + */ + getPublicReadAccess(): boolean; + /** + * Sets whether the public is allowed to write this object. + * + * @param {boolean} allowed + */ + setPublicWriteAccess(allowed: boolean): void; + /** + * Gets whether the public is allowed to write this object. + * + * @returns {boolean} + */ + getPublicWriteAccess(): boolean; + /** + * Gets whether users belonging to the given role are allowed + * to read this object. Even if this returns false, the role may + * still be able to write it if a parent role has read access. + * + * @param role The name of the role, or a Parse.Role object. + * @returns {boolean} true if the role has read access. false otherwise. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + getRoleReadAccess(role: ParseRole | string): boolean; + /** + * Gets whether users belonging to the given role are allowed + * to write this object. Even if this returns false, the role may + * still be able to write it if a parent role has write access. + * + * @param role The name of the role, or a Parse.Role object. + * @returns {boolean} true if the role has write access. false otherwise. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + getRoleWriteAccess(role: ParseRole | string): boolean; + /** + * Sets whether users belonging to the given role are allowed + * to read this object. + * + * @param role The name of the role, or a Parse.Role object. + * @param {boolean} allowed Whether the given role can read this object. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + setRoleReadAccess(role: ParseRole | string, allowed: boolean): void; + /** + * Sets whether users belonging to the given role are allowed + * to write this object. + * + * @param role The name of the role, or a Parse.Role object. + * @param {boolean} allowed Whether the given role can write this object. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + setRoleWriteAccess(role: ParseRole | string, allowed: boolean): void; } export default ParseACL; diff --git a/types/ParseCLP.d.ts b/types/ParseCLP.d.ts index 9a3d8e3b3..eaa7d6b26 100644 --- a/types/ParseCLP.d.ts +++ b/types/ParseCLP.d.ts @@ -2,13 +2,13 @@ import ParseRole from './ParseRole'; import ParseUser from './ParseUser'; type Entity = ParseUser | ParseRole | string; type UsersMap = { - [userId: string]: boolean | any; + [userId: string]: boolean | any; }; export type PermissionsMap = { - writeUserFields?: string[]; - readUserFields?: string[]; + writeUserFields?: string[]; + readUserFields?: string[]; } & { - [permission: string]: UsersMap; + [permission: string]: UsersMap; }; /** * Creates a new CLP. @@ -103,191 +103,191 @@ export type PermissionsMap = { * @alias Parse.CLP */ declare class ParseCLP { - permissionsMap: PermissionsMap; - /** - * @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for - */ - constructor(userId: ParseUser | ParseRole | PermissionsMap); - /** - * Returns a JSON-encoded version of the CLP. - * - * @returns {object} - */ - toJSON(): PermissionsMap; - /** - * Returns whether this CLP is equal to another object - * - * @param other The other object to compare to - * @returns {boolean} - */ - equals(other: ParseCLP): boolean; - _getRoleName(role: ParseRole | string): string; - _parseEntity(entity: Entity): string; - _setAccess(permission: string, userId: Entity, allowed: boolean): void; - _getAccess(permission: string, userId: Entity, returnBoolean?: boolean): boolean | string[]; - _setArrayAccess(permission: string, userId: Entity, fields: string[]): void; - _setGroupPointerPermission(operation: string, pointerFields: string[]): void; - _getGroupPointerPermissions(operation: 'readUserFields' | 'writeUserFields'): string[]; - /** - * Sets user pointer fields to allow permission for get/count/find operations. - * - * @param {string[]} pointerFields User pointer fields - */ - setReadUserFields(pointerFields: string[]): void; - /** - * @returns {string[]} User pointer fields - */ - getReadUserFields(): string[]; - /** - * Sets user pointer fields to allow permission for create/delete/update/addField operations - * - * @param {string[]} pointerFields User pointer fields - */ - setWriteUserFields(pointerFields: string[]): void; - /** - * @returns {string[]} User pointer fields - */ - getWriteUserFields(): string[]; - /** - * Sets whether the given user is allowed to retrieve fields from this class. - * - * @param userId An instance of Parse.User or its objectId. - * @param {string[]} fields fields to be protected - */ - setProtectedFields(userId: Entity, fields: string[]): void; - /** - * Returns array of fields are accessable to this user. - * - * @param userId An instance of Parse.User or its objectId, or a Parse.Role. - * @returns {string[]} - */ - getProtectedFields(userId: Entity): string[]; - /** - * Sets whether the given user is allowed to read from this class. - * - * @param userId An instance of Parse.User or its objectId. - * @param {boolean} allowed whether that user should have read access. - */ - setReadAccess(userId: Entity, allowed: boolean): void; - /** - * Get whether the given user id is *explicitly* allowed to read from this class. - * Even if this returns false, the user may still be able to access it if - * getPublicReadAccess returns true or a role that the user belongs to has - * write access. - * - * @param userId An instance of Parse.User or its objectId, or a Parse.Role. - * @returns {boolean} - */ - getReadAccess(userId: Entity): boolean; - /** - * Sets whether the given user id is allowed to write to this class. - * - * @param userId An instance of Parse.User or its objectId, or a Parse.Role.. - * @param {boolean} allowed Whether that user should have write access. - */ - setWriteAccess(userId: Entity, allowed: boolean): void; - /** - * Gets whether the given user id is *explicitly* allowed to write to this class. - * Even if this returns false, the user may still be able to write it if - * getPublicWriteAccess returns true or a role that the user belongs to has - * write access. - * - * @param userId An instance of Parse.User or its objectId, or a Parse.Role. - * @returns {boolean} - */ - getWriteAccess(userId: Entity): boolean; - /** - * Sets whether the public is allowed to read from this class. - * - * @param {boolean} allowed - */ - setPublicReadAccess(allowed: boolean): void; - /** - * Gets whether the public is allowed to read from this class. - * - * @returns {boolean} - */ - getPublicReadAccess(): boolean; - /** - * Sets whether the public is allowed to write to this class. - * - * @param {boolean} allowed - */ - setPublicWriteAccess(allowed: boolean): void; - /** - * Gets whether the public is allowed to write to this class. - * - * @returns {boolean} - */ - getPublicWriteAccess(): boolean; - /** - * Sets whether the public is allowed to protect fields in this class. - * - * @param {string[]} fields - */ - setPublicProtectedFields(fields: string[]): void; - /** - * Gets whether the public is allowed to read fields from this class. - * - * @returns {string[]} - */ - getPublicProtectedFields(): string[]; - /** - * Gets whether users belonging to the given role are allowed - * to read from this class. Even if this returns false, the role may - * still be able to write it if a parent role has read access. - * - * @param role The name of the role, or a Parse.Role object. - * @returns {boolean} true if the role has read access. false otherwise. - * @throws {TypeError} If role is neither a Parse.Role nor a String. - */ - getRoleReadAccess(role: ParseRole | string): boolean; - /** - * Gets whether users belonging to the given role are allowed - * to write to this user. Even if this returns false, the role may - * still be able to write it if a parent role has write access. - * - * @param role The name of the role, or a Parse.Role object. - * @returns {boolean} true if the role has write access. false otherwise. - * @throws {TypeError} If role is neither a Parse.Role nor a String. - */ - getRoleWriteAccess(role: ParseRole | string): boolean; - /** - * Sets whether users belonging to the given role are allowed - * to read from this class. - * - * @param role The name of the role, or a Parse.Role object. - * @param {boolean} allowed Whether the given role can read this object. - * @throws {TypeError} If role is neither a Parse.Role nor a String. - */ - setRoleReadAccess(role: ParseRole | string, allowed: boolean): void; - /** - * Sets whether users belonging to the given role are allowed - * to write to this class. - * - * @param role The name of the role, or a Parse.Role object. - * @param {boolean} allowed Whether the given role can write this object. - * @throws {TypeError} If role is neither a Parse.Role nor a String. - */ - setRoleWriteAccess(role: ParseRole | string, allowed: boolean): void; - /** - * Gets whether users belonging to the given role are allowed - * to count to this user. Even if this returns false, the role may - * still be able to count it if a parent role has count access. - * - * @param role The name of the role, or a Parse.Role object. - * @returns {string[]} - * @throws {TypeError} If role is neither a Parse.Role nor a String. - */ - getRoleProtectedFields(role: ParseRole | string): string[]; - /** - * Sets whether users belonging to the given role are allowed - * to set access field in this class. - * - * @param role The name of the role, or a Parse.Role object. - * @param {string[]} fields Fields to be protected by Role. - * @throws {TypeError} If role is neither a Parse.Role nor a String. - */ - setRoleProtectedFields(role: ParseRole | string, fields: string[]): void; + permissionsMap: PermissionsMap; + /** + * @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for + */ + constructor(userId: ParseUser | ParseRole | PermissionsMap); + /** + * Returns a JSON-encoded version of the CLP. + * + * @returns {object} + */ + toJSON(): PermissionsMap; + /** + * Returns whether this CLP is equal to another object + * + * @param other The other object to compare to + * @returns {boolean} + */ + equals(other: ParseCLP): boolean; + _getRoleName(role: ParseRole | string): string; + _parseEntity(entity: Entity): string; + _setAccess(permission: string, userId: Entity, allowed: boolean): void; + _getAccess(permission: string, userId: Entity, returnBoolean?: boolean): boolean | string[]; + _setArrayAccess(permission: string, userId: Entity, fields: string[]): void; + _setGroupPointerPermission(operation: string, pointerFields: string[]): void; + _getGroupPointerPermissions(operation: 'readUserFields' | 'writeUserFields'): string[]; + /** + * Sets user pointer fields to allow permission for get/count/find operations. + * + * @param {string[]} pointerFields User pointer fields + */ + setReadUserFields(pointerFields: string[]): void; + /** + * @returns {string[]} User pointer fields + */ + getReadUserFields(): string[]; + /** + * Sets user pointer fields to allow permission for create/delete/update/addField operations + * + * @param {string[]} pointerFields User pointer fields + */ + setWriteUserFields(pointerFields: string[]): void; + /** + * @returns {string[]} User pointer fields + */ + getWriteUserFields(): string[]; + /** + * Sets whether the given user is allowed to retrieve fields from this class. + * + * @param userId An instance of Parse.User or its objectId. + * @param {string[]} fields fields to be protected + */ + setProtectedFields(userId: Entity, fields: string[]): void; + /** + * Returns array of fields are accessable to this user. + * + * @param userId An instance of Parse.User or its objectId, or a Parse.Role. + * @returns {string[]} + */ + getProtectedFields(userId: Entity): string[]; + /** + * Sets whether the given user is allowed to read from this class. + * + * @param userId An instance of Parse.User or its objectId. + * @param {boolean} allowed whether that user should have read access. + */ + setReadAccess(userId: Entity, allowed: boolean): void; + /** + * Get whether the given user id is *explicitly* allowed to read from this class. + * Even if this returns false, the user may still be able to access it if + * getPublicReadAccess returns true or a role that the user belongs to has + * write access. + * + * @param userId An instance of Parse.User or its objectId, or a Parse.Role. + * @returns {boolean} + */ + getReadAccess(userId: Entity): boolean; + /** + * Sets whether the given user id is allowed to write to this class. + * + * @param userId An instance of Parse.User or its objectId, or a Parse.Role.. + * @param {boolean} allowed Whether that user should have write access. + */ + setWriteAccess(userId: Entity, allowed: boolean): void; + /** + * Gets whether the given user id is *explicitly* allowed to write to this class. + * Even if this returns false, the user may still be able to write it if + * getPublicWriteAccess returns true or a role that the user belongs to has + * write access. + * + * @param userId An instance of Parse.User or its objectId, or a Parse.Role. + * @returns {boolean} + */ + getWriteAccess(userId: Entity): boolean; + /** + * Sets whether the public is allowed to read from this class. + * + * @param {boolean} allowed + */ + setPublicReadAccess(allowed: boolean): void; + /** + * Gets whether the public is allowed to read from this class. + * + * @returns {boolean} + */ + getPublicReadAccess(): boolean; + /** + * Sets whether the public is allowed to write to this class. + * + * @param {boolean} allowed + */ + setPublicWriteAccess(allowed: boolean): void; + /** + * Gets whether the public is allowed to write to this class. + * + * @returns {boolean} + */ + getPublicWriteAccess(): boolean; + /** + * Sets whether the public is allowed to protect fields in this class. + * + * @param {string[]} fields + */ + setPublicProtectedFields(fields: string[]): void; + /** + * Gets whether the public is allowed to read fields from this class. + * + * @returns {string[]} + */ + getPublicProtectedFields(): string[]; + /** + * Gets whether users belonging to the given role are allowed + * to read from this class. Even if this returns false, the role may + * still be able to write it if a parent role has read access. + * + * @param role The name of the role, or a Parse.Role object. + * @returns {boolean} true if the role has read access. false otherwise. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + getRoleReadAccess(role: ParseRole | string): boolean; + /** + * Gets whether users belonging to the given role are allowed + * to write to this user. Even if this returns false, the role may + * still be able to write it if a parent role has write access. + * + * @param role The name of the role, or a Parse.Role object. + * @returns {boolean} true if the role has write access. false otherwise. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + getRoleWriteAccess(role: ParseRole | string): boolean; + /** + * Sets whether users belonging to the given role are allowed + * to read from this class. + * + * @param role The name of the role, or a Parse.Role object. + * @param {boolean} allowed Whether the given role can read this object. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + setRoleReadAccess(role: ParseRole | string, allowed: boolean): void; + /** + * Sets whether users belonging to the given role are allowed + * to write to this class. + * + * @param role The name of the role, or a Parse.Role object. + * @param {boolean} allowed Whether the given role can write this object. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + setRoleWriteAccess(role: ParseRole | string, allowed: boolean): void; + /** + * Gets whether users belonging to the given role are allowed + * to count to this user. Even if this returns false, the role may + * still be able to count it if a parent role has count access. + * + * @param role The name of the role, or a Parse.Role object. + * @returns {string[]} + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + getRoleProtectedFields(role: ParseRole | string): string[]; + /** + * Sets whether users belonging to the given role are allowed + * to set access field in this class. + * + * @param role The name of the role, or a Parse.Role object. + * @param {string[]} fields Fields to be protected by Role. + * @throws {TypeError} If role is neither a Parse.Role nor a String. + */ + setRoleProtectedFields(role: ParseRole | string, fields: string[]): void; } export default ParseCLP; diff --git a/types/ParseConfig.d.ts b/types/ParseConfig.d.ts index a4fb48d07..cfd77f36d 100644 --- a/types/ParseConfig.d.ts +++ b/types/ParseConfig.d.ts @@ -6,75 +6,72 @@ import type { RequestOptions } from './RESTController'; * @alias Parse.Config */ declare class ParseConfig { - attributes: { - [key: string]: any; - }; - _escapedAttributes: { - [key: string]: any; - }; - constructor(); - /** - * Gets the value of an attribute. - * - * @param {string} attr The name of an attribute. - * @returns {*} - */ - get(attr: string): any; - /** - * Gets the HTML-escaped value of an attribute. - * - * @param {string} attr The name of an attribute. - * @returns {string} - */ - escape(attr: string): string; - /** - * Retrieves the most recently-fetched configuration object, either from - * memory or from local storage if necessary. - * - * @static - * @returns {Parse.Config} The most recently-fetched Parse.Config if it - * exists, else an empty Parse.Config. - */ - static current(): ParseConfig | Promise; - /** - * Gets a new configuration object from the server. - * - * @static - * @param {object} options - * Valid options are:
    - *
  • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
- * @returns {Promise} A promise that is resolved with a newly-created - * configuration object when the get completes. - */ - static get(options?: RequestOptions): Promise; - /** - * Save value keys to the server. - * - * @static - * @param {object} attrs The config parameters and values. - * @param {object} masterKeyOnlyFlags The flags that define whether config parameters listed - * in `attrs` should be retrievable only by using the master key. - * For example: `param1: true` makes `param1` only retrievable by using the master key. - * If a parameter is not provided or set to `false`, it can be retrieved without - * using the master key. - * @returns {Promise} A promise that is resolved with a newly-created - * configuration object or with the current with the update. - */ - static save( - attrs: { - [key: string]: any; - }, - masterKeyOnlyFlags: { - [key: string]: any; - } - ): Promise; - /** - * Used for testing - * - * @private - */ - static _clearCache(): void; + attributes: { + [key: string]: any; + }; + _escapedAttributes: { + [key: string]: any; + }; + constructor(); + /** + * Gets the value of an attribute. + * + * @param {string} attr The name of an attribute. + * @returns {*} + */ + get(attr: string): any; + /** + * Gets the HTML-escaped value of an attribute. + * + * @param {string} attr The name of an attribute. + * @returns {string} + */ + escape(attr: string): string; + /** + * Retrieves the most recently-fetched configuration object, either from + * memory or from local storage if necessary. + * + * @static + * @returns {Parse.Config} The most recently-fetched Parse.Config if it + * exists, else an empty Parse.Config. + */ + static current(): ParseConfig | Promise; + /** + * Gets a new configuration object from the server. + * + * @static + * @param {object} options + * Valid options are:
    + *
  • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
+ * @returns {Promise} A promise that is resolved with a newly-created + * configuration object when the get completes. + */ + static get(options?: RequestOptions): Promise; + /** + * Save value keys to the server. + * + * @static + * @param {object} attrs The config parameters and values. + * @param {object} masterKeyOnlyFlags The flags that define whether config parameters listed + * in `attrs` should be retrievable only by using the master key. + * For example: `param1: true` makes `param1` only retrievable by using the master key. + * If a parameter is not provided or set to `false`, it can be retrieved without + * using the master key. + * @returns {Promise} A promise that is resolved with a newly-created + * configuration object or with the current with the update. + */ + static save(attrs: { + [key: string]: any; + }, masterKeyOnlyFlags: { + [key: string]: any; + }): Promise; + /** + * Used for testing + * + * @private + */ + static _clearCache(): void; } export default ParseConfig; diff --git a/types/ParseError.d.ts b/types/ParseError.d.ts index 5147fd681..f6bbb073f 100644 --- a/types/ParseError.d.ts +++ b/types/ParseError.d.ts @@ -7,470 +7,470 @@ import type ParseObject from './ParseObject'; * @alias Parse.Error */ declare class ParseError extends Error { - code: number; - message: string; - object?: ParseObject; - errors?: Error[]; - /** - * @param {number} code An error code constant from Parse.Error. - * @param {string} message A detailed description of the error. - */ - constructor(code: number, message?: string); - toString(): string; - /** - * Error code indicating some error other than those enumerated here. - * - * @property {number} OTHER_CAUSE - * @static - */ - static OTHER_CAUSE: number; - /** - * Error code indicating that something has gone wrong with the server. - * - * @property {number} INTERNAL_SERVER_ERROR - * @static - */ - static INTERNAL_SERVER_ERROR: number; - /** - * Error code indicating the connection to the Parse servers failed. - * - * @property {number} CONNECTION_FAILED - * @static - */ - static CONNECTION_FAILED: number; - /** - * Error code indicating the specified object doesn't exist. - * - * @property {number} OBJECT_NOT_FOUND - * @static - */ - static OBJECT_NOT_FOUND: number; - /** - * Error code indicating you tried to query with a datatype that doesn't - * support it, like exact matching an array or object. - * - * @property {number} INVALID_QUERY - * @static - */ - static INVALID_QUERY: number; - /** - * Error code indicating a missing or invalid classname. Classnames are - * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the - * only valid characters. - * - * @property {number} INVALID_CLASS_NAME - * @static - */ - static INVALID_CLASS_NAME: number; - /** - * Error code indicating an unspecified object id. - * - * @property {number} MISSING_OBJECT_ID - * @static - */ - static MISSING_OBJECT_ID: number; - /** - * Error code indicating an invalid key name. Keys are case-sensitive. They - * must start with a letter, and a-zA-Z0-9_ are the only valid characters. - * - * @property {number} INVALID_KEY_NAME - * @static - */ - static INVALID_KEY_NAME: number; - /** - * Error code indicating a malformed pointer. You should not see this unless - * you have been mucking about changing internal Parse code. - * - * @property {number} INVALID_POINTER - * @static - */ - static INVALID_POINTER: number; - /** - * Error code indicating that badly formed JSON was received upstream. This - * either indicates you have done something unusual with modifying how - * things encode to JSON, or the network is failing badly. - * - * @property {number} INVALID_JSON - * @static - */ - static INVALID_JSON: number; - /** - * Error code indicating that the feature you tried to access is only - * available internally for testing purposes. - * - * @property {number} COMMAND_UNAVAILABLE - * @static - */ - static COMMAND_UNAVAILABLE: number; - /** - * You must call Parse.initialize before using the Parse library. - * - * @property {number} NOT_INITIALIZED - * @static - */ - static NOT_INITIALIZED: number; - /** - * Error code indicating that a field was set to an inconsistent type. - * - * @property {number} INCORRECT_TYPE - * @static - */ - static INCORRECT_TYPE: number; - /** - * Error code indicating an invalid channel name. A channel name is either - * an empty string (the broadcast channel) or contains only a-zA-Z0-9_ - * characters and starts with a letter. - * - * @property {number} INVALID_CHANNEL_NAME - * @static - */ - static INVALID_CHANNEL_NAME: number; - /** - * Error code indicating that push is misconfigured. - * - * @property {number} PUSH_MISCONFIGURED - * @static - */ - static PUSH_MISCONFIGURED: number; - /** - * Error code indicating that the object is too large. - * - * @property {number} OBJECT_TOO_LARGE - * @static - */ - static OBJECT_TOO_LARGE: number; - /** - * Error code indicating that the operation isn't allowed for clients. - * - * @property {number} OPERATION_FORBIDDEN - * @static - */ - static OPERATION_FORBIDDEN: number; - /** - * Error code indicating the result was not found in the cache. - * - * @property {number} CACHE_MISS - * @static - */ - static CACHE_MISS: number; - /** - * Error code indicating that an invalid key was used in a nested - * JSONObject. - * - * @property {number} INVALID_NESTED_KEY - * @static - */ - static INVALID_NESTED_KEY: number; - /** - * Error code indicating that an invalid filename was used for ParseFile. - * A valid file name contains only a-zA-Z0-9_. characters and is between 1 - * and 128 characters. - * - * @property {number} INVALID_FILE_NAME - * @static - */ - static INVALID_FILE_NAME: number; - /** - * Error code indicating an invalid ACL was provided. - * - * @property {number} INVALID_ACL - * @static - */ - static INVALID_ACL: number; - /** - * Error code indicating that the request timed out on the server. Typically - * this indicates that the request is too expensive to run. - * - * @property {number} TIMEOUT - * @static - */ - static TIMEOUT: number; - /** - * Error code indicating that the email address was invalid. - * - * @property {number} INVALID_EMAIL_ADDRESS - * @static - */ - static INVALID_EMAIL_ADDRESS: number; - /** - * Error code indicating a missing content type. - * - * @property {number} MISSING_CONTENT_TYPE - * @static - */ - static MISSING_CONTENT_TYPE: number; - /** - * Error code indicating a missing content length. - * - * @property {number} MISSING_CONTENT_LENGTH - * @static - */ - static MISSING_CONTENT_LENGTH: number; - /** - * Error code indicating an invalid content length. - * - * @property {number} INVALID_CONTENT_LENGTH - * @static - */ - static INVALID_CONTENT_LENGTH: number; - /** - * Error code indicating a file that was too large. - * - * @property {number} FILE_TOO_LARGE - * @static - */ - static FILE_TOO_LARGE: number; - /** - * Error code indicating an error saving a file. - * - * @property {number} FILE_SAVE_ERROR - * @static - */ - static FILE_SAVE_ERROR: number; - /** - * Error code indicating that a unique field was given a value that is - * already taken. - * - * @property {number} DUPLICATE_VALUE - * @static - */ - static DUPLICATE_VALUE: number; - /** - * Error code indicating that a role's name is invalid. - * - * @property {number} INVALID_ROLE_NAME - * @static - */ - static INVALID_ROLE_NAME: number; - /** - * Error code indicating that an application quota was exceeded. Upgrade to - * resolve. - * - * @property {number} EXCEEDED_QUOTA - * @static - */ - static EXCEEDED_QUOTA: number; - /** - * Error code indicating that a Cloud Code script failed. - * - * @property {number} SCRIPT_FAILED - * @static - */ - static SCRIPT_FAILED: number; - /** - * Error code indicating that a Cloud Code validation failed. - * - * @property {number} VALIDATION_ERROR - * @static - */ - static VALIDATION_ERROR: number; - /** - * Error code indicating that invalid image data was provided. - * - * @property {number} INVALID_IMAGE_DATA - * @static - */ - static INVALID_IMAGE_DATA: number; - /** - * Error code indicating an unsaved file. - * - * @property {number} UNSAVED_FILE_ERROR - * @static - */ - static UNSAVED_FILE_ERROR: number; - /** - * Error code indicating an invalid push time. - * - * @property {number} INVALID_PUSH_TIME_ERROR - * @static - */ - static INVALID_PUSH_TIME_ERROR: number; - /** - * Error code indicating an error deleting a file. - * - * @property {number} FILE_DELETE_ERROR - * @static - */ - static FILE_DELETE_ERROR: number; - /** - * Error code indicating an error deleting an unnamed file. - * - * @property {number} FILE_DELETE_UNNAMED_ERROR - * @static - */ - static FILE_DELETE_UNNAMED_ERROR: number; - /** - * Error code indicating that the application has exceeded its request - * limit. - * - * @property {number} REQUEST_LIMIT_EXCEEDED - * @static - */ - static REQUEST_LIMIT_EXCEEDED: number; - /** - * Error code indicating that the request was a duplicate and has been discarded due to - * idempotency rules. - * - * @property {number} DUPLICATE_REQUEST - * @static - */ - static DUPLICATE_REQUEST: number; - /** - * Error code indicating an invalid event name. - * - * @property {number} INVALID_EVENT_NAME - * @static - */ - static INVALID_EVENT_NAME: number; - /** - * Error code indicating that a field had an invalid value. - * - * @property {number} INVALID_VALUE - * @static - */ - static INVALID_VALUE: number; - /** - * Error code indicating that the username is missing or empty. - * - * @property {number} USERNAME_MISSING - * @static - */ - static USERNAME_MISSING: number; - /** - * Error code indicating that the password is missing or empty. - * - * @property {number} PASSWORD_MISSING - * @static - */ - static PASSWORD_MISSING: number; - /** - * Error code indicating that the username has already been taken. - * - * @property {number} USERNAME_TAKEN - * @static - */ - static USERNAME_TAKEN: number; - /** - * Error code indicating that the email has already been taken. - * - * @property {number} EMAIL_TAKEN - * @static - */ - static EMAIL_TAKEN: number; - /** - * Error code indicating that the email is missing, but must be specified. - * - * @property {number} EMAIL_MISSING - * @static - */ - static EMAIL_MISSING: number; - /** - * Error code indicating that a user with the specified email was not found. - * - * @property {number} EMAIL_NOT_FOUND - * @static - */ - static EMAIL_NOT_FOUND: number; - /** - * Error code indicating that a user object without a valid session could - * not be altered. - * - * @property {number} SESSION_MISSING - * @static - */ - static SESSION_MISSING: number; - /** - * Error code indicating that a user can only be created through signup. - * - * @property {number} MUST_CREATE_USER_THROUGH_SIGNUP - * @static - */ - static MUST_CREATE_USER_THROUGH_SIGNUP: number; - /** - * Error code indicating that an an account being linked is already linked - * to another user. - * - * @property {number} ACCOUNT_ALREADY_LINKED - * @static - */ - static ACCOUNT_ALREADY_LINKED: number; - /** - * Error code indicating that the current session token is invalid. - * - * @property {number} INVALID_SESSION_TOKEN - * @static - */ - static INVALID_SESSION_TOKEN: number; - /** - * Error code indicating an error enabling or verifying MFA - * - * @property {number} MFA_ERROR - * @static - */ - static MFA_ERROR: number; - /** - * Error code indicating that a valid MFA token must be provided - * - * @property {number} MFA_TOKEN_REQUIRED - * @static - */ - static MFA_TOKEN_REQUIRED: number; - /** - * Error code indicating that a user cannot be linked to an account because - * that account's id could not be found. - * - * @property {number} LINKED_ID_MISSING - * @static - */ - static LINKED_ID_MISSING: number; - /** - * Error code indicating that a user with a linked (e.g. Facebook) account - * has an invalid session. - * - * @property {number} INVALID_LINKED_SESSION - * @static - */ - static INVALID_LINKED_SESSION: number; - /** - * Error code indicating that a service being linked (e.g. Facebook or - * Twitter) is unsupported. - * - * @property {number} UNSUPPORTED_SERVICE - * @static - */ - static UNSUPPORTED_SERVICE: number; - /** - * Error code indicating an invalid operation occured on schema - * - * @property {number} INVALID_SCHEMA_OPERATION - * @static - */ - static INVALID_SCHEMA_OPERATION: number; - /** - * Error code indicating that there were multiple errors. Aggregate errors - * have an "errors" property, which is an array of error objects with more - * detail about each error that occurred. - * - * @property {number} AGGREGATE_ERROR - * @static - */ - static AGGREGATE_ERROR: number; - /** - * Error code indicating the client was unable to read an input file. - * - * @property {number} FILE_READ_ERROR - * @static - */ - static FILE_READ_ERROR: number; - /** - * Error code indicating a real error code is unavailable because - * we had to use an XDomainRequest object to allow CORS requests in - * Internet Explorer, which strips the body from HTTP responses that have - * a non-2XX status code. - * - * @property {number} X_DOMAIN_REQUEST - * @static - */ - static X_DOMAIN_REQUEST: number; + code: number; + message: string; + object?: ParseObject; + errors?: Error[]; + /** + * @param {number} code An error code constant from Parse.Error. + * @param {string} message A detailed description of the error. + */ + constructor(code: number, message?: string); + toString(): string; + /** + * Error code indicating some error other than those enumerated here. + * + * @property {number} OTHER_CAUSE + * @static + */ + static OTHER_CAUSE: number; + /** + * Error code indicating that something has gone wrong with the server. + * + * @property {number} INTERNAL_SERVER_ERROR + * @static + */ + static INTERNAL_SERVER_ERROR: number; + /** + * Error code indicating the connection to the Parse servers failed. + * + * @property {number} CONNECTION_FAILED + * @static + */ + static CONNECTION_FAILED: number; + /** + * Error code indicating the specified object doesn't exist. + * + * @property {number} OBJECT_NOT_FOUND + * @static + */ + static OBJECT_NOT_FOUND: number; + /** + * Error code indicating you tried to query with a datatype that doesn't + * support it, like exact matching an array or object. + * + * @property {number} INVALID_QUERY + * @static + */ + static INVALID_QUERY: number; + /** + * Error code indicating a missing or invalid classname. Classnames are + * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the + * only valid characters. + * + * @property {number} INVALID_CLASS_NAME + * @static + */ + static INVALID_CLASS_NAME: number; + /** + * Error code indicating an unspecified object id. + * + * @property {number} MISSING_OBJECT_ID + * @static + */ + static MISSING_OBJECT_ID: number; + /** + * Error code indicating an invalid key name. Keys are case-sensitive. They + * must start with a letter, and a-zA-Z0-9_ are the only valid characters. + * + * @property {number} INVALID_KEY_NAME + * @static + */ + static INVALID_KEY_NAME: number; + /** + * Error code indicating a malformed pointer. You should not see this unless + * you have been mucking about changing internal Parse code. + * + * @property {number} INVALID_POINTER + * @static + */ + static INVALID_POINTER: number; + /** + * Error code indicating that badly formed JSON was received upstream. This + * either indicates you have done something unusual with modifying how + * things encode to JSON, or the network is failing badly. + * + * @property {number} INVALID_JSON + * @static + */ + static INVALID_JSON: number; + /** + * Error code indicating that the feature you tried to access is only + * available internally for testing purposes. + * + * @property {number} COMMAND_UNAVAILABLE + * @static + */ + static COMMAND_UNAVAILABLE: number; + /** + * You must call Parse.initialize before using the Parse library. + * + * @property {number} NOT_INITIALIZED + * @static + */ + static NOT_INITIALIZED: number; + /** + * Error code indicating that a field was set to an inconsistent type. + * + * @property {number} INCORRECT_TYPE + * @static + */ + static INCORRECT_TYPE: number; + /** + * Error code indicating an invalid channel name. A channel name is either + * an empty string (the broadcast channel) or contains only a-zA-Z0-9_ + * characters and starts with a letter. + * + * @property {number} INVALID_CHANNEL_NAME + * @static + */ + static INVALID_CHANNEL_NAME: number; + /** + * Error code indicating that push is misconfigured. + * + * @property {number} PUSH_MISCONFIGURED + * @static + */ + static PUSH_MISCONFIGURED: number; + /** + * Error code indicating that the object is too large. + * + * @property {number} OBJECT_TOO_LARGE + * @static + */ + static OBJECT_TOO_LARGE: number; + /** + * Error code indicating that the operation isn't allowed for clients. + * + * @property {number} OPERATION_FORBIDDEN + * @static + */ + static OPERATION_FORBIDDEN: number; + /** + * Error code indicating the result was not found in the cache. + * + * @property {number} CACHE_MISS + * @static + */ + static CACHE_MISS: number; + /** + * Error code indicating that an invalid key was used in a nested + * JSONObject. + * + * @property {number} INVALID_NESTED_KEY + * @static + */ + static INVALID_NESTED_KEY: number; + /** + * Error code indicating that an invalid filename was used for ParseFile. + * A valid file name contains only a-zA-Z0-9_. characters and is between 1 + * and 128 characters. + * + * @property {number} INVALID_FILE_NAME + * @static + */ + static INVALID_FILE_NAME: number; + /** + * Error code indicating an invalid ACL was provided. + * + * @property {number} INVALID_ACL + * @static + */ + static INVALID_ACL: number; + /** + * Error code indicating that the request timed out on the server. Typically + * this indicates that the request is too expensive to run. + * + * @property {number} TIMEOUT + * @static + */ + static TIMEOUT: number; + /** + * Error code indicating that the email address was invalid. + * + * @property {number} INVALID_EMAIL_ADDRESS + * @static + */ + static INVALID_EMAIL_ADDRESS: number; + /** + * Error code indicating a missing content type. + * + * @property {number} MISSING_CONTENT_TYPE + * @static + */ + static MISSING_CONTENT_TYPE: number; + /** + * Error code indicating a missing content length. + * + * @property {number} MISSING_CONTENT_LENGTH + * @static + */ + static MISSING_CONTENT_LENGTH: number; + /** + * Error code indicating an invalid content length. + * + * @property {number} INVALID_CONTENT_LENGTH + * @static + */ + static INVALID_CONTENT_LENGTH: number; + /** + * Error code indicating a file that was too large. + * + * @property {number} FILE_TOO_LARGE + * @static + */ + static FILE_TOO_LARGE: number; + /** + * Error code indicating an error saving a file. + * + * @property {number} FILE_SAVE_ERROR + * @static + */ + static FILE_SAVE_ERROR: number; + /** + * Error code indicating that a unique field was given a value that is + * already taken. + * + * @property {number} DUPLICATE_VALUE + * @static + */ + static DUPLICATE_VALUE: number; + /** + * Error code indicating that a role's name is invalid. + * + * @property {number} INVALID_ROLE_NAME + * @static + */ + static INVALID_ROLE_NAME: number; + /** + * Error code indicating that an application quota was exceeded. Upgrade to + * resolve. + * + * @property {number} EXCEEDED_QUOTA + * @static + */ + static EXCEEDED_QUOTA: number; + /** + * Error code indicating that a Cloud Code script failed. + * + * @property {number} SCRIPT_FAILED + * @static + */ + static SCRIPT_FAILED: number; + /** + * Error code indicating that a Cloud Code validation failed. + * + * @property {number} VALIDATION_ERROR + * @static + */ + static VALIDATION_ERROR: number; + /** + * Error code indicating that invalid image data was provided. + * + * @property {number} INVALID_IMAGE_DATA + * @static + */ + static INVALID_IMAGE_DATA: number; + /** + * Error code indicating an unsaved file. + * + * @property {number} UNSAVED_FILE_ERROR + * @static + */ + static UNSAVED_FILE_ERROR: number; + /** + * Error code indicating an invalid push time. + * + * @property {number} INVALID_PUSH_TIME_ERROR + * @static + */ + static INVALID_PUSH_TIME_ERROR: number; + /** + * Error code indicating an error deleting a file. + * + * @property {number} FILE_DELETE_ERROR + * @static + */ + static FILE_DELETE_ERROR: number; + /** + * Error code indicating an error deleting an unnamed file. + * + * @property {number} FILE_DELETE_UNNAMED_ERROR + * @static + */ + static FILE_DELETE_UNNAMED_ERROR: number; + /** + * Error code indicating that the application has exceeded its request + * limit. + * + * @property {number} REQUEST_LIMIT_EXCEEDED + * @static + */ + static REQUEST_LIMIT_EXCEEDED: number; + /** + * Error code indicating that the request was a duplicate and has been discarded due to + * idempotency rules. + * + * @property {number} DUPLICATE_REQUEST + * @static + */ + static DUPLICATE_REQUEST: number; + /** + * Error code indicating an invalid event name. + * + * @property {number} INVALID_EVENT_NAME + * @static + */ + static INVALID_EVENT_NAME: number; + /** + * Error code indicating that a field had an invalid value. + * + * @property {number} INVALID_VALUE + * @static + */ + static INVALID_VALUE: number; + /** + * Error code indicating that the username is missing or empty. + * + * @property {number} USERNAME_MISSING + * @static + */ + static USERNAME_MISSING: number; + /** + * Error code indicating that the password is missing or empty. + * + * @property {number} PASSWORD_MISSING + * @static + */ + static PASSWORD_MISSING: number; + /** + * Error code indicating that the username has already been taken. + * + * @property {number} USERNAME_TAKEN + * @static + */ + static USERNAME_TAKEN: number; + /** + * Error code indicating that the email has already been taken. + * + * @property {number} EMAIL_TAKEN + * @static + */ + static EMAIL_TAKEN: number; + /** + * Error code indicating that the email is missing, but must be specified. + * + * @property {number} EMAIL_MISSING + * @static + */ + static EMAIL_MISSING: number; + /** + * Error code indicating that a user with the specified email was not found. + * + * @property {number} EMAIL_NOT_FOUND + * @static + */ + static EMAIL_NOT_FOUND: number; + /** + * Error code indicating that a user object without a valid session could + * not be altered. + * + * @property {number} SESSION_MISSING + * @static + */ + static SESSION_MISSING: number; + /** + * Error code indicating that a user can only be created through signup. + * + * @property {number} MUST_CREATE_USER_THROUGH_SIGNUP + * @static + */ + static MUST_CREATE_USER_THROUGH_SIGNUP: number; + /** + * Error code indicating that an an account being linked is already linked + * to another user. + * + * @property {number} ACCOUNT_ALREADY_LINKED + * @static + */ + static ACCOUNT_ALREADY_LINKED: number; + /** + * Error code indicating that the current session token is invalid. + * + * @property {number} INVALID_SESSION_TOKEN + * @static + */ + static INVALID_SESSION_TOKEN: number; + /** + * Error code indicating an error enabling or verifying MFA + * + * @property {number} MFA_ERROR + * @static + */ + static MFA_ERROR: number; + /** + * Error code indicating that a valid MFA token must be provided + * + * @property {number} MFA_TOKEN_REQUIRED + * @static + */ + static MFA_TOKEN_REQUIRED: number; + /** + * Error code indicating that a user cannot be linked to an account because + * that account's id could not be found. + * + * @property {number} LINKED_ID_MISSING + * @static + */ + static LINKED_ID_MISSING: number; + /** + * Error code indicating that a user with a linked (e.g. Facebook) account + * has an invalid session. + * + * @property {number} INVALID_LINKED_SESSION + * @static + */ + static INVALID_LINKED_SESSION: number; + /** + * Error code indicating that a service being linked (e.g. Facebook or + * Twitter) is unsupported. + * + * @property {number} UNSUPPORTED_SERVICE + * @static + */ + static UNSUPPORTED_SERVICE: number; + /** + * Error code indicating an invalid operation occured on schema + * + * @property {number} INVALID_SCHEMA_OPERATION + * @static + */ + static INVALID_SCHEMA_OPERATION: number; + /** + * Error code indicating that there were multiple errors. Aggregate errors + * have an "errors" property, which is an array of error objects with more + * detail about each error that occurred. + * + * @property {number} AGGREGATE_ERROR + * @static + */ + static AGGREGATE_ERROR: number; + /** + * Error code indicating the client was unable to read an input file. + * + * @property {number} FILE_READ_ERROR + * @static + */ + static FILE_READ_ERROR: number; + /** + * Error code indicating a real error code is unavailable because + * we had to use an XDomainRequest object to allow CORS requests in + * Internet Explorer, which strips the body from HTTP responses that have + * a non-2XX status code. + * + * @property {number} X_DOMAIN_REQUEST + * @static + */ + static X_DOMAIN_REQUEST: number; } export default ParseError; diff --git a/types/ParseFile.d.ts b/types/ParseFile.d.ts index d7eab6ba3..611736f58 100644 --- a/types/ParseFile.d.ts +++ b/types/ParseFile.d.ts @@ -1,35 +1,32 @@ import type { FullOptions } from './RESTController'; type Base64 = { - base64: string; + base64: string; }; type Uri = { - uri: string; + uri: string; }; type FileData = Array | Base64 | Blob | Uri; export type FileSaveOptions = FullOptions & { - metadata?: { - [key: string]: any; - }; - tags?: { - [key: string]: any; - }; -}; -export type FileSource = - | { - format: 'file'; - file: Blob; - type: string | undefined; - } - | { - format: 'base64'; - base64: string; - type: string | undefined; - } - | { - format: 'uri'; - uri: string; - type: string | undefined; + metadata?: { + [key: string]: any; + }; + tags?: { + [key: string]: any; }; +}; +export type FileSource = { + format: 'file'; + file: Blob; + type: string | undefined; +} | { + format: 'base64'; + base64: string; + type: string | undefined; +} | { + format: 'uri'; + uri: string; + type: string | undefined; +}; /** * A Parse.File is a local representation of a file that is saved to the Parse * cloud. @@ -37,159 +34,159 @@ export type FileSource = * @alias Parse.File */ declare class ParseFile { - _name: string; - _url?: string; - _source: FileSource; - _previousSave?: Promise; - _data?: string; - _requestTask?: any; - _metadata?: object; - _tags?: object; - /** - * @param name {String} The file's name. This will be prefixed by a unique - * value once the file has finished saving. The file name must begin with - * an alphanumeric character, and consist of alphanumeric characters, - * periods, spaces, underscores, or dashes. - * @param data {Array} The data for the file, as either: - * 1. an Array of byte value Numbers, or - * 2. an Object like { base64: "..." } with a base64-encoded String. - * 3. an Object like { uri: "..." } with a uri String. - * 4. a File object selected with a file upload control. (3) only works - * in Firefox 3.6+, Safari 6.0.2+, Chrome 7+, and IE 10+. - * For example: - *
-   * var fileUploadControl = $("#profilePhotoFileUpload")[0];
-   * if (fileUploadControl.files.length > 0) {
-   *   var file = fileUploadControl.files[0];
-   *   var name = "photo.jpg";
-   *   var parseFile = new Parse.File(name, file);
-   *   parseFile.save().then(function() {
-   *     // The file has been saved to Parse.
-   *   }, function(error) {
-   *     // The file either could not be read, or could not be saved to Parse.
-   *   });
-   * }
- * @param type {String} Optional Content-Type header to use for the file. If - * this is omitted, the content type will be inferred from the name's - * extension. - * @param metadata {object} Optional key value pairs to be stored with file object - * @param tags {object} Optional key value pairs to be stored with file object - */ - constructor(name: string, data?: FileData, type?: string, metadata?: object, tags?: object); - /** - * Return the data for the file, downloading it if not already present. - * Data is present if initialized with Byte Array, Base64 or Saved with Uri. - * Data is cleared if saved with File object selected with a file upload control - * - * @returns {Promise} Promise that is resolve with base64 data - */ - getData(): Promise; - /** - * Gets the name of the file. Before save is called, this is the filename - * given by the user. After save is called, that name gets prefixed with a - * unique identifier. - * - * @returns {string} - */ - name(): string; - /** - * Gets the url of the file. It is only available after you save the file or - * after you get the file from a Parse.Object. - * - * @param {object} options An object to specify url options - * @param {boolean} [options.forceSecure] force the url to be secure - * @returns {string | undefined} - */ - url(options?: { forceSecure?: boolean }): string | undefined; - /** - * Gets the metadata of the file. - * - * @returns {object} - */ - metadata(): object; - /** - * Gets the tags of the file. - * - * @returns {object} - */ - tags(): object; - /** - * Saves the file to the Parse cloud. - * - * @param {object} options - * Valid options are:
    - *
  • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
  • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
  • progress: In Browser only, callback for upload progress. For example: - *
    -   * let parseFile = new Parse.File(name, file);
    -   * parseFile.save({
    -   *   progress: (progressValue, loaded, total, { type }) => {
    -   *     if (type === "upload" && progressValue !== null) {
    -   *       // Update the UI using progressValue
    -   *     }
    -   *   }
    -   * });
    -   * 
    - *
- * @returns {Promise | undefined} Promise that is resolved when the save finishes. - */ - save( - options?: FileSaveOptions & { - requestTask?: any; - } - ): Promise | undefined; - /** - * Aborts the request if it has already been sent. - */ - cancel(): void; - /** - * Deletes the file from the Parse cloud. - * In Cloud Code and Node only with Master Key. - * - * @param {object} options - * Valid options are:
    - *
  • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    -   * @returns {Promise} Promise that is resolved when the delete finishes.
    -   */
    -  destroy(options?: FullOptions): Promise;
    -  toJSON(): {
    -    __type: 'File';
    -    name?: string;
    -    url?: string;
    -  };
    -  equals(other: any): boolean;
    -  /**
    -   * Sets metadata to be saved with file object. Overwrites existing metadata
    -   *
    -   * @param {object} metadata Key value pairs to be stored with file object
    -   */
    -  setMetadata(metadata: any): void;
    -  /**
    -   * Sets metadata to be saved with file object. Adds to existing metadata.
    -   *
    -   * @param {string} key key to store the metadata
    -   * @param {*} value metadata
    -   */
    -  addMetadata(key: string, value: any): void;
    -  /**
    -   * Sets tags to be saved with file object. Overwrites existing tags
    -   *
    -   * @param {object} tags Key value pairs to be stored with file object
    -   */
    -  setTags(tags: any): void;
    -  /**
    -   * Sets tags to be saved with file object. Adds to existing tags.
    -   *
    -   * @param {string} key key to store tags
    -   * @param {*} value tag
    -   */
    -  addTag(key: string, value: string): void;
    -  static fromJSON(obj: any): ParseFile;
    -  static encodeBase64(bytes: Array | Uint8Array): string;
    +    _name: string;
    +    _url?: string;
    +    _source: FileSource;
    +    _previousSave?: Promise;
    +    _data?: string;
    +    _requestTask?: any;
    +    _metadata?: object;
    +    _tags?: object;
    +    /**
    +     * @param name {String} The file's name. This will be prefixed by a unique
    +     *     value once the file has finished saving. The file name must begin with
    +     *     an alphanumeric character, and consist of alphanumeric characters,
    +     *     periods, spaces, underscores, or dashes.
    +     * @param data {Array} The data for the file, as either:
    +     *     1. an Array of byte value Numbers, or
    +     *     2. an Object like { base64: "..." } with a base64-encoded String.
    +     *     3. an Object like { uri: "..." } with a uri String.
    +     *     4. a File object selected with a file upload control. (3) only works
    +     *        in Firefox 3.6+, Safari 6.0.2+, Chrome 7+, and IE 10+.
    +     *        For example:
    +     * 
    +     * var fileUploadControl = $("#profilePhotoFileUpload")[0];
    +     * if (fileUploadControl.files.length > 0) {
    +     *   var file = fileUploadControl.files[0];
    +     *   var name = "photo.jpg";
    +     *   var parseFile = new Parse.File(name, file);
    +     *   parseFile.save().then(function() {
    +     *     // The file has been saved to Parse.
    +     *   }, function(error) {
    +     *     // The file either could not be read, or could not be saved to Parse.
    +     *   });
    +     * }
    + * @param type {String} Optional Content-Type header to use for the file. If + * this is omitted, the content type will be inferred from the name's + * extension. + * @param metadata {object} Optional key value pairs to be stored with file object + * @param tags {object} Optional key value pairs to be stored with file object + */ + constructor(name: string, data?: FileData, type?: string, metadata?: object, tags?: object); + /** + * Return the data for the file, downloading it if not already present. + * Data is present if initialized with Byte Array, Base64 or Saved with Uri. + * Data is cleared if saved with File object selected with a file upload control + * + * @returns {Promise} Promise that is resolve with base64 data + */ + getData(): Promise; + /** + * Gets the name of the file. Before save is called, this is the filename + * given by the user. After save is called, that name gets prefixed with a + * unique identifier. + * + * @returns {string} + */ + name(): string; + /** + * Gets the url of the file. It is only available after you save the file or + * after you get the file from a Parse.Object. + * + * @param {object} options An object to specify url options + * @param {boolean} [options.forceSecure] force the url to be secure + * @returns {string | undefined} + */ + url(options?: { + forceSecure?: boolean; + }): string | undefined; + /** + * Gets the metadata of the file. + * + * @returns {object} + */ + metadata(): object; + /** + * Gets the tags of the file. + * + * @returns {object} + */ + tags(): object; + /** + * Saves the file to the Parse cloud. + * + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • progress: In Browser only, callback for upload progress. For example: + *
      +     * let parseFile = new Parse.File(name, file);
      +     * parseFile.save({
      +     *   progress: (progressValue, loaded, total, { type }) => {
      +     *     if (type === "upload" && progressValue !== null) {
      +     *       // Update the UI using progressValue
      +     *     }
      +     *   }
      +     * });
      +     * 
      + *
    + * @returns {Promise | undefined} Promise that is resolved when the save finishes. + */ + save(options?: FileSaveOptions & { + requestTask?: any; + }): Promise | undefined; + /** + * Aborts the request if it has already been sent. + */ + cancel(): void; + /** + * Deletes the file from the Parse cloud. + * In Cloud Code and Node only with Master Key. + * + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
      +     * @returns {Promise} Promise that is resolved when the delete finishes.
      +     */
      +    destroy(options?: FullOptions): Promise;
      +    toJSON(): {
      +        __type: 'File';
      +        name?: string;
      +        url?: string;
      +    };
      +    equals(other: any): boolean;
      +    /**
      +     * Sets metadata to be saved with file object. Overwrites existing metadata
      +     *
      +     * @param {object} metadata Key value pairs to be stored with file object
      +     */
      +    setMetadata(metadata: any): void;
      +    /**
      +     * Sets metadata to be saved with file object. Adds to existing metadata.
      +     *
      +     * @param {string} key key to store the metadata
      +     * @param {*} value metadata
      +     */
      +    addMetadata(key: string, value: any): void;
      +    /**
      +     * Sets tags to be saved with file object. Overwrites existing tags
      +     *
      +     * @param {object} tags Key value pairs to be stored with file object
      +     */
      +    setTags(tags: any): void;
      +    /**
      +     * Sets tags to be saved with file object. Adds to existing tags.
      +     *
      +     * @param {string} key key to store tags
      +     * @param {*} value tag
      +     */
      +    addTag(key: string, value: string): void;
      +    static fromJSON(obj: any): ParseFile;
      +    static encodeBase64(bytes: Array | Uint8Array): string;
       }
       export default ParseFile;
      diff --git a/types/ParseGeoPoint.d.ts b/types/ParseGeoPoint.d.ts
      index 7c2c6b432..b982b7f75 100644
      --- a/types/ParseGeoPoint.d.ts
      +++ b/types/ParseGeoPoint.d.ts
      @@ -22,89 +22,83 @@
        * @alias Parse.GeoPoint
        */
       declare class ParseGeoPoint {
      -  _latitude: number;
      -  _longitude: number;
      -  /**
      -   * @param {(number[] | object | number)} arg1 Either a list of coordinate pairs, an object with `latitude`, `longitude`, or the latitude or the point.
      -   * @param {number} arg2 The longitude of the GeoPoint
      -   */
      -  constructor(
      -    arg1:
      -      | Array
      -      | {
      -          latitude: number;
      -          longitude: number;
      -        }
      -      | number,
      -    arg2?: number
      -  );
      -  /**
      -   * North-south portion of the coordinate, in range [-90, 90].
      -   * Throws an exception if set out of range in a modern browser.
      -   *
      -   * @property {number} latitude
      -   * @returns {number}
      -   */
      -  get latitude(): number;
      -  set latitude(val: number);
      -  /**
      -   * East-west portion of the coordinate, in range [-180, 180].
      -   * Throws if set out of range in a modern browser.
      -   *
      -   * @property {number} longitude
      -   * @returns {number}
      -   */
      -  get longitude(): number;
      -  set longitude(val: number);
      -  /**
      -   * Returns a JSON representation of the GeoPoint, suitable for Parse.
      -   *
      -   * @returns {object}
      -   */
      -  toJSON(): {
      -    __type: string;
      -    latitude: number;
      -    longitude: number;
      -  };
      -  equals(other: any): boolean;
      -  /**
      -   * Returns the distance from this GeoPoint to another in radians.
      -   *
      -   * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
      -   * @returns {number}
      -   */
      -  radiansTo(point: ParseGeoPoint): number;
      -  /**
      -   * Returns the distance from this GeoPoint to another in kilometers.
      -   *
      -   * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
      -   * @returns {number}
      -   */
      -  kilometersTo(point: ParseGeoPoint): number;
      -  /**
      -   * Returns the distance from this GeoPoint to another in miles.
      -   *
      -   * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
      -   * @returns {number}
      -   */
      -  milesTo(point: ParseGeoPoint): number;
      -  static _validate(latitude: number, longitude: number): void;
      -  /**
      -   * Creates a GeoPoint with the user's current location, if available.
      -   *
      -   * @param {object} options The options.
      -   * @param {boolean} [options.enableHighAccuracy] A boolean value that indicates the application would like to receive the best possible results.
      -   *  If true and if the device is able to provide a more accurate position, it will do so.
      -   *  Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example).
      -   *  On the other hand, if false, the device can take the liberty to save resources by responding more quickly and/or using less power. Default: false.
      -   * @param {number} [options.timeout] A positive long value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position.
      -   *  The default value is Infinity, meaning that getCurrentPosition() won't return until the position is available.
      -   * @param {number} [options.maximumAge] A positive long value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return.
      -   *  If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position.
      -   *  If set to Infinity the device must return a cached position regardless of its age. Default: 0.
      -   * @static
      -   * @returns {Promise} User's current location
      -   */
      -  static current(options: any): Promise;
      +    _latitude: number;
      +    _longitude: number;
      +    /**
      +     * @param {(number[] | object | number)} arg1 Either a list of coordinate pairs, an object with `latitude`, `longitude`, or the latitude or the point.
      +     * @param {number} arg2 The longitude of the GeoPoint
      +     */
      +    constructor(arg1: Array | {
      +        latitude: number;
      +        longitude: number;
      +    } | number, arg2?: number);
      +    /**
      +     * North-south portion of the coordinate, in range [-90, 90].
      +     * Throws an exception if set out of range in a modern browser.
      +     *
      +     * @property {number} latitude
      +     * @returns {number}
      +     */
      +    get latitude(): number;
      +    set latitude(val: number);
      +    /**
      +     * East-west portion of the coordinate, in range [-180, 180].
      +     * Throws if set out of range in a modern browser.
      +     *
      +     * @property {number} longitude
      +     * @returns {number}
      +     */
      +    get longitude(): number;
      +    set longitude(val: number);
      +    /**
      +     * Returns a JSON representation of the GeoPoint, suitable for Parse.
      +     *
      +     * @returns {object}
      +     */
      +    toJSON(): {
      +        __type: string;
      +        latitude: number;
      +        longitude: number;
      +    };
      +    equals(other: any): boolean;
      +    /**
      +     * Returns the distance from this GeoPoint to another in radians.
      +     *
      +     * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
      +     * @returns {number}
      +     */
      +    radiansTo(point: ParseGeoPoint): number;
      +    /**
      +     * Returns the distance from this GeoPoint to another in kilometers.
      +     *
      +     * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
      +     * @returns {number}
      +     */
      +    kilometersTo(point: ParseGeoPoint): number;
      +    /**
      +     * Returns the distance from this GeoPoint to another in miles.
      +     *
      +     * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
      +     * @returns {number}
      +     */
      +    milesTo(point: ParseGeoPoint): number;
      +    static _validate(latitude: number, longitude: number): void;
      +    /**
      +     * Creates a GeoPoint with the user's current location, if available.
      +     *
      +     * @param {object} options The options.
      +     * @param {boolean} [options.enableHighAccuracy] A boolean value that indicates the application would like to receive the best possible results.
      +     *  If true and if the device is able to provide a more accurate position, it will do so.
      +     *  Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example).
      +     *  On the other hand, if false, the device can take the liberty to save resources by responding more quickly and/or using less power. Default: false.
      +     * @param {number} [options.timeout] A positive long value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position.
      +     *  The default value is Infinity, meaning that getCurrentPosition() won't return until the position is available.
      +     * @param {number} [options.maximumAge] A positive long value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return.
      +     *  If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position.
      +     *  If set to Infinity the device must return a cached position regardless of its age. Default: 0.
      +     * @static
      +     * @returns {Promise} User's current location
      +     */
      +    static current(options: any): Promise;
       }
       export default ParseGeoPoint;
      diff --git a/types/ParseHooks.d.ts b/types/ParseHooks.d.ts
      index 525af90dc..e854b0d76 100644
      --- a/types/ParseHooks.d.ts
      +++ b/types/ParseHooks.d.ts
      @@ -1,38 +1,26 @@
      -export type HookDeclaration =
      -  | {
      -      functionName: string;
      -      url: string;
      -    }
      -  | {
      -      className: string;
      -      triggerName: string;
      -      url: string;
      -    };
      -export type HookDeleteArg =
      -  | {
      -      functionName: string;
      -    }
      -  | {
      -      className: string;
      -      triggerName: string;
      -    };
      +export type HookDeclaration = {
      +    functionName: string;
      +    url: string;
      +} | {
      +    className: string;
      +    triggerName: string;
      +    url: string;
      +};
      +export type HookDeleteArg = {
      +    functionName: string;
      +} | {
      +    className: string;
      +    triggerName: string;
      +};
       export declare function getFunctions(): Promise;
       export declare function getTriggers(): Promise;
       export declare function getFunction(name: string): Promise;
       export declare function getTrigger(className: string, triggerName: string): Promise;
       export declare function createFunction(functionName: string, url: string): Promise;
      -export declare function createTrigger(
      -  className: string,
      -  triggerName: string,
      -  url: string
      -): Promise;
      +export declare function createTrigger(className: string, triggerName: string, url: string): Promise;
       export declare function create(hook: HookDeclaration): Promise;
       export declare function updateFunction(functionName: string, url: string): Promise;
      -export declare function updateTrigger(
      -  className: string,
      -  triggerName: string,
      -  url: string
      -): Promise;
      +export declare function updateTrigger(className: string, triggerName: string, url: string): Promise;
       export declare function update(hook: HookDeclaration): Promise;
       export declare function removeFunction(functionName: string): Promise;
       export declare function removeTrigger(className: string, triggerName: string): Promise;
      diff --git a/types/ParseInstallation.d.ts b/types/ParseInstallation.d.ts
      index 1743dce1d..2f07cd594 100644
      --- a/types/ParseInstallation.d.ts
      +++ b/types/ParseInstallation.d.ts
      @@ -1,12 +1,12 @@
       import ParseObject from './ParseObject';
       import type { AttributeMap } from './ObjectStateMutations';
       type DeviceInterface = {
      -  IOS: string;
      -  MACOS: string;
      -  TVOS: string;
      -  FCM: string;
      -  ANDROID: string;
      -  WEB: string;
      +    IOS: string;
      +    MACOS: string;
      +    TVOS: string;
      +    FCM: string;
      +    ANDROID: string;
      +    WEB: string;
       };
       /**
        * Parse.Installation is a local representation of installation data that can be saved and retrieved from the Parse cloud.
      @@ -20,161 +20,161 @@ type DeviceInterface = {
        * @alias Parse.Installation
        */
       declare class ParseInstallation extends ParseObject {
      -  /**
      -   * @param {object} attributes The initial set of data to store in the object.
      -   */
      -  constructor(attributes?: AttributeMap);
      -  /**
      -   * A unique identifier for this installation’s client application. In iOS, this is the Bundle Identifier.
      -   *
      -   * @property {string} appIdentifier
      -   * @static
      -   * @returns {string}
      -   */
      -  get appIdentifier(): any;
      -  /**
      -   * The version string of the client application to which this installation belongs.
      -   *
      -   * @property {string} appVersion
      -   * @static
      -   * @returns {string}
      -   */
      -  get appVersion(): any;
      -  /**
      -   * The display name of the client application to which this installation belongs.
      -   *
      -   * @property {string} appName
      -   * @static
      -   * @returns {string}
      -   */
      -  get appName(): any;
      -  /**
      -   * The current value of the icon badge for iOS apps.
      -   * Changes to this value on the server will be used
      -   * for future badge-increment push notifications.
      -   *
      -   * @property {number} badge
      -   * @static
      -   * @returns {number}
      -   */
      -  get badge(): any;
      -  /**
      -   * An array of the channels to which a device is currently subscribed.
      -   *
      -   * @property {string[]} channels
      -   * @static
      -   * @returns {string[]}
      -   */
      -  get channels(): any;
      -  /**
      -   * Token used to deliver push notifications to the device.
      -   *
      -   * @property {string} deviceToken
      -   * @static
      -   * @returns {string}
      -   */
      -  get deviceToken(): any;
      -  /**
      -   * The type of device, “ios”, “android”, “web”, etc.
      -   *
      -   * @property {string} deviceType
      -   * @static
      -   * @returns {string}
      -   */
      -  get deviceType(): any;
      -  /**
      -   * Gets the GCM sender identifier for this installation
      -   *
      -   * @property {string} GCMSenderId
      -   * @static
      -   * @returns {string}
      -   */
      -  get GCMSenderId(): any;
      -  /**
      -   * Universally Unique Identifier (UUID) for the device used by Parse. It must be unique across all of an app’s installations.
      -   *
      -   * @property {string} installationId
      -   * @static
      -   * @returns {string}
      -   */
      -  get installationId(): any;
      -  /**
      -   * Gets the local identifier for this installation
      -   *
      -   * @property {string} localeIdentifier
      -   * @static
      -   * @returns {string}
      -   */
      -  get localeIdentifier(): any;
      -  /**
      -   * Gets the parse server version for this installation
      -   *
      -   * @property {string} parseVersion
      -   * @static
      -   * @returns {string}
      -   */
      -  get parseVersion(): any;
      -  /**
      -   * This field is reserved for directing Parse to the push delivery network to be used.
      -   *
      -   * @property {string} pushType
      -   * @static
      -   * @returns {string}
      -   */
      -  get pushType(): any;
      -  /**
      -   * Gets the time zone for this installation
      -   *
      -   * @property {string} timeZone
      -   * @static
      -   * @returns {string}
      -   */
      -  get timeZone(): any;
      -  /**
      -   * Returns the device types for used for Push Notifications.
      -   *
      -   * 
      -   * Parse.Installation.DEVICE_TYPES.IOS
      -   * Parse.Installation.DEVICE_TYPES.MACOS
      -   * Parse.Installation.DEVICE_TYPES.TVOS
      -   * Parse.Installation.DEVICE_TYPES.FCM
      -   * Parse.Installation.DEVICE_TYPES.ANDROID
      -   * Parse.Installation.DEVICE_TYPES.WEB
      -   * 
      ): Promise; - /** - * Wrap the default save behavior with functionality to update the local storage. - * If the installation is deleted on the server, retry saving a new installation. - * - * @param {...any} args - * @returns {Promise} - */ - save(...args: Array): Promise; - _markAllFieldsDirty(): void; - /** - * Get the current Parse.Installation from disk. If doesn't exists, create an new installation. - * - *
      -   * const installation = await Parse.Installation.currentInstallation();
      -   * installation.set('deviceToken', '123');
      -   * await installation.save();
      -   * 
      - * - * @returns {Promise} A promise that resolves to the local installation object. - */ - static currentInstallation(): Promise; + /** + * @param {object} attributes The initial set of data to store in the object. + */ + constructor(attributes?: AttributeMap); + /** + * A unique identifier for this installation’s client application. In iOS, this is the Bundle Identifier. + * + * @property {string} appIdentifier + * @static + * @returns {string} + */ + get appIdentifier(): any; + /** + * The version string of the client application to which this installation belongs. + * + * @property {string} appVersion + * @static + * @returns {string} + */ + get appVersion(): any; + /** + * The display name of the client application to which this installation belongs. + * + * @property {string} appName + * @static + * @returns {string} + */ + get appName(): any; + /** + * The current value of the icon badge for iOS apps. + * Changes to this value on the server will be used + * for future badge-increment push notifications. + * + * @property {number} badge + * @static + * @returns {number} + */ + get badge(): any; + /** + * An array of the channels to which a device is currently subscribed. + * + * @property {string[]} channels + * @static + * @returns {string[]} + */ + get channels(): any; + /** + * Token used to deliver push notifications to the device. + * + * @property {string} deviceToken + * @static + * @returns {string} + */ + get deviceToken(): any; + /** + * The type of device, “ios”, “android”, “web”, etc. + * + * @property {string} deviceType + * @static + * @returns {string} + */ + get deviceType(): any; + /** + * Gets the GCM sender identifier for this installation + * + * @property {string} GCMSenderId + * @static + * @returns {string} + */ + get GCMSenderId(): any; + /** + * Universally Unique Identifier (UUID) for the device used by Parse. It must be unique across all of an app’s installations. + * + * @property {string} installationId + * @static + * @returns {string} + */ + get installationId(): any; + /** + * Gets the local identifier for this installation + * + * @property {string} localeIdentifier + * @static + * @returns {string} + */ + get localeIdentifier(): any; + /** + * Gets the parse server version for this installation + * + * @property {string} parseVersion + * @static + * @returns {string} + */ + get parseVersion(): any; + /** + * This field is reserved for directing Parse to the push delivery network to be used. + * + * @property {string} pushType + * @static + * @returns {string} + */ + get pushType(): any; + /** + * Gets the time zone for this installation + * + * @property {string} timeZone + * @static + * @returns {string} + */ + get timeZone(): any; + /** + * Returns the device types for used for Push Notifications. + * + *
      +     * Parse.Installation.DEVICE_TYPES.IOS
      +     * Parse.Installation.DEVICE_TYPES.MACOS
      +     * Parse.Installation.DEVICE_TYPES.TVOS
      +     * Parse.Installation.DEVICE_TYPES.FCM
      +     * Parse.Installation.DEVICE_TYPES.ANDROID
      +     * Parse.Installation.DEVICE_TYPES.WEB
      +     * 
      ): Promise; + /** + * Wrap the default save behavior with functionality to update the local storage. + * If the installation is deleted on the server, retry saving a new installation. + * + * @param {...any} args + * @returns {Promise} + */ + save(...args: Array): Promise; + _markAllFieldsDirty(): void; + /** + * Get the current Parse.Installation from disk. If doesn't exists, create an new installation. + * + *
      +     * const installation = await Parse.Installation.currentInstallation();
      +     * installation.set('deviceToken', '123');
      +     * await installation.save();
      +     * 
      + * + * @returns {Promise} A promise that resolves to the local installation object. + */ + static currentInstallation(): Promise; } export default ParseInstallation; diff --git a/types/ParseLiveQuery.d.ts b/types/ParseLiveQuery.d.ts index ac9aa3495..68dd9893e 100644 --- a/types/ParseLiveQuery.d.ts +++ b/types/ParseLiveQuery.d.ts @@ -26,22 +26,22 @@ * @static */ declare class LiveQuery { - emitter: any; - on: any; - emit: any; - constructor(); - /** - * After open is called, the LiveQuery will try to send a connect request - * to the LiveQuery server. - */ - open(): Promise; - /** - * When you're done using LiveQuery, you can call Parse.LiveQuery.close(). - * This function will close the WebSocket connection to the LiveQuery server, - * cancel the auto reconnect, and unsubscribe all subscriptions based on it. - * If you call query.subscribe() after this, we'll create a new WebSocket - * connection to the LiveQuery server. - */ - close(): Promise; + emitter: any; + on: any; + emit: any; + constructor(); + /** + * After open is called, the LiveQuery will try to send a connect request + * to the LiveQuery server. + */ + open(): Promise; + /** + * When you're done using LiveQuery, you can call Parse.LiveQuery.close(). + * This function will close the WebSocket connection to the LiveQuery server, + * cancel the auto reconnect, and unsubscribe all subscriptions based on it. + * If you call query.subscribe() after this, we'll create a new WebSocket + * connection to the LiveQuery server. + */ + close(): Promise; } export default LiveQuery; diff --git a/types/ParseObject.d.ts b/types/ParseObject.d.ts index 7b49bfce2..fbf2e5c58 100644 --- a/types/ParseObject.d.ts +++ b/types/ParseObject.d.ts @@ -6,27 +6,27 @@ import ParseRelation from './ParseRelation'; import type { AttributeMap, OpsMap } from './ObjectStateMutations'; import type { RequestOptions, FullOptions } from './RESTController'; export type Pointer = { - __type: string; - className: string; - objectId?: string; - _localId?: string; + __type: string; + className: string; + objectId?: string; + _localId?: string; }; type SaveParams = { - method: string; - path: string; - body: AttributeMap; + method: string; + path: string; + body: AttributeMap; }; export type SaveOptions = FullOptions & { - cascadeSave?: boolean; - context?: AttributeMap; - batchSize?: number; - transaction?: boolean; + cascadeSave?: boolean; + context?: AttributeMap; + batchSize?: number; + transaction?: boolean; }; type FetchOptions = { - useMasterKey?: boolean; - sessionToken?: string; - include?: string | string[]; - context?: AttributeMap; + useMasterKey?: boolean; + sessionToken?: string; + include?: string | string[]; + context?: AttributeMap; }; /** * Creates a new model with defined attributes. @@ -47,1050 +47,1006 @@ type FetchOptions = { * @alias Parse.Object */ declare class ParseObject { - /** - * @param {string} className The class name for the object - * @param {object} attributes The initial set of data to store in the object. - * @param {object} options The options for this object instance. - * @param {boolean} [options.ignoreValidation] Set to `true` ignore any attribute validation errors. - */ - constructor( - className?: - | string - | { - className: string; - [attr: string]: any; - }, - attributes?: { - [attr: string]: any; - }, - options?: { - ignoreValidation: boolean; - } - ); - /** - * The ID of this object, unique within its class. - * - * @property {string} id - */ - id?: string; - _localId?: string; - _objCount: number; - className: string; - get attributes(): AttributeMap; - /** - * The first time this object was saved on the server. - * - * @property {Date} createdAt - * @returns {Date} - */ - get createdAt(): Date | undefined; - /** - * The last time this object was updated on the server. - * - * @property {Date} updatedAt - * @returns {Date} - */ - get updatedAt(): Date | undefined; - /** - * Returns a local or server Id used uniquely identify this object - * - * @returns {string} - */ - _getId(): string; - /** - * Returns a unique identifier used to pull data from the State Controller. - * - * @returns {Parse.Object|object} - */ - _getStateIdentifier(): - | ParseObject - | { + /** + * @param {string} className The class name for the object + * @param {object} attributes The initial set of data to store in the object. + * @param {object} options The options for this object instance. + * @param {boolean} [options.ignoreValidation] Set to `true` ignore any attribute validation errors. + */ + constructor(className?: string | { + className: string; + [attr: string]: any; + }, attributes?: { + [attr: string]: any; + }, options?: { + ignoreValidation: boolean; + }); + /** + * The ID of this object, unique within its class. + * + * @property {string} id + */ + id?: string; + _localId?: string; + _objCount: number; + className: string; + get attributes(): AttributeMap; + /** + * The first time this object was saved on the server. + * + * @property {Date} createdAt + * @returns {Date} + */ + get createdAt(): Date | undefined; + /** + * The last time this object was updated on the server. + * + * @property {Date} updatedAt + * @returns {Date} + */ + get updatedAt(): Date | undefined; + /** + * Returns a local or server Id used uniquely identify this object + * + * @returns {string} + */ + _getId(): string; + /** + * Returns a unique identifier used to pull data from the State Controller. + * + * @returns {Parse.Object|object} + */ + _getStateIdentifier(): ParseObject | { id: string; className: string; - }; - _getServerData(): AttributeMap; - _clearServerData(): void; - _getPendingOps(): Array; - /** - * @param {Array} [keysToClear] - if specified, only ops matching - * these fields will be cleared - */ - _clearPendingOps(keysToClear?: Array): void; - _getDirtyObjectAttributes(): AttributeMap; - _toFullJSON(seen?: Array, offline?: boolean): AttributeMap; - _getSaveJSON(): AttributeMap; - _getSaveParams(): SaveParams; - _finishFetch(serverData: AttributeMap): void; - _setExisted(existed: boolean): void; - _migrateId(serverId: string): void; - _handleSaveResponse(response: AttributeMap, status: number): void; - _handleSaveError(): void; - static _getClassMap(): AttributeMap; - static _getRequestOptions( - options?: RequestOptions & - FullOptions & { + }; + _getServerData(): AttributeMap; + _clearServerData(): void; + _getPendingOps(): Array; + /** + * @param {Array} [keysToClear] - if specified, only ops matching + * these fields will be cleared + */ + _clearPendingOps(keysToClear?: Array): void; + _getDirtyObjectAttributes(): AttributeMap; + _toFullJSON(seen?: Array, offline?: boolean): AttributeMap; + _getSaveJSON(): AttributeMap; + _getSaveParams(): SaveParams; + _finishFetch(serverData: AttributeMap): void; + _setExisted(existed: boolean): void; + _migrateId(serverId: string): void; + _handleSaveResponse(response: AttributeMap, status: number): void; + _handleSaveError(): void; + static _getClassMap(): AttributeMap; + static _getRequestOptions(options?: RequestOptions & FullOptions & { + json?: boolean; + }): RequestOptions & FullOptions & { json?: boolean; - } - ): RequestOptions & - FullOptions & { - json?: boolean; }; - initialize(): void; - /** - * Returns a JSON version of the object suitable for saving to Parse. - * - * @param seen - * @param offline - * @returns {object} - */ - toJSON(seen: Array | void, offline?: boolean): AttributeMap; - /** - * Determines whether this ParseObject is equal to another ParseObject - * - * @param {object} other - An other object ot compare - * @returns {boolean} - */ - equals(other: any): boolean; - /** - * Returns true if this object has been modified since its last - * save/refresh. If an attribute is specified, it returns true only if that - * particular attribute has been modified since the last save/refresh. - * - * @param {string} attr An attribute name (optional). - * @returns {boolean} - */ - dirty(attr?: string): boolean; - /** - * Returns an array of keys that have been modified since last save/refresh - * - * @returns {string[]} - */ - dirtyKeys(): Array; - /** - * Returns true if the object has been fetched. - * - * @returns {boolean} - */ - isDataAvailable(): boolean; - /** - * Gets a Pointer referencing this Object. - * - * @returns {Pointer} - */ - toPointer(): Pointer; - /** - * Gets a Pointer referencing this Object. - * - * @returns {Pointer} - */ - toOfflinePointer(): Pointer; - /** - * Gets the value of an attribute. - * - * @param {string} attr The string name of an attribute. - * @returns {*} - */ - get(attr: string): any; - /** - * Gets a relation on the given class for the attribute. - * - * @param {string} attr The attribute to get the relation for. - * @returns {Parse.Relation} - */ - relation(attr: string): ParseRelation; - /** - * Gets the HTML-escaped value of an attribute. - * - * @param {string} attr The string name of an attribute. - * @returns {string} - */ - escape(attr: string): string; - /** - * Returns true if the attribute contains a value that is not - * null or undefined. - * - * @param {string} attr The string name of the attribute. - * @returns {boolean} - */ - has(attr: string): boolean; - /** - * Sets a hash of model attributes on the object. - * - *

      You can call it with an object containing keys and values, with one - * key and value, or dot notation. For example:

      -   *   gameTurn.set({
      -   *     player: player1,
      -   *     diceRoll: 2
      -   *   }, {
      -   *     error: function(gameTurnAgain, error) {
      -   *       // The set failed validation.
      -   *     }
      -   *   });
      -   *
      -   *   game.set("currentPlayer", player2, {
      -   *     error: function(gameTurnAgain, error) {
      -   *       // The set failed validation.
      -   *     }
      -   *   });
      -   *
      -   *   game.set("finished", true);

      - * - * game.set("player.score", 10);

      - * - * @param {(string|object)} key The key to set. - * @param {(string|object)} value The value to give it. - * @param {object} options A set of options for the set. - * The only supported option is error. - * @returns {Parse.Object} Returns the object, so you can chain this call. - */ - set(key: any, value?: any, options?: any): this; - /** - * Remove an attribute from the model. This is a noop if the attribute doesn't - * exist. - * - * @param {string} attr The string name of an attribute. - * @param options - * @returns {Parse.Object} Returns the object, so you can chain this call. - */ - unset( - attr: string, - options?: { - [opt: string]: any; - } - ): this; - /** - * Atomically increments the value of the given attribute the next time the - * object is saved. If no amount is specified, 1 is used by default. - * - * @param attr {String} The key. - * @param amount {Number} The amount to increment by (optional). - * @returns {Parse.Object} Returns the object, so you can chain this call. - */ - increment(attr: string, amount?: number): this; - /** - * Atomically decrements the value of the given attribute the next time the - * object is saved. If no amount is specified, 1 is used by default. - * - * @param attr {String} The key. - * @param amount {Number} The amount to decrement by (optional). - * @returns {Parse.Object} Returns the object, so you can chain this call. - */ - decrement(attr: string, amount?: number): this; - /** - * Atomically add an object to the end of the array associated with a given - * key. - * - * @param attr {String} The key. - * @param item {} The item to add. - * @returns {Parse.Object} Returns the object, so you can chain this call. - */ - add(attr: string, item: any): this; - /** - * Atomically add the objects to the end of the array associated with a given - * key. - * - * @param attr {String} The key. - * @param items {Object[]} The items to add. - * @returns {Parse.Object} Returns the object, so you can chain this call. - */ - addAll(attr: string, items: Array): this; - /** - * Atomically add an object to the array associated with a given key, only - * if it is not already present in the array. The position of the insert is - * not guaranteed. - * - * @param attr {String} The key. - * @param item {} The object to add. - * @returns {Parse.Object} Returns the object, so you can chain this call. - */ - addUnique(attr: string, item: any): this; - /** - * Atomically add the objects to the array associated with a given key, only - * if it is not already present in the array. The position of the insert is - * not guaranteed. - * - * @param attr {String} The key. - * @param items {Object[]} The objects to add. - * @returns {Parse.Object} Returns the object, so you can chain this call. - */ - addAllUnique(attr: string, items: Array): this; - /** - * Atomically remove all instances of an object from the array associated - * with a given key. - * - * @param attr {String} The key. - * @param item {} The object to remove. - * @returns {Parse.Object} Returns the object, so you can chain this call. - */ - remove(attr: string, item: any): this; - /** - * Atomically remove all instances of the objects from the array associated - * with a given key. - * - * @param attr {String} The key. - * @param items {Object[]} The object to remove. - * @returns {Parse.Object} Returns the object, so you can chain this call. - */ - removeAll(attr: string, items: Array): this; - /** - * Returns an instance of a subclass of Parse.Op describing what kind of - * modification has been performed on this field since the last time it was - * saved. For example, after calling object.increment("x"), calling - * object.op("x") would return an instance of Parse.Op.Increment. - * - * @param attr {String} The key. - * @returns {Parse.Op | undefined} The operation, or undefined if none. - */ - op(attr: string): Op | undefined; - /** - * Creates a new model with identical attributes to this one. - * - * @returns {Parse.Object} - */ - clone(): any; - /** - * Creates a new instance of this object. Not to be confused with clone() - * - * @returns {Parse.Object} - */ - newInstance(): any; - /** - * Returns true if this object has never been saved to Parse. - * - * @returns {boolean} - */ - isNew(): boolean; - /** - * Returns true if this object was created by the Parse server when the - * object might have already been there (e.g. in the case of a Facebook - * login) - * - * @returns {boolean} - */ - existed(): boolean; - /** - * Returns true if this object exists on the Server - * - * @param {object} options - * Valid options are:
        - *
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
      • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
      - * @returns {Promise} A boolean promise that is fulfilled if object exists. - */ - exists(options?: RequestOptions): Promise; - /** - * Checks if the model is currently in a valid state. - * - * @returns {boolean} - */ - isValid(): boolean; - /** - * You should not call this function directly unless you subclass - * Parse.Object, in which case you can override this method - * to provide additional validation on set and - * save. Your implementation should return - * - * @param {object} attrs The current data to validate. - * @returns {Parse.Error|boolean} False if the data is valid. An error object otherwise. - * @see Parse.Object#set - */ - validate(attrs: AttributeMap): ParseError | boolean; - /** - * Returns the ACL for this object. - * - * @returns {Parse.ACL|null} An instance of Parse.ACL. - * @see Parse.Object#get - */ - getACL(): ParseACL | null; - /** - * Sets the ACL to be used for this object. - * - * @param {Parse.ACL} acl An instance of Parse.ACL. - * @param {object} options - * @returns {Parse.Object} Returns the object, so you can chain this call. - * @see Parse.Object#set - */ - setACL(acl: ParseACL, options?: any): this; - /** - * Clears any (or specific) changes to this object made since the last call to save() - * - * @param {string} [keys] - specify which fields to revert - */ - revert(...keys: Array): void; - /** - * Clears all attributes on a model - * - * @returns {Parse.Object} Returns the object, so you can chain this call. - */ - clear(): this; - /** - * Fetch the model from the server. If the server's representation of the - * model differs from its current attributes, they will be overriden. - * - * @param {object} options - * Valid options are:
        - *
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
      • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
      • include: The name(s) of the key(s) to include. Can be a string, an array of strings, - * or an array of array of strings. - *
      • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. - *
      - * @returns {Promise} A promise that is fulfilled when the fetch - * completes. - */ - fetch(options: FetchOptions): Promise; - /** - * Fetch the model from the server. If the server's representation of the - * model differs from its current attributes, they will be overriden. - * - * Includes nested Parse.Objects for the provided key. You can use dot - * notation to specify which fields in the included object are also fetched. - * - * @param {string | Array>} keys The name(s) of the key(s) to include. - * @param {object} options - * Valid options are:
        - *
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
      • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
      - * @returns {Promise} A promise that is fulfilled when the fetch - * completes. - */ - fetchWithInclude( - keys: string | Array>, - options: RequestOptions - ): Promise; - /** - * Saves this object to the server at some unspecified time in the future, - * even if Parse is currently inaccessible. - * - * Use this when you may not have a solid network connection, and don't need to know when the save completes. - * If there is some problem with the object such that it can't be saved, it will be silently discarded. - * - * Objects saved with this method will be stored locally in an on-disk cache until they can be delivered to Parse. - * They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is - * available. Objects saved this way will persist even after the app is closed, in which case they will be sent the - * next time the app is opened. - * - * @param {object} [options] - * Used to pass option parameters to method if arg1 and arg2 were both passed as strings. - * Valid options are: - *
        - *
      • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
      • cascadeSave: If `false`, nested objects will not be saved (default is `true`). - *
      • context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers. - *
      - * @returns {Promise} A promise that is fulfilled when the save - * completes. - */ - saveEventually(options: SaveOptions): Promise; - /** - * Set a hash of model attributes, and save the model to the server. - * updatedAt will be updated when the request returns. - * You can either call it as:
      -   * object.save();
      - * or
      -   * object.save(attrs);
      - * or
      -   * object.save(null, options);
      - * or
      -   * object.save(attrs, options);
      - * or
      -   * object.save(key, value);
      - * or
      -   * object.save(key, value, options);
      - * - * Example 1:
      -   * gameTurn.save({
      -   * player: "Jake Cutter",
      -   * diceRoll: 2
      -   * }).then(function(gameTurnAgain) {
      -   * // The save was successful.
      -   * }, function(error) {
      -   * // The save failed.  Error is an instance of Parse.Error.
      -   * });
      - * - * Example 2:
      -   * gameTurn.save("player", "Jake Cutter");
      - * - * @param {string | object | null} [arg1] - * Valid options are:
        - *
      • `Object` - Key/value pairs to update on the object.
      • - *
      • `String` Key - Key of attribute to update (requires arg2 to also be string)
      • - *
      • `null` - Passing null for arg1 allows you to save the object with options passed in arg2.
      • - *
      - * @param {string | object} [arg2] - *
        - *
      • `String` Value - If arg1 was passed as a key, arg2 is the value that should be set on that key.
      • - *
      • `Object` Options - Valid options are: - *
          - *
        • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
        • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
        • cascadeSave: If `false`, nested objects will not be saved (default is `true`). - *
        • context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers. - *
        - *
      • - *
      - * @param {object} [arg3] - * Used to pass option parameters to method if arg1 and arg2 were both passed as strings. - * Valid options are: - *
        - *
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
      • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
      • cascadeSave: If `false`, nested objects will not be saved (default is `true`). - *
      • context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers. - *
      - * @returns {Promise} A promise that is fulfilled when the save - * completes. - */ - save( - arg1: - | undefined - | string - | { - [attr: string]: any; - } - | null, - arg2: SaveOptions | any, - arg3?: SaveOptions - ): Promise; - /** - * Deletes this object from the server at some unspecified time in the future, - * even if Parse is currently inaccessible. - * - * Use this when you may not have a solid network connection, - * and don't need to know when the delete completes. If there is some problem with the object - * such that it can't be deleted, the request will be silently discarded. - * - * Delete instructions made with this method will be stored locally in an on-disk cache until they can be transmitted - * to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection - * is available. Delete requests will persist even after the app is closed, in which case they will be sent the - * next time the app is opened. - * - * @param {object} [options] - * Valid options are:
        - *
      • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
      • context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers. - *
      - * @returns {Promise} A promise that is fulfilled when the destroy - * completes. - */ - destroyEventually(options: RequestOptions): Promise; - /** - * Destroy this model on the server if it was already persisted. - * - * @param {object} options - * Valid options are:
        - *
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
      • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
      • context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers. - *
      - * @returns {Promise} A promise that is fulfilled when the destroy - * completes. - */ - destroy(options: RequestOptions): Promise; - /** - * Asynchronously stores the object and every object it points to in the local datastore, - * recursively, using a default pin name: _default. - * - * If those other objects have not been fetched from Parse, they will not be stored. - * However, if they have changed data, all the changes will be retained. - * - *
      -   * await object.pin();
      -   * 
      - * - * To retrieve object: - * query.fromLocalDatastore() or query.fromPin() - * - * @returns {Promise} A promise that is fulfilled when the pin completes. - */ - pin(): Promise; - /** - * Asynchronously removes the object and every object it points to in the local datastore, - * recursively, using a default pin name: _default. - * - *
      -   * await object.unPin();
      -   * 
      - * - * @returns {Promise} A promise that is fulfilled when the unPin completes. - */ - unPin(): Promise; - /** - * Asynchronously returns if the object is pinned - * - *
      -   * const isPinned = await object.isPinned();
      -   * 
      - * - * @returns {Promise} A boolean promise that is fulfilled if object is pinned. - */ - isPinned(): Promise; - /** - * Asynchronously stores the objects and every object they point to in the local datastore, recursively. - * - * If those other objects have not been fetched from Parse, they will not be stored. - * However, if they have changed data, all the changes will be retained. - * - *
      -   * await object.pinWithName(name);
      -   * 
      - * - * To retrieve object: - * query.fromLocalDatastore() or query.fromPinWithName(name) - * - * @param {string} name Name of Pin. - * @returns {Promise} A promise that is fulfilled when the pin completes. - */ - pinWithName(name: string): Promise; - /** - * Asynchronously removes the object and every object it points to in the local datastore, recursively. - * - *
      -   * await object.unPinWithName(name);
      -   * 
      - * - * @param {string} name Name of Pin. - * @returns {Promise} A promise that is fulfilled when the unPin completes. - */ - unPinWithName(name: string): Promise; - /** - * Asynchronously loads data from the local datastore into this object. - * - *
      -   * await object.fetchFromLocalDatastore();
      -   * 
      - * - * You can create an unfetched pointer with Parse.Object.createWithoutData() - * and then call fetchFromLocalDatastore() on it. - * - * @returns {Promise} A promise that is fulfilled when the fetch completes. - */ - fetchFromLocalDatastore(): Promise; - static _clearAllState(): void; - /** - * Fetches the given list of Parse.Object. - * If any error is encountered, stops and calls the error handler. - * - *
      -   *   Parse.Object.fetchAll([object1, object2, ...])
      -   *    .then((list) => {
      -   *      // All the objects were fetched.
      -   *    }, (error) => {
      -   *      // An error occurred while fetching one of the objects.
      -   *    });
      -   * 
      - * - * @param {Array} list A list of Parse.Object. - * @param {object} options - * Valid options are:
        - *
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
      • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
      • include: The name(s) of the key(s) to include. Can be a string, an array of strings, - * or an array of array of strings. - *
      - * @static - * @returns {Parse.Object[]} - */ - static fetchAll( - list: Array, - options?: RequestOptions - ): Promise; - /** - * Fetches the given list of Parse.Object. - * - * Includes nested Parse.Objects for the provided key. You can use dot - * notation to specify which fields in the included object are also fetched. - * - * If any error is encountered, stops and calls the error handler. - * - *
      -   *   Parse.Object.fetchAllWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
      -   *    .then((list) => {
      -   *      // All the objects were fetched.
      -   *    }, (error) => {
      -   *      // An error occurred while fetching one of the objects.
      -   *    });
      -   * 
      - * - * @param {Array} list A list of Parse.Object. - * @param {string | Array>} keys The name(s) of the key(s) to include. - * @param {object} options - * Valid options are:
        - *
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
      • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
      - * @static - * @returns {Parse.Object[]} - */ - static fetchAllWithInclude( - list: Array, - keys: string | Array>, - options: RequestOptions - ): Promise; - /** - * Fetches the given list of Parse.Object if needed. - * If any error is encountered, stops and calls the error handler. - * - * Includes nested Parse.Objects for the provided key. You can use dot - * notation to specify which fields in the included object are also fetched. - * - * If any error is encountered, stops and calls the error handler. - * - *
      -   *   Parse.Object.fetchAllIfNeededWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
      -   *    .then((list) => {
      -   *      // All the objects were fetched.
      -   *    }, (error) => {
      -   *      // An error occurred while fetching one of the objects.
      -   *    });
      -   * 
      - * - * @param {Array} list A list of Parse.Object. - * @param {string | Array>} keys The name(s) of the key(s) to include. - * @param {object} options - * Valid options are:
        - *
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
      • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
      - * @static - * @returns {Parse.Object[]} - */ - static fetchAllIfNeededWithInclude( - list: Array, - keys: string | Array>, - options: RequestOptions - ): Promise; - /** - * Fetches the given list of Parse.Object if needed. - * If any error is encountered, stops and calls the error handler. - * - *
      -   *   Parse.Object.fetchAllIfNeeded([object1, ...])
      -   *    .then((list) => {
      -   *      // Objects were fetched and updated.
      -   *    }, (error) => {
      -   *      // An error occurred while fetching one of the objects.
      -   *    });
      -   * 
      - * - * @param {Array} list A list of Parse.Object. - * @param {object} options - * Valid options are:
        - *
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
      • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
      • include: The name(s) of the key(s) to include. Can be a string, an array of strings, - * or an array of array of strings. - *
      • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. - *
      - * @static - * @returns {Parse.Object[]} - */ - static fetchAllIfNeeded( - list: Array, - options: FetchOptions - ): Promise; - static handleIncludeOptions(options: { include?: string | string[] }): any[]; - /** - * Destroy the given list of models on the server if it was already persisted. - * - *

      Unlike saveAll, if an error occurs while deleting an individual model, - * this method will continue trying to delete the rest of the models if - * possible, except in the case of a fatal error like a connection error. - * - *

      In particular, the Parse.Error object returned in the case of error may - * be one of two types: - * - *

        - *
      • A Parse.Error.AGGREGATE_ERROR. This object's "errors" property is an - * array of other Parse.Error objects. Each error object in this array - * has an "object" property that references the object that could not be - * deleted (for instance, because that object could not be found).
      • - *
      • A non-aggregate Parse.Error. This indicates a serious error that - * caused the delete operation to be aborted partway through (for - * instance, a connection failure in the middle of the delete).
      • - *
      - * - *
      -   * Parse.Object.destroyAll([object1, object2, ...])
      -   * .then((list) => {
      -   * // All the objects were deleted.
      -   * }, (error) => {
      -   * // An error occurred while deleting one or more of the objects.
      -   * // If this is an aggregate error, then we can inspect each error
      -   * // object individually to determine the reason why a particular
      -   * // object was not deleted.
      -   * if (error.code === Parse.Error.AGGREGATE_ERROR) {
      -   * for (var i = 0; i < error.errors.length; i++) {
      -   * console.log("Couldn't delete " + error.errors[i].object.id +
      -   * "due to " + error.errors[i].message);
      -   * }
      -   * } else {
      -   * console.log("Delete aborted because of " + error.message);
      -   * }
      -   * });
      -   * 
      - * - * @param {Array} list A list of Parse.Object. - * @param {object} options - * Valid options are:
        - *
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
      • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
      • context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers. - *
      • transaction: Set to true to enable transactions - *
      • batchSize: How many objects to yield in each batch (default: 20) - *
      - * @static - * @returns {Promise} A promise that is fulfilled when the destroyAll - * completes. - */ - static destroyAll( - list: Array, - options?: SaveOptions - ): Promise; - /** - * Saves the given list of Parse.Object. - * If any error is encountered, stops and calls the error handler. - * - *
      -   * Parse.Object.saveAll([object1, object2, ...])
      -   * .then((list) => {
      -   * // All the objects were saved.
      -   * }, (error) => {
      -   * // An error occurred while saving one of the objects.
      -   * });
      -   * 
      - * - * @param {Array} list A list of Parse.Object. - * @param {object} options - * Valid options are: - *
        - *
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
      • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
      • cascadeSave: If `false`, nested objects will not be saved (default is `true`). - *
      • context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers. - *
      • transaction: Set to true to enable transactions - *
      • batchSize: How many objects to yield in each batch (default: 20) - *
      - * @static - * @returns {Parse.Object[]} - */ - static saveAll( - list: Array, - options?: SaveOptions - ): Promise; - /** - * Creates a reference to a subclass of Parse.Object with the given id. This - * does not exist on Parse.Object, only on subclasses. - * - *

      A shortcut for:

      -   *  var Foo = Parse.Object.extend("Foo");
      -   *  var pointerToFoo = new Foo();
      -   *  pointerToFoo.id = "myObjectId";
      -   * 
      - * - * @param {string} id The ID of the object to create a reference to. - * @static - * @returns {Parse.Object} A Parse.Object reference. - */ - static createWithoutData(id: string): ParseObject; - /** - * Creates a new instance of a Parse Object from a JSON representation. - * - * @param {object} json The JSON map of the Object's data - * @param {boolean} override In single instance mode, all old server data - * is overwritten if this is set to true - * @param {boolean} dirty Whether the Parse.Object should set JSON keys to dirty - * @static - * @returns {Parse.Object} A Parse.Object reference - */ - static fromJSON(json: any, override?: boolean, dirty?: boolean): ParseObject; - /** - * Registers a subclass of Parse.Object with a specific class name. - * When objects of that class are retrieved from a query, they will be - * instantiated with this subclass. - * This is only necessary when using ES6 subclassing. - * - * @param {string} className The class name of the subclass - * @param {Function} constructor The subclass - */ - static registerSubclass(className: string, constructor: any): void; - /** - * Unegisters a subclass of Parse.Object with a specific class name. - * - * @param {string} className The class name of the subclass - */ - static unregisterSubclass(className: string): void; - /** - * Creates a new subclass of Parse.Object for the given Parse class name. - * - *

      Every extension of a Parse class will inherit from the most recent - * previous extension of that class. When a Parse.Object is automatically - * created by parsing JSON, it will use the most recent extension of that - * class.

      - * - *

      You should call either:

      -   *     var MyClass = Parse.Object.extend("MyClass", {
      -   *         Instance methods,
      -   *         initialize: function(attrs, options) {
      -   *             this.someInstanceProperty = [],
      -   *             Other instance properties
      -   *         }
      -   *     }, {
      -   *         Class properties
      -   *     });
      - * or, for Backbone compatibility:
      -   *     var MyClass = Parse.Object.extend({
      -   *         className: "MyClass",
      -   *         Instance methods,
      -   *         initialize: function(attrs, options) {
      -   *             this.someInstanceProperty = [],
      -   *             Other instance properties
      -   *         }
      -   *     }, {
      -   *         Class properties
      -   *     });

      - * - * @param {string} className The name of the Parse class backing this model. - * @param {object} [protoProps] Instance properties to add to instances of the - * class returned from this method. - * @param {object} [classProps] Class properties to add the class returned from - * this method. - * @returns {Parse.Object} A new subclass of Parse.Object. - */ - static extend(className: any, protoProps?: any, classProps?: any): any; - /** - * Enable single instance objects, where any local objects with the same Id - * share the same attributes, and stay synchronized with each other. - * This is disabled by default in server environments, since it can lead to - * security issues. - * - * @static - */ - static enableSingleInstance(): void; - /** - * Disable single instance objects, where any local objects with the same Id - * share the same attributes, and stay synchronized with each other. - * When disabled, you can have two instances of the same object in memory - * without them sharing attributes. - * - * @static - */ - static disableSingleInstance(): void; - /** - * Asynchronously stores the objects and every object they point to in the local datastore, - * recursively, using a default pin name: _default. - * - * If those other objects have not been fetched from Parse, they will not be stored. - * However, if they have changed data, all the changes will be retained. - * - *
      -   * await Parse.Object.pinAll([...]);
      -   * 
      - * - * To retrieve object: - * query.fromLocalDatastore() or query.fromPin() - * - * @param {Array} objects A list of Parse.Object. - * @returns {Promise} A promise that is fulfilled when the pin completes. - * @static - */ - static pinAll(objects: Array): Promise; - /** - * Asynchronously stores the objects and every object they point to in the local datastore, recursively. - * - * If those other objects have not been fetched from Parse, they will not be stored. - * However, if they have changed data, all the changes will be retained. - * - *
      -   * await Parse.Object.pinAllWithName(name, [obj1, obj2, ...]);
      -   * 
      - * - * To retrieve object: - * query.fromLocalDatastore() or query.fromPinWithName(name) - * - * @param {string} name Name of Pin. - * @param {Array} objects A list of Parse.Object. - * @returns {Promise} A promise that is fulfilled when the pin completes. - * @static - */ - static pinAllWithName(name: string, objects: Array): Promise; - /** - * Asynchronously removes the objects and every object they point to in the local datastore, - * recursively, using a default pin name: _default. - * - *
      -   * await Parse.Object.unPinAll([...]);
      -   * 
      - * - * @param {Array} objects A list of Parse.Object. - * @returns {Promise} A promise that is fulfilled when the unPin completes. - * @static - */ - static unPinAll(objects: Array): Promise; - /** - * Asynchronously removes the objects and every object they point to in the local datastore, recursively. - * - *
      -   * await Parse.Object.unPinAllWithName(name, [obj1, obj2, ...]);
      -   * 
      - * - * @param {string} name Name of Pin. - * @param {Array} objects A list of Parse.Object. - * @returns {Promise} A promise that is fulfilled when the unPin completes. - * @static - */ - static unPinAllWithName(name: string, objects: Array): Promise; - /** - * Asynchronously removes all objects in the local datastore using a default pin name: _default. - * - *
      -   * await Parse.Object.unPinAllObjects();
      -   * 
      - * - * @returns {Promise} A promise that is fulfilled when the unPin completes. - * @static - */ - static unPinAllObjects(): Promise; - /** - * Asynchronously removes all objects with the specified pin name. - * Deletes the pin name also. - * - *
      -   * await Parse.Object.unPinAllObjectsWithName(name);
      -   * 
      - * - * @param {string} name Name of Pin. - * @returns {Promise} A promise that is fulfilled when the unPin completes. - * @static - */ - static unPinAllObjectsWithName(name: string): Promise; + initialize(): void; + /** + * Returns a JSON version of the object suitable for saving to Parse. + * + * @param seen + * @param offline + * @returns {object} + */ + toJSON(seen: Array | void, offline?: boolean): AttributeMap; + /** + * Determines whether this ParseObject is equal to another ParseObject + * + * @param {object} other - An other object ot compare + * @returns {boolean} + */ + equals(other: any): boolean; + /** + * Returns true if this object has been modified since its last + * save/refresh. If an attribute is specified, it returns true only if that + * particular attribute has been modified since the last save/refresh. + * + * @param {string} attr An attribute name (optional). + * @returns {boolean} + */ + dirty(attr?: string): boolean; + /** + * Returns an array of keys that have been modified since last save/refresh + * + * @returns {string[]} + */ + dirtyKeys(): Array; + /** + * Returns true if the object has been fetched. + * + * @returns {boolean} + */ + isDataAvailable(): boolean; + /** + * Gets a Pointer referencing this Object. + * + * @returns {Pointer} + */ + toPointer(): Pointer; + /** + * Gets a Pointer referencing this Object. + * + * @returns {Pointer} + */ + toOfflinePointer(): Pointer; + /** + * Gets the value of an attribute. + * + * @param {string} attr The string name of an attribute. + * @returns {*} + */ + get(attr: string): any; + /** + * Gets a relation on the given class for the attribute. + * + * @param {string} attr The attribute to get the relation for. + * @returns {Parse.Relation} + */ + relation(attr: string): ParseRelation; + /** + * Gets the HTML-escaped value of an attribute. + * + * @param {string} attr The string name of an attribute. + * @returns {string} + */ + escape(attr: string): string; + /** + * Returns true if the attribute contains a value that is not + * null or undefined. + * + * @param {string} attr The string name of the attribute. + * @returns {boolean} + */ + has(attr: string): boolean; + /** + * Sets a hash of model attributes on the object. + * + *

      You can call it with an object containing keys and values, with one + * key and value, or dot notation. For example:

      +     *   gameTurn.set({
      +     *     player: player1,
      +     *     diceRoll: 2
      +     *   }, {
      +     *     error: function(gameTurnAgain, error) {
      +     *       // The set failed validation.
      +     *     }
      +     *   });
      +     *
      +     *   game.set("currentPlayer", player2, {
      +     *     error: function(gameTurnAgain, error) {
      +     *       // The set failed validation.
      +     *     }
      +     *   });
      +     *
      +     *   game.set("finished", true);

      + * + * game.set("player.score", 10);

    + * + * @param {(string|object)} key The key to set. + * @param {(string|object)} value The value to give it. + * @param {object} options A set of options for the set. + * The only supported option is error. + * @returns {Parse.Object} Returns the object, so you can chain this call. + */ + set(key: any, value?: any, options?: any): this; + /** + * Remove an attribute from the model. This is a noop if the attribute doesn't + * exist. + * + * @param {string} attr The string name of an attribute. + * @param options + * @returns {Parse.Object} Returns the object, so you can chain this call. + */ + unset(attr: string, options?: { + [opt: string]: any; + }): this; + /** + * Atomically increments the value of the given attribute the next time the + * object is saved. If no amount is specified, 1 is used by default. + * + * @param attr {String} The key. + * @param amount {Number} The amount to increment by (optional). + * @returns {Parse.Object} Returns the object, so you can chain this call. + */ + increment(attr: string, amount?: number): this; + /** + * Atomically decrements the value of the given attribute the next time the + * object is saved. If no amount is specified, 1 is used by default. + * + * @param attr {String} The key. + * @param amount {Number} The amount to decrement by (optional). + * @returns {Parse.Object} Returns the object, so you can chain this call. + */ + decrement(attr: string, amount?: number): this; + /** + * Atomically add an object to the end of the array associated with a given + * key. + * + * @param attr {String} The key. + * @param item {} The item to add. + * @returns {Parse.Object} Returns the object, so you can chain this call. + */ + add(attr: string, item: any): this; + /** + * Atomically add the objects to the end of the array associated with a given + * key. + * + * @param attr {String} The key. + * @param items {Object[]} The items to add. + * @returns {Parse.Object} Returns the object, so you can chain this call. + */ + addAll(attr: string, items: Array): this; + /** + * Atomically add an object to the array associated with a given key, only + * if it is not already present in the array. The position of the insert is + * not guaranteed. + * + * @param attr {String} The key. + * @param item {} The object to add. + * @returns {Parse.Object} Returns the object, so you can chain this call. + */ + addUnique(attr: string, item: any): this; + /** + * Atomically add the objects to the array associated with a given key, only + * if it is not already present in the array. The position of the insert is + * not guaranteed. + * + * @param attr {String} The key. + * @param items {Object[]} The objects to add. + * @returns {Parse.Object} Returns the object, so you can chain this call. + */ + addAllUnique(attr: string, items: Array): this; + /** + * Atomically remove all instances of an object from the array associated + * with a given key. + * + * @param attr {String} The key. + * @param item {} The object to remove. + * @returns {Parse.Object} Returns the object, so you can chain this call. + */ + remove(attr: string, item: any): this; + /** + * Atomically remove all instances of the objects from the array associated + * with a given key. + * + * @param attr {String} The key. + * @param items {Object[]} The object to remove. + * @returns {Parse.Object} Returns the object, so you can chain this call. + */ + removeAll(attr: string, items: Array): this; + /** + * Returns an instance of a subclass of Parse.Op describing what kind of + * modification has been performed on this field since the last time it was + * saved. For example, after calling object.increment("x"), calling + * object.op("x") would return an instance of Parse.Op.Increment. + * + * @param attr {String} The key. + * @returns {Parse.Op | undefined} The operation, or undefined if none. + */ + op(attr: string): Op | undefined; + /** + * Creates a new model with identical attributes to this one. + * + * @returns {Parse.Object} + */ + clone(): any; + /** + * Creates a new instance of this object. Not to be confused with clone() + * + * @returns {Parse.Object} + */ + newInstance(): any; + /** + * Returns true if this object has never been saved to Parse. + * + * @returns {boolean} + */ + isNew(): boolean; + /** + * Returns true if this object was created by the Parse server when the + * object might have already been there (e.g. in the case of a Facebook + * login) + * + * @returns {boolean} + */ + existed(): boolean; + /** + * Returns true if this object exists on the Server + * + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    + * @returns {Promise} A boolean promise that is fulfilled if object exists. + */ + exists(options?: RequestOptions): Promise; + /** + * Checks if the model is currently in a valid state. + * + * @returns {boolean} + */ + isValid(): boolean; + /** + * You should not call this function directly unless you subclass + * Parse.Object, in which case you can override this method + * to provide additional validation on set and + * save. Your implementation should return + * + * @param {object} attrs The current data to validate. + * @returns {Parse.Error|boolean} False if the data is valid. An error object otherwise. + * @see Parse.Object#set + */ + validate(attrs: AttributeMap): ParseError | boolean; + /** + * Returns the ACL for this object. + * + * @returns {Parse.ACL|null} An instance of Parse.ACL. + * @see Parse.Object#get + */ + getACL(): ParseACL | null; + /** + * Sets the ACL to be used for this object. + * + * @param {Parse.ACL} acl An instance of Parse.ACL. + * @param {object} options + * @returns {Parse.Object} Returns the object, so you can chain this call. + * @see Parse.Object#set + */ + setACL(acl: ParseACL, options?: any): this; + /** + * Clears any (or specific) changes to this object made since the last call to save() + * + * @param {string} [keys] - specify which fields to revert + */ + revert(...keys: Array): void; + /** + * Clears all attributes on a model + * + * @returns {Parse.Object} Returns the object, so you can chain this call. + */ + clear(): this; + /** + * Fetch the model from the server. If the server's representation of the + * model differs from its current attributes, they will be overriden. + * + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • include: The name(s) of the key(s) to include. Can be a string, an array of strings, + * or an array of array of strings. + *
    • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. + *
    + * @returns {Promise} A promise that is fulfilled when the fetch + * completes. + */ + fetch(options: FetchOptions): Promise; + /** + * Fetch the model from the server. If the server's representation of the + * model differs from its current attributes, they will be overriden. + * + * Includes nested Parse.Objects for the provided key. You can use dot + * notation to specify which fields in the included object are also fetched. + * + * @param {string | Array>} keys The name(s) of the key(s) to include. + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    + * @returns {Promise} A promise that is fulfilled when the fetch + * completes. + */ + fetchWithInclude(keys: string | Array>, options: RequestOptions): Promise; + /** + * Saves this object to the server at some unspecified time in the future, + * even if Parse is currently inaccessible. + * + * Use this when you may not have a solid network connection, and don't need to know when the save completes. + * If there is some problem with the object such that it can't be saved, it will be silently discarded. + * + * Objects saved with this method will be stored locally in an on-disk cache until they can be delivered to Parse. + * They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is + * available. Objects saved this way will persist even after the app is closed, in which case they will be sent the + * next time the app is opened. + * + * @param {object} [options] + * Used to pass option parameters to method if arg1 and arg2 were both passed as strings. + * Valid options are: + *
      + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • cascadeSave: If `false`, nested objects will not be saved (default is `true`). + *
    • context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers. + *
    + * @returns {Promise} A promise that is fulfilled when the save + * completes. + */ + saveEventually(options: SaveOptions): Promise; + /** + * Set a hash of model attributes, and save the model to the server. + * updatedAt will be updated when the request returns. + * You can either call it as:
    +     * object.save();
    + * or
    +     * object.save(attrs);
    + * or
    +     * object.save(null, options);
    + * or
    +     * object.save(attrs, options);
    + * or
    +     * object.save(key, value);
    + * or
    +     * object.save(key, value, options);
    + * + * Example 1:
    +     * gameTurn.save({
    +     * player: "Jake Cutter",
    +     * diceRoll: 2
    +     * }).then(function(gameTurnAgain) {
    +     * // The save was successful.
    +     * }, function(error) {
    +     * // The save failed.  Error is an instance of Parse.Error.
    +     * });
    + * + * Example 2:
    +     * gameTurn.save("player", "Jake Cutter");
    + * + * @param {string | object | null} [arg1] + * Valid options are:
      + *
    • `Object` - Key/value pairs to update on the object.
    • + *
    • `String` Key - Key of attribute to update (requires arg2 to also be string)
    • + *
    • `null` - Passing null for arg1 allows you to save the object with options passed in arg2.
    • + *
    + * @param {string | object} [arg2] + *
      + *
    • `String` Value - If arg1 was passed as a key, arg2 is the value that should be set on that key.
    • + *
    • `Object` Options - Valid options are: + *
        + *
      • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
      • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
      • cascadeSave: If `false`, nested objects will not be saved (default is `true`). + *
      • context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers. + *
      + *
    • + *
    + * @param {object} [arg3] + * Used to pass option parameters to method if arg1 and arg2 were both passed as strings. + * Valid options are: + *
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • cascadeSave: If `false`, nested objects will not be saved (default is `true`). + *
    • context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers. + *
    + * @returns {Promise} A promise that is fulfilled when the save + * completes. + */ + save(arg1: undefined | string | { + [attr: string]: any; + } | null, arg2: SaveOptions | any, arg3?: SaveOptions): Promise; + /** + * Deletes this object from the server at some unspecified time in the future, + * even if Parse is currently inaccessible. + * + * Use this when you may not have a solid network connection, + * and don't need to know when the delete completes. If there is some problem with the object + * such that it can't be deleted, the request will be silently discarded. + * + * Delete instructions made with this method will be stored locally in an on-disk cache until they can be transmitted + * to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection + * is available. Delete requests will persist even after the app is closed, in which case they will be sent the + * next time the app is opened. + * + * @param {object} [options] + * Valid options are:
      + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers. + *
    + * @returns {Promise} A promise that is fulfilled when the destroy + * completes. + */ + destroyEventually(options: RequestOptions): Promise; + /** + * Destroy this model on the server if it was already persisted. + * + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers. + *
    + * @returns {Promise} A promise that is fulfilled when the destroy + * completes. + */ + destroy(options: RequestOptions): Promise; + /** + * Asynchronously stores the object and every object it points to in the local datastore, + * recursively, using a default pin name: _default. + * + * If those other objects have not been fetched from Parse, they will not be stored. + * However, if they have changed data, all the changes will be retained. + * + *
    +     * await object.pin();
    +     * 
    + * + * To retrieve object: + * query.fromLocalDatastore() or query.fromPin() + * + * @returns {Promise} A promise that is fulfilled when the pin completes. + */ + pin(): Promise; + /** + * Asynchronously removes the object and every object it points to in the local datastore, + * recursively, using a default pin name: _default. + * + *
    +     * await object.unPin();
    +     * 
    + * + * @returns {Promise} A promise that is fulfilled when the unPin completes. + */ + unPin(): Promise; + /** + * Asynchronously returns if the object is pinned + * + *
    +     * const isPinned = await object.isPinned();
    +     * 
    + * + * @returns {Promise} A boolean promise that is fulfilled if object is pinned. + */ + isPinned(): Promise; + /** + * Asynchronously stores the objects and every object they point to in the local datastore, recursively. + * + * If those other objects have not been fetched from Parse, they will not be stored. + * However, if they have changed data, all the changes will be retained. + * + *
    +     * await object.pinWithName(name);
    +     * 
    + * + * To retrieve object: + * query.fromLocalDatastore() or query.fromPinWithName(name) + * + * @param {string} name Name of Pin. + * @returns {Promise} A promise that is fulfilled when the pin completes. + */ + pinWithName(name: string): Promise; + /** + * Asynchronously removes the object and every object it points to in the local datastore, recursively. + * + *
    +     * await object.unPinWithName(name);
    +     * 
    + * + * @param {string} name Name of Pin. + * @returns {Promise} A promise that is fulfilled when the unPin completes. + */ + unPinWithName(name: string): Promise; + /** + * Asynchronously loads data from the local datastore into this object. + * + *
    +     * await object.fetchFromLocalDatastore();
    +     * 
    + * + * You can create an unfetched pointer with Parse.Object.createWithoutData() + * and then call fetchFromLocalDatastore() on it. + * + * @returns {Promise} A promise that is fulfilled when the fetch completes. + */ + fetchFromLocalDatastore(): Promise; + static _clearAllState(): void; + /** + * Fetches the given list of Parse.Object. + * If any error is encountered, stops and calls the error handler. + * + *
    +     *   Parse.Object.fetchAll([object1, object2, ...])
    +     *    .then((list) => {
    +     *      // All the objects were fetched.
    +     *    }, (error) => {
    +     *      // An error occurred while fetching one of the objects.
    +     *    });
    +     * 
    + * + * @param {Array} list A list of Parse.Object. + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • include: The name(s) of the key(s) to include. Can be a string, an array of strings, + * or an array of array of strings. + *
    + * @static + * @returns {Parse.Object[]} + */ + static fetchAll(list: Array, options?: RequestOptions): Promise; + /** + * Fetches the given list of Parse.Object. + * + * Includes nested Parse.Objects for the provided key. You can use dot + * notation to specify which fields in the included object are also fetched. + * + * If any error is encountered, stops and calls the error handler. + * + *
    +     *   Parse.Object.fetchAllWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
    +     *    .then((list) => {
    +     *      // All the objects were fetched.
    +     *    }, (error) => {
    +     *      // An error occurred while fetching one of the objects.
    +     *    });
    +     * 
    + * + * @param {Array} list A list of Parse.Object. + * @param {string | Array>} keys The name(s) of the key(s) to include. + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    + * @static + * @returns {Parse.Object[]} + */ + static fetchAllWithInclude(list: Array, keys: string | Array>, options: RequestOptions): Promise; + /** + * Fetches the given list of Parse.Object if needed. + * If any error is encountered, stops and calls the error handler. + * + * Includes nested Parse.Objects for the provided key. You can use dot + * notation to specify which fields in the included object are also fetched. + * + * If any error is encountered, stops and calls the error handler. + * + *
    +     *   Parse.Object.fetchAllIfNeededWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
    +     *    .then((list) => {
    +     *      // All the objects were fetched.
    +     *    }, (error) => {
    +     *      // An error occurred while fetching one of the objects.
    +     *    });
    +     * 
    + * + * @param {Array} list A list of Parse.Object. + * @param {string | Array>} keys The name(s) of the key(s) to include. + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    + * @static + * @returns {Parse.Object[]} + */ + static fetchAllIfNeededWithInclude(list: Array, keys: string | Array>, options: RequestOptions): Promise; + /** + * Fetches the given list of Parse.Object if needed. + * If any error is encountered, stops and calls the error handler. + * + *
    +     *   Parse.Object.fetchAllIfNeeded([object1, ...])
    +     *    .then((list) => {
    +     *      // Objects were fetched and updated.
    +     *    }, (error) => {
    +     *      // An error occurred while fetching one of the objects.
    +     *    });
    +     * 
    + * + * @param {Array} list A list of Parse.Object. + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • include: The name(s) of the key(s) to include. Can be a string, an array of strings, + * or an array of array of strings. + *
    • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. + *
    + * @static + * @returns {Parse.Object[]} + */ + static fetchAllIfNeeded(list: Array, options: FetchOptions): Promise; + static handleIncludeOptions(options: { + include?: string | string[]; + }): any[]; + /** + * Destroy the given list of models on the server if it was already persisted. + * + *

    Unlike saveAll, if an error occurs while deleting an individual model, + * this method will continue trying to delete the rest of the models if + * possible, except in the case of a fatal error like a connection error. + * + *

    In particular, the Parse.Error object returned in the case of error may + * be one of two types: + * + *

      + *
    • A Parse.Error.AGGREGATE_ERROR. This object's "errors" property is an + * array of other Parse.Error objects. Each error object in this array + * has an "object" property that references the object that could not be + * deleted (for instance, because that object could not be found).
    • + *
    • A non-aggregate Parse.Error. This indicates a serious error that + * caused the delete operation to be aborted partway through (for + * instance, a connection failure in the middle of the delete).
    • + *
    + * + *
    +     * Parse.Object.destroyAll([object1, object2, ...])
    +     * .then((list) => {
    +     * // All the objects were deleted.
    +     * }, (error) => {
    +     * // An error occurred while deleting one or more of the objects.
    +     * // If this is an aggregate error, then we can inspect each error
    +     * // object individually to determine the reason why a particular
    +     * // object was not deleted.
    +     * if (error.code === Parse.Error.AGGREGATE_ERROR) {
    +     * for (var i = 0; i < error.errors.length; i++) {
    +     * console.log("Couldn't delete " + error.errors[i].object.id +
    +     * "due to " + error.errors[i].message);
    +     * }
    +     * } else {
    +     * console.log("Delete aborted because of " + error.message);
    +     * }
    +     * });
    +     * 
    + * + * @param {Array} list A list of Parse.Object. + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers. + *
    • transaction: Set to true to enable transactions + *
    • batchSize: How many objects to yield in each batch (default: 20) + *
    + * @static + * @returns {Promise} A promise that is fulfilled when the destroyAll + * completes. + */ + static destroyAll(list: Array, options?: SaveOptions): Promise; + /** + * Saves the given list of Parse.Object. + * If any error is encountered, stops and calls the error handler. + * + *
    +     * Parse.Object.saveAll([object1, object2, ...])
    +     * .then((list) => {
    +     * // All the objects were saved.
    +     * }, (error) => {
    +     * // An error occurred while saving one of the objects.
    +     * });
    +     * 
    + * + * @param {Array} list A list of Parse.Object. + * @param {object} options + * Valid options are: + *
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • cascadeSave: If `false`, nested objects will not be saved (default is `true`). + *
    • context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers. + *
    • transaction: Set to true to enable transactions + *
    • batchSize: How many objects to yield in each batch (default: 20) + *
    + * @static + * @returns {Parse.Object[]} + */ + static saveAll(list: Array, options?: SaveOptions): Promise; + /** + * Creates a reference to a subclass of Parse.Object with the given id. This + * does not exist on Parse.Object, only on subclasses. + * + *

    A shortcut for:

    +     *  var Foo = Parse.Object.extend("Foo");
    +     *  var pointerToFoo = new Foo();
    +     *  pointerToFoo.id = "myObjectId";
    +     * 
    + * + * @param {string} id The ID of the object to create a reference to. + * @static + * @returns {Parse.Object} A Parse.Object reference. + */ + static createWithoutData(id: string): ParseObject; + /** + * Creates a new instance of a Parse Object from a JSON representation. + * + * @param {object} json The JSON map of the Object's data + * @param {boolean} override In single instance mode, all old server data + * is overwritten if this is set to true + * @param {boolean} dirty Whether the Parse.Object should set JSON keys to dirty + * @static + * @returns {Parse.Object} A Parse.Object reference + */ + static fromJSON(json: any, override?: boolean, dirty?: boolean): ParseObject; + /** + * Registers a subclass of Parse.Object with a specific class name. + * When objects of that class are retrieved from a query, they will be + * instantiated with this subclass. + * This is only necessary when using ES6 subclassing. + * + * @param {string} className The class name of the subclass + * @param {Function} constructor The subclass + */ + static registerSubclass(className: string, constructor: any): void; + /** + * Unegisters a subclass of Parse.Object with a specific class name. + * + * @param {string} className The class name of the subclass + */ + static unregisterSubclass(className: string): void; + /** + * Creates a new subclass of Parse.Object for the given Parse class name. + * + *

    Every extension of a Parse class will inherit from the most recent + * previous extension of that class. When a Parse.Object is automatically + * created by parsing JSON, it will use the most recent extension of that + * class.

    + * + *

    You should call either:

    +     *     var MyClass = Parse.Object.extend("MyClass", {
    +     *         Instance methods,
    +     *         initialize: function(attrs, options) {
    +     *             this.someInstanceProperty = [],
    +     *             Other instance properties
    +     *         }
    +     *     }, {
    +     *         Class properties
    +     *     });
    + * or, for Backbone compatibility:
    +     *     var MyClass = Parse.Object.extend({
    +     *         className: "MyClass",
    +     *         Instance methods,
    +     *         initialize: function(attrs, options) {
    +     *             this.someInstanceProperty = [],
    +     *             Other instance properties
    +     *         }
    +     *     }, {
    +     *         Class properties
    +     *     });

    + * + * @param {string} className The name of the Parse class backing this model. + * @param {object} [protoProps] Instance properties to add to instances of the + * class returned from this method. + * @param {object} [classProps] Class properties to add the class returned from + * this method. + * @returns {Parse.Object} A new subclass of Parse.Object. + */ + static extend(className: any, protoProps?: any, classProps?: any): any; + /** + * Enable single instance objects, where any local objects with the same Id + * share the same attributes, and stay synchronized with each other. + * This is disabled by default in server environments, since it can lead to + * security issues. + * + * @static + */ + static enableSingleInstance(): void; + /** + * Disable single instance objects, where any local objects with the same Id + * share the same attributes, and stay synchronized with each other. + * When disabled, you can have two instances of the same object in memory + * without them sharing attributes. + * + * @static + */ + static disableSingleInstance(): void; + /** + * Asynchronously stores the objects and every object they point to in the local datastore, + * recursively, using a default pin name: _default. + * + * If those other objects have not been fetched from Parse, they will not be stored. + * However, if they have changed data, all the changes will be retained. + * + *
    +     * await Parse.Object.pinAll([...]);
    +     * 
    + * + * To retrieve object: + * query.fromLocalDatastore() or query.fromPin() + * + * @param {Array} objects A list of Parse.Object. + * @returns {Promise} A promise that is fulfilled when the pin completes. + * @static + */ + static pinAll(objects: Array): Promise; + /** + * Asynchronously stores the objects and every object they point to in the local datastore, recursively. + * + * If those other objects have not been fetched from Parse, they will not be stored. + * However, if they have changed data, all the changes will be retained. + * + *
    +     * await Parse.Object.pinAllWithName(name, [obj1, obj2, ...]);
    +     * 
    + * + * To retrieve object: + * query.fromLocalDatastore() or query.fromPinWithName(name) + * + * @param {string} name Name of Pin. + * @param {Array} objects A list of Parse.Object. + * @returns {Promise} A promise that is fulfilled when the pin completes. + * @static + */ + static pinAllWithName(name: string, objects: Array): Promise; + /** + * Asynchronously removes the objects and every object they point to in the local datastore, + * recursively, using a default pin name: _default. + * + *
    +     * await Parse.Object.unPinAll([...]);
    +     * 
    + * + * @param {Array} objects A list of Parse.Object. + * @returns {Promise} A promise that is fulfilled when the unPin completes. + * @static + */ + static unPinAll(objects: Array): Promise; + /** + * Asynchronously removes the objects and every object they point to in the local datastore, recursively. + * + *
    +     * await Parse.Object.unPinAllWithName(name, [obj1, obj2, ...]);
    +     * 
    + * + * @param {string} name Name of Pin. + * @param {Array} objects A list of Parse.Object. + * @returns {Promise} A promise that is fulfilled when the unPin completes. + * @static + */ + static unPinAllWithName(name: string, objects: Array): Promise; + /** + * Asynchronously removes all objects in the local datastore using a default pin name: _default. + * + *
    +     * await Parse.Object.unPinAllObjects();
    +     * 
    + * + * @returns {Promise} A promise that is fulfilled when the unPin completes. + * @static + */ + static unPinAllObjects(): Promise; + /** + * Asynchronously removes all objects with the specified pin name. + * Deletes the pin name also. + * + *
    +     * await Parse.Object.unPinAllObjectsWithName(name);
    +     * 
    + * + * @param {string} name Name of Pin. + * @returns {Promise} A promise that is fulfilled when the unPin completes. + * @static + */ + static unPinAllObjectsWithName(name: string): Promise; } export default ParseObject; diff --git a/types/ParseOp.d.ts b/types/ParseOp.d.ts index a7ad4a411..1ffd8bbc8 100644 --- a/types/ParseOp.d.ts +++ b/types/ParseOp.d.ts @@ -1,76 +1,78 @@ import type ParseObject from './ParseObject'; import ParseRelation from './ParseRelation'; -export declare function opFromJSON(json: { [key: string]: any }): Op | null; +export declare function opFromJSON(json: { + [key: string]: any; +}): Op | null; export declare class Op { - applyTo(value: any): any; - mergeWith(previous: Op): Op | void; - toJSON(offline?: boolean): any; + applyTo(value: any): any; + mergeWith(previous: Op): Op | void; + toJSON(offline?: boolean): any; } export declare class SetOp extends Op { - _value: any; - constructor(value: any); - applyTo(): any; - mergeWith(): SetOp; - toJSON(offline?: boolean): any; + _value: any; + constructor(value: any); + applyTo(): any; + mergeWith(): SetOp; + toJSON(offline?: boolean): any; } export declare class UnsetOp extends Op { - applyTo(): any; - mergeWith(): UnsetOp; - toJSON(): { - __op: string; - }; + applyTo(): any; + mergeWith(): UnsetOp; + toJSON(): { + __op: string; + }; } export declare class IncrementOp extends Op { - _amount: number; - constructor(amount: number); - applyTo(value: any): number; - mergeWith(previous: Op): Op; - toJSON(): { - __op: string; - amount: number; - }; + _amount: number; + constructor(amount: number); + applyTo(value: any): number; + mergeWith(previous: Op): Op; + toJSON(): { + __op: string; + amount: number; + }; } export declare class AddOp extends Op { - _value: Array; - constructor(value: any | Array); - applyTo(value: any): Array; - mergeWith(previous: Op): Op; - toJSON(): { - __op: string; - objects: any; - }; + _value: Array; + constructor(value: any | Array); + applyTo(value: any): Array; + mergeWith(previous: Op): Op; + toJSON(): { + __op: string; + objects: any; + }; } export declare class AddUniqueOp extends Op { - _value: Array; - constructor(value: any | Array); - applyTo(value: any | Array): Array; - mergeWith(previous: Op): Op; - toJSON(): { - __op: string; - objects: any; - }; + _value: Array; + constructor(value: any | Array); + applyTo(value: any | Array): Array; + mergeWith(previous: Op): Op; + toJSON(): { + __op: string; + objects: any; + }; } export declare class RemoveOp extends Op { - _value: Array; - constructor(value: any | Array); - applyTo(value: any | Array): Array; - mergeWith(previous: Op): Op; - toJSON(): { - __op: string; - objects: any; - }; + _value: Array; + constructor(value: any | Array); + applyTo(value: any | Array): Array; + mergeWith(previous: Op): Op; + toJSON(): { + __op: string; + objects: any; + }; } export declare class RelationOp extends Op { - _targetClassName: string | null; - relationsToAdd: Array; - relationsToRemove: Array; - constructor(adds: Array, removes: Array); - _extractId(obj: string | ParseObject): string; - applyTo(value: any, parent?: ParseObject, key?: string): ParseRelation; - mergeWith(previous: Op): Op; - toJSON(): { - __op?: string; - objects?: any; - ops?: any; - }; + _targetClassName: string | null; + relationsToAdd: Array; + relationsToRemove: Array; + constructor(adds: Array, removes: Array); + _extractId(obj: string | ParseObject): string; + applyTo(value: any, parent?: ParseObject, key?: string): ParseRelation; + mergeWith(previous: Op): Op; + toJSON(): { + __op?: string; + objects?: any; + ops?: any; + }; } diff --git a/types/ParsePolygon.d.ts b/types/ParsePolygon.d.ts index 3baabb14c..28d4b07d2 100644 --- a/types/ParsePolygon.d.ts +++ b/types/ParsePolygon.d.ts @@ -21,49 +21,49 @@ type Coordinates = Coordinate[]; * @alias Parse.Polygon */ declare class ParsePolygon { - _coordinates: Coordinates; - /** - * @param {(Coordinates | Parse.GeoPoint[])} coordinates An Array of coordinate pairs - */ - constructor(coordinates: Coordinates | Array); - /** - * Coordinates value for this Polygon. - * Throws an exception if not valid type. - * - * @property {(Coordinates | Parse.GeoPoint[])} coordinates list of coordinates - * @returns {Coordinates} - */ - get coordinates(): Coordinates; - set coordinates(coords: Coordinates | Array); - /** - * Returns a JSON representation of the Polygon, suitable for Parse. - * - * @returns {object} - */ - toJSON(): { - __type: string; - coordinates: Coordinates; - }; - /** - * Checks if two polygons are equal - * - * @param {(Parse.Polygon | object)} other - * @returns {boolean} - */ - equals(other: ParsePolygon | any): boolean; - /** - * - * @param {Parse.GeoPoint} point - * @returns {boolean} Returns if the point is contained in the polygon - */ - containsPoint(point: ParseGeoPoint): boolean; - /** - * Validates that the list of coordinates can form a valid polygon - * - * @param {Array} coords the list of coordinates to validate as a polygon - * @throws {TypeError} - * @returns {number[][]} Array of coordinates if validated. - */ - static _validate(coords: Coordinates | Array): Coordinates; + _coordinates: Coordinates; + /** + * @param {(Coordinates | Parse.GeoPoint[])} coordinates An Array of coordinate pairs + */ + constructor(coordinates: Coordinates | Array); + /** + * Coordinates value for this Polygon. + * Throws an exception if not valid type. + * + * @property {(Coordinates | Parse.GeoPoint[])} coordinates list of coordinates + * @returns {Coordinates} + */ + get coordinates(): Coordinates; + set coordinates(coords: Coordinates | Array); + /** + * Returns a JSON representation of the Polygon, suitable for Parse. + * + * @returns {object} + */ + toJSON(): { + __type: string; + coordinates: Coordinates; + }; + /** + * Checks if two polygons are equal + * + * @param {(Parse.Polygon | object)} other + * @returns {boolean} + */ + equals(other: ParsePolygon | any): boolean; + /** + * + * @param {Parse.GeoPoint} point + * @returns {boolean} Returns if the point is contained in the polygon + */ + containsPoint(point: ParseGeoPoint): boolean; + /** + * Validates that the list of coordinates can form a valid polygon + * + * @param {Array} coords the list of coordinates to validate as a polygon + * @throws {TypeError} + * @returns {number[][]} Array of coordinates if validated. + */ + static _validate(coords: Coordinates | Array): Coordinates; } export default ParsePolygon; diff --git a/types/ParseQuery.d.ts b/types/ParseQuery.d.ts index 968f13f80..99b44a721 100644 --- a/types/ParseQuery.d.ts +++ b/types/ParseQuery.d.ts @@ -3,47 +3,47 @@ import ParseObject from './ParseObject'; import type LiveQuerySubscription from './LiveQuerySubscription'; import type { FullOptions } from './RESTController'; type BatchOptions = FullOptions & { - batchSize?: number; - useMasterKey?: boolean; - sessionToken?: string; - context?: { - [key: string]: any; - }; - json?: boolean; + batchSize?: number; + useMasterKey?: boolean; + sessionToken?: string; + context?: { + [key: string]: any; + }; + json?: boolean; }; export type WhereClause = { - [attr: string]: any; + [attr: string]: any; }; type QueryOptions = { - useMasterKey?: boolean; - sessionToken?: string; - context?: { - [key: string]: any; - }; - json?: boolean; + useMasterKey?: boolean; + sessionToken?: string; + context?: { + [key: string]: any; + }; + json?: boolean; }; type FullTextQueryOptions = { - language?: string; - caseSensitive?: boolean; - diacriticSensitive?: boolean; + language?: string; + caseSensitive?: boolean; + diacriticSensitive?: boolean; }; export type QueryJSON = { - where: WhereClause; - watch?: string; - include?: string; - excludeKeys?: string; - keys?: string; - limit?: number; - skip?: number; - order?: string; - className?: string; - count?: number; - hint?: any; - explain?: boolean; - readPreference?: string; - includeReadPreference?: string; - subqueryReadPreference?: string; - comment?: string; + where: WhereClause; + watch?: string; + include?: string; + excludeKeys?: string; + keys?: string; + limit?: number; + skip?: number; + order?: string; + className?: string; + count?: number; + hint?: any; + explain?: boolean; + readPreference?: string; + includeReadPreference?: string; + subqueryReadPreference?: string; + comment?: string; }; /** * Creates a new parse Parse.Query for the given Parse.Object subclass. @@ -89,907 +89,870 @@ export type QueryJSON = { * @alias Parse.Query */ declare class ParseQuery { - /** - * @property {string} className - */ - className: string; - _where: any; - _watch: Array; - _include: Array; - _exclude: Array; - _select: Array; - _limit: number; - _skip: number; - _count: boolean; - _order: Array; - _readPreference: string | null; - _includeReadPreference: string | null; - _subqueryReadPreference: string | null; - _queriesLocalDatastore: boolean; - _localDatastorePinName: any; - _extraOptions: { - [key: string]: any; - }; - _hint: any; - _explain: boolean; - _xhrRequest: any; - _comment: string; - /** - * @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string. - */ - constructor(objectClass: string | ParseObject); - /** - * Adds constraint that at least one of the passed in queries matches. - * - * @param {Array} queries - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - _orQuery(queries: Array): ParseQuery; - /** - * Adds constraint that all of the passed in queries match. - * - * @param {Array} queries - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - _andQuery(queries: Array): ParseQuery; - /** - * Adds constraint that none of the passed in queries match. - * - * @param {Array} queries - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - _norQuery(queries: Array): ParseQuery; - /** - * Helper for condition queries - * - * @param key - * @param condition - * @param value - * @returns {Parse.Query} - */ - _addCondition(key: string, condition: string, value: any): ParseQuery; - /** - * Converts string for regular expression at the beginning - * - * @param string - * @returns {string} - */ - _regexStartWith(string: string): string; - _handleOfflineQuery(params: QueryJSON): Promise; - /** - * Returns a JSON representation of this query. - * - * @returns {object} The JSON representation of the query. - */ - toJSON(): QueryJSON; - /** - * Return a query with conditions from json, can be useful to send query from server side to client - * Not static, all query conditions was set before calling this method will be deleted. - * For example on the server side we have - * var query = new Parse.Query("className"); - * query.equalTo(key: value); - * query.limit(100); - * ... (others queries) - * Create JSON representation of Query Object - * var jsonFromServer = query.fromJSON(); - * - * On client side getting query: - * var query = new Parse.Query("className"); - * query.fromJSON(jsonFromServer); - * - * and continue to query... - * query.skip(100).find().then(...); - * - * @param {QueryJSON} json from Parse.Query.toJSON() method - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - withJSON(json: QueryJSON): ParseQuery; - /** - * Static method to restore Parse.Query by json representation - * Internally calling Parse.Query.withJSON - * - * @param {string} className - * @param {QueryJSON} json from Parse.Query.toJSON() method - * @returns {Parse.Query} new created query - */ - static fromJSON(className: string, json: QueryJSON): ParseQuery; - /** - * Constructs a Parse.Object whose id is already known by fetching data from - * the server. Unlike the first method, it never returns undefined. - * - * @param {string} objectId The id of the object to be fetched. - * @param {object} options - * Valid options are:
      - *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
    • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. - *
    • json: Return raw json without converting to Parse.Object - *
    - * @returns {Promise} A promise that is resolved with the result when - * the query completes. - */ - get(objectId: string, options?: QueryOptions): Promise; - /** - * Retrieves a list of ParseObjects that satisfy this query. - * - * @param {object} options Valid options - * are:
      - *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
    • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. - *
    • json: Return raw json without converting to Parse.Object - *
    - * @returns {Promise} A promise that is resolved with the results when - * the query completes. - */ - find(options?: QueryOptions): Promise>; - /** - * Retrieves a complete list of ParseObjects that satisfy this query. - * Using `eachBatch` under the hood to fetch all the valid objects. - * - * @param {object} options Valid options are:
      - *
    • batchSize: How many objects to yield in each batch (default: 100) - *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
    • json: Return raw JSON without converting to Parse.Object. - *
    - * @returns {Promise} A promise that is resolved with the results when - * the query completes. - */ - findAll(options?: BatchOptions): Promise>; - /** - * Counts the number of objects that match this query. - * - * @param {object} options - * @param {boolean} [options.useMasterKey] - * @param {string} [options.sessionToken] - * Valid options are:
      - *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
    - * @returns {Promise} A promise that is resolved with the count when - * the query completes. - */ - count(options?: { useMasterKey?: boolean; sessionToken?: string }): Promise; - /** - * Executes a distinct query and returns unique values - * - * @param {string} key A field to find distinct values - * @param {object} options - * @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user. - * @returns {Promise} A promise that is resolved with the query completes. - */ - distinct( - key: string, - options?: { - sessionToken?: string; - } - ): Promise>; - /** - * Executes an aggregate query and returns aggregate results - * - * @param {(Array|object)} pipeline Array or Object of stages to process query - * @param {object} options - * @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user. - * @returns {Promise} A promise that is resolved with the query completes. - */ - aggregate( - pipeline: any, - options?: { - sessionToken?: string; - } - ): Promise>; - /** - * Retrieves at most one Parse.Object that satisfies this query. - * - * Returns the object if there is one, otherwise undefined. - * - * @param {object} options Valid options are:
      - *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
    • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. - *
    • json: Return raw json without converting to Parse.Object - *
    - * @returns {Promise} A promise that is resolved with the object when - * the query completes. - */ - first(options?: QueryOptions): Promise; - /** - * Iterates over objects matching a query, calling a callback for each batch. - * If the callback returns a promise, the iteration will not continue until - * that promise has been fulfilled. If the callback returns a rejected - * promise, then iteration will stop with that error. The items are processed - * in an unspecified order. The query may not have any sort order, and may - * not use limit or skip. - * - * @param {Function} callback Callback that will be called with each result - * of the query. - * @param {object} options Valid options are:
      - *
    • batchSize: How many objects to yield in each batch (default: 100) - *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
    • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. - *
    - * @returns {Promise} A promise that will be fulfilled once the - * iteration has completed. - */ - eachBatch(callback: (objs: Array) => void, options?: BatchOptions): Promise; - /** - * Iterates over each result of a query, calling a callback for each one. If - * the callback returns a promise, the iteration will not continue until - * that promise has been fulfilled. If the callback returns a rejected - * promise, then iteration will stop with that error. The items are - * processed in an unspecified order. The query may not have any sort order, - * and may not use limit or skip. - * - * @param {Function} callback Callback that will be called with each result - * of the query. - * @param {object} options Valid options are:
      - *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
    • json: Return raw json without converting to Parse.Object - *
    - * @returns {Promise} A promise that will be fulfilled once the - * iteration has completed. - */ - each(callback: (obj: ParseObject) => any, options?: BatchOptions): Promise; - /** - * Adds a hint to force index selection. (https://docs.mongodb.com/manual/reference/operator/meta/hint/) - * - * @param {(string|object)} value String or Object of index that should be used when executing query - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - hint(value: any): ParseQuery; - /** - * Investigates the query execution plan. Useful for optimizing queries. (https://docs.mongodb.com/manual/reference/operator/meta/explain/) - * - * @param {boolean} explain Used to toggle the information on the query plan. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - explain(explain?: boolean): ParseQuery; - /** - * Iterates over each result of a query, calling a callback for each one. If - * the callback returns a promise, the iteration will not continue until - * that promise has been fulfilled. If the callback returns a rejected - * promise, then iteration will stop with that error. The items are - * processed in an unspecified order. The query may not have any sort order, - * and may not use limit or skip. - * - * @param {Function} callback Callback
      - *
    • currentObject: The current Parse.Object being processed in the array.
    • - *
    • index: The index of the current Parse.Object being processed in the array.
    • - *
    • query: The query map was called upon.
    • - *
    - * @param {object} options Valid options are:
      - *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
    - * @returns {Promise} A promise that will be fulfilled once the - * iteration has completed. - */ - map( - callback: (currentObject: ParseObject, index: number, query: ParseQuery) => any, - options?: BatchOptions - ): Promise>; - /** - * Iterates over each result of a query, calling a callback for each one. If - * the callback returns a promise, the iteration will not continue until - * that promise has been fulfilled. If the callback returns a rejected - * promise, then iteration will stop with that error. The items are - * processed in an unspecified order. The query may not have any sort order, - * and may not use limit or skip. - * - * @param {Function} callback Callback
      - *
    • accumulator: The accumulator accumulates the callback's return values. It is the accumulated value previously returned in the last invocation of the callback.
    • - *
    • currentObject: The current Parse.Object being processed in the array.
    • - *
    • index: The index of the current Parse.Object being processed in the array.
    • - *
    - * @param {*} initialValue A value to use as the first argument to the first call of the callback. If no initialValue is supplied, the first object in the query will be used and skipped. - * @param {object} options Valid options are:
      - *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
    - * @returns {Promise} A promise that will be fulfilled once the - * iteration has completed. - */ - reduce( - callback: (accumulator: any, currentObject: ParseObject, index: number) => any, - initialValue: any, - options?: BatchOptions - ): Promise>; - /** - * Iterates over each result of a query, calling a callback for each one. If - * the callback returns a promise, the iteration will not continue until - * that promise has been fulfilled. If the callback returns a rejected - * promise, then iteration will stop with that error. The items are - * processed in an unspecified order. The query may not have any sort order, - * and may not use limit or skip. - * - * @param {Function} callback Callback
      - *
    • currentObject: The current Parse.Object being processed in the array.
    • - *
    • index: The index of the current Parse.Object being processed in the array.
    • - *
    • query: The query filter was called upon.
    • - *
    - * @param {object} options Valid options are:
      - *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    • sessionToken: A valid session token, used for making a request on - * behalf of a specific user. - *
    - * @returns {Promise} A promise that will be fulfilled once the - * iteration has completed. - */ - filter( - callback: (currentObject: ParseObject, index: number, query: ParseQuery) => boolean, - options?: BatchOptions - ): Promise>; - /** - * Adds a constraint to the query that requires a particular key's value to - * be equal to the provided value. - * - * @param {string} key The key to check. - * @param value The value that the Parse.Object must contain. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - equalTo( - key: - | string - | { - [key: string]: any; - }, - value?: any - ): ParseQuery; - /** - * Adds a constraint to the query that requires a particular key's value to - * be not equal to the provided value. - * - * @param {string} key The key to check. - * @param value The value that must not be equalled. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - notEqualTo( - key: - | string - | { - [key: string]: any; - }, - value?: any - ): ParseQuery; - /** - * Adds a constraint to the query that requires a particular key's value to - * be less than the provided value. - * - * @param {string} key The key to check. - * @param value The value that provides an upper bound. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - lessThan(key: string, value: any): ParseQuery; - /** - * Adds a constraint to the query that requires a particular key's value to - * be greater than the provided value. - * - * @param {string} key The key to check. - * @param value The value that provides an lower bound. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - greaterThan(key: string, value: any): ParseQuery; - /** - * Adds a constraint to the query that requires a particular key's value to - * be less than or equal to the provided value. - * - * @param {string} key The key to check. - * @param value The value that provides an upper bound. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - lessThanOrEqualTo(key: string, value: any): ParseQuery; - /** - * Adds a constraint to the query that requires a particular key's value to - * be greater than or equal to the provided value. - * - * @param {string} key The key to check. - * @param {*} value The value that provides an lower bound. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - greaterThanOrEqualTo(key: string, value: any): ParseQuery; - /** - * Adds a constraint to the query that requires a particular key's value to - * be contained in the provided list of values. - * - * @param {string} key The key to check. - * @param {Array<*>} value The values that will match. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - containedIn(key: string, value: Array): ParseQuery; - /** - * Adds a constraint to the query that requires a particular key's value to - * not be contained in the provided list of values. - * - * @param {string} key The key to check. - * @param {Array<*>} value The values that will not match. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - notContainedIn(key: string, value: Array): ParseQuery; - /** - * Adds a constraint to the query that requires a particular key's value to - * be contained by the provided list of values. Get objects where all array elements match. - * - * @param {string} key The key to check. - * @param {Array} values The values that will match. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - containedBy(key: string, values: Array): ParseQuery; - /** - * Adds a constraint to the query that requires a particular key's value to - * contain each one of the provided list of values. - * - * @param {string} key The key to check. This key's value must be an array. - * @param {Array} values The values that will match. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - containsAll(key: string, values: Array): ParseQuery; - /** - * Adds a constraint to the query that requires a particular key's value to - * contain each one of the provided list of values starting with given strings. - * - * @param {string} key The key to check. This key's value must be an array. - * @param {Array} values The string values that will match as starting string. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - containsAllStartingWith(key: string, values: Array): ParseQuery; - /** - * Adds a constraint for finding objects that contain the given key. - * - * @param {string} key The key that should exist. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - exists(key: string): ParseQuery; - /** - * Adds a constraint for finding objects that do not contain a given key. - * - * @param {string} key The key that should not exist - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - doesNotExist(key: string): ParseQuery; - /** - * Adds a regular expression constraint for finding string values that match - * the provided regular expression. - * This may be slow for large datasets. - * - * @param {string} key The key that the string to match is stored in. - * @param {RegExp | string} regex The regular expression pattern to match. - * @param {string} modifiers The regular expression mode. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - matches(key: string, regex: RegExp | string, modifiers: string): ParseQuery; - /** - * Adds a constraint that requires that a key's value matches a Parse.Query - * constraint. - * - * @param {string} key The key that the contains the object to match the - * query. - * @param {Parse.Query} query The query that should match. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - matchesQuery(key: string, query: ParseQuery): ParseQuery; - /** - * Adds a constraint that requires that a key's value not matches a - * Parse.Query constraint. - * - * @param {string} key The key that the contains the object to match the - * query. - * @param {Parse.Query} query The query that should not match. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - doesNotMatchQuery(key: string, query: ParseQuery): ParseQuery; - /** - * Adds a constraint that requires that a key's value matches a value in - * an object returned by a different Parse.Query. - * - * @param {string} key The key that contains the value that is being - * matched. - * @param {string} queryKey The key in the objects returned by the query to - * match against. - * @param {Parse.Query} query The query to run. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - matchesKeyInQuery(key: string, queryKey: string, query: ParseQuery): ParseQuery; - /** - * Adds a constraint that requires that a key's value not match a value in - * an object returned by a different Parse.Query. - * - * @param {string} key The key that contains the value that is being - * excluded. - * @param {string} queryKey The key in the objects returned by the query to - * match against. - * @param {Parse.Query} query The query to run. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - doesNotMatchKeyInQuery(key: string, queryKey: string, query: ParseQuery): ParseQuery; - /** - * Adds a constraint for finding string values that contain a provided - * string. This may be slow for large datasets. - * - * @param {string} key The key that the string to match is stored in. - * @param {string} substring The substring that the value must contain. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - contains(key: string, substring: string): ParseQuery; - /** - * Adds a constraint for finding string values that contain a provided - * string. This may be slow for large datasets. Requires Parse-Server > 2.5.0 - * - * In order to sort you must use select and ascending ($score is required) - *
    -   *   query.fullText('field', 'term');
    -   *   query.ascending('$score');
    -   *   query.select('$score');
    -   *  
    - * - * To retrieve the weight / rank - *
    -   *   object->get('score');
    -   *  
    - * - * You can define optionals by providing an object as a third parameter - *
    -   *   query.fullText('field', 'term', { language: 'es', diacriticSensitive: true });
    -   *  
    - * - * @param {string} key The key that the string to match is stored in. - * @param {string} value The string to search - * @param {object} options (Optional) - * @param {string} options.language The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer. - * @param {boolean} options.caseSensitive A boolean flag to enable or disable case sensitive search. - * @param {boolean} options.diacriticSensitive A boolean flag to enable or disable diacritic sensitive search. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - fullText(key: string, value: string, options?: FullTextQueryOptions): ParseQuery; - /** - * Method to sort the full text search by text score - * - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - sortByTextScore(): this; - /** - * Adds a constraint for finding string values that start with a provided - * string. This query will use the backend index, so it will be fast even - * for large datasets. - * - * @param {string} key The key that the string to match is stored in. - * @param {string} prefix The substring that the value must start with. - * @param {string} modifiers The regular expression mode. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - startsWith(key: string, prefix: string, modifiers: string): ParseQuery; - /** - * Adds a constraint for finding string values that end with a provided - * string. This will be slow for large datasets. - * - * @param {string} key The key that the string to match is stored in. - * @param {string} suffix The substring that the value must end with. - * @param {string} modifiers The regular expression mode. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - endsWith(key: string, suffix: string, modifiers: string): ParseQuery; - /** - * Adds a proximity based constraint for finding objects with key point - * values near the point given. - * - * @param {string} key The key that the Parse.GeoPoint is stored in. - * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - near(key: string, point: ParseGeoPoint): ParseQuery; - /** - * Adds a proximity based constraint for finding objects with key point - * values near the point given and within the maximum distance given. - * - * @param {string} key The key that the Parse.GeoPoint is stored in. - * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used. - * @param {number} maxDistance Maximum distance (in radians) of results to return. - * @param {boolean} sorted A Bool value that is true if results should be - * sorted by distance ascending, false is no sorting is required, - * defaults to true. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - withinRadians( - key: string, - point: ParseGeoPoint, - maxDistance: number, - sorted: boolean - ): ParseQuery; - /** - * Adds a proximity based constraint for finding objects with key point - * values near the point given and within the maximum distance given. - * Radius of earth used is 3958.8 miles. - * - * @param {string} key The key that the Parse.GeoPoint is stored in. - * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used. - * @param {number} maxDistance Maximum distance (in miles) of results to return. - * @param {boolean} sorted A Bool value that is true if results should be - * sorted by distance ascending, false is no sorting is required, - * defaults to true. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - withinMiles(key: string, point: ParseGeoPoint, maxDistance: number, sorted: boolean): ParseQuery; - /** - * Adds a proximity based constraint for finding objects with key point - * values near the point given and within the maximum distance given. - * Radius of earth used is 6371.0 kilometers. - * - * @param {string} key The key that the Parse.GeoPoint is stored in. - * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used. - * @param {number} maxDistance Maximum distance (in kilometers) of results to return. - * @param {boolean} sorted A Bool value that is true if results should be - * sorted by distance ascending, false is no sorting is required, - * defaults to true. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - withinKilometers( - key: string, - point: ParseGeoPoint, - maxDistance: number, - sorted: boolean - ): ParseQuery; - /** - * Adds a constraint to the query that requires a particular key's - * coordinates be contained within a given rectangular geographic bounding - * box. - * - * @param {string} key The key to be constrained. - * @param {Parse.GeoPoint} southwest - * The lower-left inclusive corner of the box. - * @param {Parse.GeoPoint} northeast - * The upper-right inclusive corner of the box. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - withinGeoBox(key: string, southwest: ParseGeoPoint, northeast: ParseGeoPoint): ParseQuery; - /** - * Adds a constraint to the query that requires a particular key's - * coordinates be contained within and on the bounds of a given polygon. - * Supports closed and open (last point is connected to first) paths - * - * Polygon must have at least 3 points - * - * @param {string} key The key to be constrained. - * @param {Array} points Array of Coordinates / GeoPoints - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - withinPolygon(key: string, points: Array>): ParseQuery; - /** - * Add a constraint to the query that requires a particular key's - * coordinates that contains a ParseGeoPoint - * - * @param {string} key The key to be constrained. - * @param {Parse.GeoPoint} point - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - polygonContains(key: string, point: ParseGeoPoint): ParseQuery; - /** - * Sorts the results in ascending order by the given key. - * - * @param {(string|string[])} keys The key to order by, which is a - * string of comma separated values, or an Array of keys, or multiple keys. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - ascending(...keys: Array): ParseQuery; - /** - * Sorts the results in ascending order by the given key, - * but can also add secondary sort descriptors without overwriting _order. - * - * @param {(string|string[])} keys The key to order by, which is a - * string of comma separated values, or an Array of keys, or multiple keys. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - addAscending(...keys: Array): ParseQuery; - /** - * Sorts the results in descending order by the given key. - * - * @param {(string|string[])} keys The key to order by, which is a - * string of comma separated values, or an Array of keys, or multiple keys. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - descending(...keys: Array): ParseQuery; - /** - * Sorts the results in descending order by the given key, - * but can also add secondary sort descriptors without overwriting _order. - * - * @param {(string|string[])} keys The key to order by, which is a - * string of comma separated values, or an Array of keys, or multiple keys. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - addDescending(...keys: Array): ParseQuery; - /** - * Sets the number of results to skip before returning any results. - * This is useful for pagination. - * Default is to skip zero results. - * - * @param {number} n the number of results to skip. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - skip(n: number): ParseQuery; - /** - * Sets the limit of the number of results to return. The default limit is 100. - * - * @param {number} n the number of results to limit to. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - limit(n: number): ParseQuery; - /** - * Sets the flag to include with response the total number of objects satisfying this query, - * despite limits/skip. Might be useful for pagination. - * Note that result of this query will be wrapped as an object with - * `results`: holding {ParseObject} array and `count`: integer holding total number - * - * @param {boolean} includeCount false - disable, true - enable. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - withCount(includeCount?: boolean): ParseQuery; - /** - * Includes nested Parse.Objects for the provided key. You can use dot - * notation to specify which fields in the included object are also fetched. - * - * You can include all nested Parse.Objects by passing in '*'. - * Requires Parse Server 3.0.0+ - *
    query.include('*');
    - * - * @param {...string|Array} keys The name(s) of the key(s) to include. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - include(...keys: Array>): ParseQuery; - /** - * Includes all nested Parse.Objects one level deep. - * - * Requires Parse Server 3.0.0+ - * - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - includeAll(): ParseQuery; - /** - * Restricts the fields of the returned Parse.Objects to include only the - * provided keys. If this is called multiple times, then all of the keys - * specified in each of the calls will be included. - * - * @param {...string|Array} keys The name(s) of the key(s) to include. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - select(...keys: Array>): ParseQuery; - /** - * Restricts the fields of the returned Parse.Objects to all keys except the - * provided keys. Exclude takes precedence over select and include. - * - * Requires Parse Server 3.6.0+ - * - * @param {...string|Array} keys The name(s) of the key(s) to exclude. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - exclude(...keys: Array>): ParseQuery; - /** - * Restricts live query to trigger only for watched fields. - * - * Requires Parse Server 6.0.0+ - * - * @param {...string|Array} keys The name(s) of the key(s) to watch. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - watch(...keys: Array>): ParseQuery; - /** - * Changes the read preference that the backend will use when performing the query to the database. - * - * @param {string} readPreference The read preference for the main query. - * @param {string} includeReadPreference The read preference for the queries to include pointers. - * @param {string} subqueryReadPreference The read preference for the sub queries. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - readPreference( - readPreference: string, - includeReadPreference?: string, - subqueryReadPreference?: string - ): ParseQuery; - /** - * Subscribe this query to get liveQuery updates - * - * @param {string} sessionToken (optional) Defaults to the currentUser - * @returns {Promise} Returns the liveQuerySubscription, it's an event emitter - * which can be used to get liveQuery updates. - */ - subscribe(sessionToken?: string): Promise; - /** - * Constructs a Parse.Query that is the OR of the passed in queries. For - * example: - *
    var compoundQuery = Parse.Query.or(query1, query2, query3);
    - * - * will create a compoundQuery that is an or of the query1, query2, and - * query3. - * - * @param {...Parse.Query} queries The list of queries to OR. - * @static - * @returns {Parse.Query} The query that is the OR of the passed in queries. - */ - static or(...queries: Array): ParseQuery; - /** - * Constructs a Parse.Query that is the AND of the passed in queries. For - * example: - *
    var compoundQuery = Parse.Query.and(query1, query2, query3);
    - * - * will create a compoundQuery that is an and of the query1, query2, and - * query3. - * - * @param {...Parse.Query} queries The list of queries to AND. - * @static - * @returns {Parse.Query} The query that is the AND of the passed in queries. - */ - static and(...queries: Array): ParseQuery; - /** - * Constructs a Parse.Query that is the NOR of the passed in queries. For - * example: - *
    const compoundQuery = Parse.Query.nor(query1, query2, query3);
    - * - * will create a compoundQuery that is a nor of the query1, query2, and - * query3. - * - * @param {...Parse.Query} queries The list of queries to NOR. - * @static - * @returns {Parse.Query} The query that is the NOR of the passed in queries. - */ - static nor(...queries: Array): ParseQuery; - /** - * Change the source of this query to the server. - * - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - fromNetwork(): ParseQuery; - /** - * Changes the source of this query to all pinned objects. - * - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - fromLocalDatastore(): ParseQuery; - /** - * Changes the source of this query to the default group of pinned objects. - * - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - fromPin(): ParseQuery; - /** - * Changes the source of this query to a specific group of pinned objects. - * - * @param {string} name The name of query source. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - fromPinWithName(name?: string | null): ParseQuery; - /** - * Cancels the current network request (if any is running). - * - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - cancel(): ParseQuery; - _setRequestTask(options: any): void; - /** - * Sets a comment to the query so that the query - * can be identified when using a the profiler for MongoDB. - * - * @param {string} value a comment can make your profile data easier to interpret and trace. - * @returns {Parse.Query} Returns the query, so you can chain this call. - */ - comment(value: string): ParseQuery; + /** + * @property {string} className + */ + className: string; + _where: any; + _watch: Array; + _include: Array; + _exclude: Array; + _select: Array; + _limit: number; + _skip: number; + _count: boolean; + _order: Array; + _readPreference: string | null; + _includeReadPreference: string | null; + _subqueryReadPreference: string | null; + _queriesLocalDatastore: boolean; + _localDatastorePinName: any; + _extraOptions: { + [key: string]: any; + }; + _hint: any; + _explain: boolean; + _xhrRequest: any; + _comment: string; + /** + * @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string. + */ + constructor(objectClass: string | ParseObject); + /** + * Adds constraint that at least one of the passed in queries matches. + * + * @param {Array} queries + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + _orQuery(queries: Array): ParseQuery; + /** + * Adds constraint that all of the passed in queries match. + * + * @param {Array} queries + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + _andQuery(queries: Array): ParseQuery; + /** + * Adds constraint that none of the passed in queries match. + * + * @param {Array} queries + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + _norQuery(queries: Array): ParseQuery; + /** + * Helper for condition queries + * + * @param key + * @param condition + * @param value + * @returns {Parse.Query} + */ + _addCondition(key: string, condition: string, value: any): ParseQuery; + /** + * Converts string for regular expression at the beginning + * + * @param string + * @returns {string} + */ + _regexStartWith(string: string): string; + _handleOfflineQuery(params: QueryJSON): Promise; + /** + * Returns a JSON representation of this query. + * + * @returns {object} The JSON representation of the query. + */ + toJSON(): QueryJSON; + /** + * Return a query with conditions from json, can be useful to send query from server side to client + * Not static, all query conditions was set before calling this method will be deleted. + * For example on the server side we have + * var query = new Parse.Query("className"); + * query.equalTo(key: value); + * query.limit(100); + * ... (others queries) + * Create JSON representation of Query Object + * var jsonFromServer = query.fromJSON(); + * + * On client side getting query: + * var query = new Parse.Query("className"); + * query.fromJSON(jsonFromServer); + * + * and continue to query... + * query.skip(100).find().then(...); + * + * @param {QueryJSON} json from Parse.Query.toJSON() method + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + withJSON(json: QueryJSON): ParseQuery; + /** + * Static method to restore Parse.Query by json representation + * Internally calling Parse.Query.withJSON + * + * @param {string} className + * @param {QueryJSON} json from Parse.Query.toJSON() method + * @returns {Parse.Query} new created query + */ + static fromJSON(className: string, json: QueryJSON): ParseQuery; + /** + * Constructs a Parse.Object whose id is already known by fetching data from + * the server. Unlike the first method, it never returns undefined. + * + * @param {string} objectId The id of the object to be fetched. + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. + *
    • json: Return raw json without converting to Parse.Object + *
    + * @returns {Promise} A promise that is resolved with the result when + * the query completes. + */ + get(objectId: string, options?: QueryOptions): Promise; + /** + * Retrieves a list of ParseObjects that satisfy this query. + * + * @param {object} options Valid options + * are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. + *
    • json: Return raw json without converting to Parse.Object + *
    + * @returns {Promise} A promise that is resolved with the results when + * the query completes. + */ + find(options?: QueryOptions): Promise>; + /** + * Retrieves a complete list of ParseObjects that satisfy this query. + * Using `eachBatch` under the hood to fetch all the valid objects. + * + * @param {object} options Valid options are:
      + *
    • batchSize: How many objects to yield in each batch (default: 100) + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • json: Return raw JSON without converting to Parse.Object. + *
    + * @returns {Promise} A promise that is resolved with the results when + * the query completes. + */ + findAll(options?: BatchOptions): Promise>; + /** + * Counts the number of objects that match this query. + * + * @param {object} options + * @param {boolean} [options.useMasterKey] + * @param {string} [options.sessionToken] + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    + * @returns {Promise} A promise that is resolved with the count when + * the query completes. + */ + count(options?: { + useMasterKey?: boolean; + sessionToken?: string; + }): Promise; + /** + * Executes a distinct query and returns unique values + * + * @param {string} key A field to find distinct values + * @param {object} options + * @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user. + * @returns {Promise} A promise that is resolved with the query completes. + */ + distinct(key: string, options?: { + sessionToken?: string; + }): Promise>; + /** + * Executes an aggregate query and returns aggregate results + * + * @param {(Array|object)} pipeline Array or Object of stages to process query + * @param {object} options + * @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user. + * @returns {Promise} A promise that is resolved with the query completes. + */ + aggregate(pipeline: any, options?: { + sessionToken?: string; + }): Promise>; + /** + * Retrieves at most one Parse.Object that satisfies this query. + * + * Returns the object if there is one, otherwise undefined. + * + * @param {object} options Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. + *
    • json: Return raw json without converting to Parse.Object + *
    + * @returns {Promise} A promise that is resolved with the object when + * the query completes. + */ + first(options?: QueryOptions): Promise; + /** + * Iterates over objects matching a query, calling a callback for each batch. + * If the callback returns a promise, the iteration will not continue until + * that promise has been fulfilled. If the callback returns a rejected + * promise, then iteration will stop with that error. The items are processed + * in an unspecified order. The query may not have any sort order, and may + * not use limit or skip. + * + * @param {Function} callback Callback that will be called with each result + * of the query. + * @param {object} options Valid options are:
      + *
    • batchSize: How many objects to yield in each batch (default: 100) + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • context: A dictionary that is accessible in Cloud Code `beforeFind` trigger. + *
    + * @returns {Promise} A promise that will be fulfilled once the + * iteration has completed. + */ + eachBatch(callback: (objs: Array) => void, options?: BatchOptions): Promise; + /** + * Iterates over each result of a query, calling a callback for each one. If + * the callback returns a promise, the iteration will not continue until + * that promise has been fulfilled. If the callback returns a rejected + * promise, then iteration will stop with that error. The items are + * processed in an unspecified order. The query may not have any sort order, + * and may not use limit or skip. + * + * @param {Function} callback Callback that will be called with each result + * of the query. + * @param {object} options Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    • json: Return raw json without converting to Parse.Object + *
    + * @returns {Promise} A promise that will be fulfilled once the + * iteration has completed. + */ + each(callback: (obj: ParseObject) => any, options?: BatchOptions): Promise; + /** + * Adds a hint to force index selection. (https://docs.mongodb.com/manual/reference/operator/meta/hint/) + * + * @param {(string|object)} value String or Object of index that should be used when executing query + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + hint(value: any): ParseQuery; + /** + * Investigates the query execution plan. Useful for optimizing queries. (https://docs.mongodb.com/manual/reference/operator/meta/explain/) + * + * @param {boolean} explain Used to toggle the information on the query plan. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + explain(explain?: boolean): ParseQuery; + /** + * Iterates over each result of a query, calling a callback for each one. If + * the callback returns a promise, the iteration will not continue until + * that promise has been fulfilled. If the callback returns a rejected + * promise, then iteration will stop with that error. The items are + * processed in an unspecified order. The query may not have any sort order, + * and may not use limit or skip. + * + * @param {Function} callback Callback
      + *
    • currentObject: The current Parse.Object being processed in the array.
    • + *
    • index: The index of the current Parse.Object being processed in the array.
    • + *
    • query: The query map was called upon.
    • + *
    + * @param {object} options Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    + * @returns {Promise} A promise that will be fulfilled once the + * iteration has completed. + */ + map(callback: (currentObject: ParseObject, index: number, query: ParseQuery) => any, options?: BatchOptions): Promise>; + /** + * Iterates over each result of a query, calling a callback for each one. If + * the callback returns a promise, the iteration will not continue until + * that promise has been fulfilled. If the callback returns a rejected + * promise, then iteration will stop with that error. The items are + * processed in an unspecified order. The query may not have any sort order, + * and may not use limit or skip. + * + * @param {Function} callback Callback
      + *
    • accumulator: The accumulator accumulates the callback's return values. It is the accumulated value previously returned in the last invocation of the callback.
    • + *
    • currentObject: The current Parse.Object being processed in the array.
    • + *
    • index: The index of the current Parse.Object being processed in the array.
    • + *
    + * @param {*} initialValue A value to use as the first argument to the first call of the callback. If no initialValue is supplied, the first object in the query will be used and skipped. + * @param {object} options Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    + * @returns {Promise} A promise that will be fulfilled once the + * iteration has completed. + */ + reduce(callback: (accumulator: any, currentObject: ParseObject, index: number) => any, initialValue: any, options?: BatchOptions): Promise>; + /** + * Iterates over each result of a query, calling a callback for each one. If + * the callback returns a promise, the iteration will not continue until + * that promise has been fulfilled. If the callback returns a rejected + * promise, then iteration will stop with that error. The items are + * processed in an unspecified order. The query may not have any sort order, + * and may not use limit or skip. + * + * @param {Function} callback Callback
      + *
    • currentObject: The current Parse.Object being processed in the array.
    • + *
    • index: The index of the current Parse.Object being processed in the array.
    • + *
    • query: The query filter was called upon.
    • + *
    + * @param {object} options Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • sessionToken: A valid session token, used for making a request on + * behalf of a specific user. + *
    + * @returns {Promise} A promise that will be fulfilled once the + * iteration has completed. + */ + filter(callback: (currentObject: ParseObject, index: number, query: ParseQuery) => boolean, options?: BatchOptions): Promise>; + /** + * Adds a constraint to the query that requires a particular key's value to + * be equal to the provided value. + * + * @param {string} key The key to check. + * @param value The value that the Parse.Object must contain. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + equalTo(key: string | { + [key: string]: any; + }, value?: any): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * be not equal to the provided value. + * + * @param {string} key The key to check. + * @param value The value that must not be equalled. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + notEqualTo(key: string | { + [key: string]: any; + }, value?: any): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * be less than the provided value. + * + * @param {string} key The key to check. + * @param value The value that provides an upper bound. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + lessThan(key: string, value: any): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * be greater than the provided value. + * + * @param {string} key The key to check. + * @param value The value that provides an lower bound. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + greaterThan(key: string, value: any): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * be less than or equal to the provided value. + * + * @param {string} key The key to check. + * @param value The value that provides an upper bound. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + lessThanOrEqualTo(key: string, value: any): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * be greater than or equal to the provided value. + * + * @param {string} key The key to check. + * @param {*} value The value that provides an lower bound. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + greaterThanOrEqualTo(key: string, value: any): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * be contained in the provided list of values. + * + * @param {string} key The key to check. + * @param {Array<*>} value The values that will match. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + containedIn(key: string, value: Array): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * not be contained in the provided list of values. + * + * @param {string} key The key to check. + * @param {Array<*>} value The values that will not match. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + notContainedIn(key: string, value: Array): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * be contained by the provided list of values. Get objects where all array elements match. + * + * @param {string} key The key to check. + * @param {Array} values The values that will match. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + containedBy(key: string, values: Array): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * contain each one of the provided list of values. + * + * @param {string} key The key to check. This key's value must be an array. + * @param {Array} values The values that will match. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + containsAll(key: string, values: Array): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's value to + * contain each one of the provided list of values starting with given strings. + * + * @param {string} key The key to check. This key's value must be an array. + * @param {Array} values The string values that will match as starting string. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + containsAllStartingWith(key: string, values: Array): ParseQuery; + /** + * Adds a constraint for finding objects that contain the given key. + * + * @param {string} key The key that should exist. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + exists(key: string): ParseQuery; + /** + * Adds a constraint for finding objects that do not contain a given key. + * + * @param {string} key The key that should not exist + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + doesNotExist(key: string): ParseQuery; + /** + * Adds a regular expression constraint for finding string values that match + * the provided regular expression. + * This may be slow for large datasets. + * + * @param {string} key The key that the string to match is stored in. + * @param {RegExp | string} regex The regular expression pattern to match. + * @param {string} modifiers The regular expression mode. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + matches(key: string, regex: RegExp | string, modifiers: string): ParseQuery; + /** + * Adds a constraint that requires that a key's value matches a Parse.Query + * constraint. + * + * @param {string} key The key that the contains the object to match the + * query. + * @param {Parse.Query} query The query that should match. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + matchesQuery(key: string, query: ParseQuery): ParseQuery; + /** + * Adds a constraint that requires that a key's value not matches a + * Parse.Query constraint. + * + * @param {string} key The key that the contains the object to match the + * query. + * @param {Parse.Query} query The query that should not match. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + doesNotMatchQuery(key: string, query: ParseQuery): ParseQuery; + /** + * Adds a constraint that requires that a key's value matches a value in + * an object returned by a different Parse.Query. + * + * @param {string} key The key that contains the value that is being + * matched. + * @param {string} queryKey The key in the objects returned by the query to + * match against. + * @param {Parse.Query} query The query to run. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + matchesKeyInQuery(key: string, queryKey: string, query: ParseQuery): ParseQuery; + /** + * Adds a constraint that requires that a key's value not match a value in + * an object returned by a different Parse.Query. + * + * @param {string} key The key that contains the value that is being + * excluded. + * @param {string} queryKey The key in the objects returned by the query to + * match against. + * @param {Parse.Query} query The query to run. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + doesNotMatchKeyInQuery(key: string, queryKey: string, query: ParseQuery): ParseQuery; + /** + * Adds a constraint for finding string values that contain a provided + * string. This may be slow for large datasets. + * + * @param {string} key The key that the string to match is stored in. + * @param {string} substring The substring that the value must contain. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + contains(key: string, substring: string): ParseQuery; + /** + * Adds a constraint for finding string values that contain a provided + * string. This may be slow for large datasets. Requires Parse-Server > 2.5.0 + * + * In order to sort you must use select and ascending ($score is required) + *
    +     *   query.fullText('field', 'term');
    +     *   query.ascending('$score');
    +     *   query.select('$score');
    +     *  
    + * + * To retrieve the weight / rank + *
    +     *   object->get('score');
    +     *  
    + * + * You can define optionals by providing an object as a third parameter + *
    +     *   query.fullText('field', 'term', { language: 'es', diacriticSensitive: true });
    +     *  
    + * + * @param {string} key The key that the string to match is stored in. + * @param {string} value The string to search + * @param {object} options (Optional) + * @param {string} options.language The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer. + * @param {boolean} options.caseSensitive A boolean flag to enable or disable case sensitive search. + * @param {boolean} options.diacriticSensitive A boolean flag to enable or disable diacritic sensitive search. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + fullText(key: string, value: string, options?: FullTextQueryOptions): ParseQuery; + /** + * Method to sort the full text search by text score + * + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + sortByTextScore(): this; + /** + * Adds a constraint for finding string values that start with a provided + * string. This query will use the backend index, so it will be fast even + * for large datasets. + * + * @param {string} key The key that the string to match is stored in. + * @param {string} prefix The substring that the value must start with. + * @param {string} modifiers The regular expression mode. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + startsWith(key: string, prefix: string, modifiers: string): ParseQuery; + /** + * Adds a constraint for finding string values that end with a provided + * string. This will be slow for large datasets. + * + * @param {string} key The key that the string to match is stored in. + * @param {string} suffix The substring that the value must end with. + * @param {string} modifiers The regular expression mode. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + endsWith(key: string, suffix: string, modifiers: string): ParseQuery; + /** + * Adds a proximity based constraint for finding objects with key point + * values near the point given. + * + * @param {string} key The key that the Parse.GeoPoint is stored in. + * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + near(key: string, point: ParseGeoPoint): ParseQuery; + /** + * Adds a proximity based constraint for finding objects with key point + * values near the point given and within the maximum distance given. + * + * @param {string} key The key that the Parse.GeoPoint is stored in. + * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used. + * @param {number} maxDistance Maximum distance (in radians) of results to return. + * @param {boolean} sorted A Bool value that is true if results should be + * sorted by distance ascending, false is no sorting is required, + * defaults to true. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + withinRadians(key: string, point: ParseGeoPoint, maxDistance: number, sorted: boolean): ParseQuery; + /** + * Adds a proximity based constraint for finding objects with key point + * values near the point given and within the maximum distance given. + * Radius of earth used is 3958.8 miles. + * + * @param {string} key The key that the Parse.GeoPoint is stored in. + * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used. + * @param {number} maxDistance Maximum distance (in miles) of results to return. + * @param {boolean} sorted A Bool value that is true if results should be + * sorted by distance ascending, false is no sorting is required, + * defaults to true. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + withinMiles(key: string, point: ParseGeoPoint, maxDistance: number, sorted: boolean): ParseQuery; + /** + * Adds a proximity based constraint for finding objects with key point + * values near the point given and within the maximum distance given. + * Radius of earth used is 6371.0 kilometers. + * + * @param {string} key The key that the Parse.GeoPoint is stored in. + * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used. + * @param {number} maxDistance Maximum distance (in kilometers) of results to return. + * @param {boolean} sorted A Bool value that is true if results should be + * sorted by distance ascending, false is no sorting is required, + * defaults to true. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + withinKilometers(key: string, point: ParseGeoPoint, maxDistance: number, sorted: boolean): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's + * coordinates be contained within a given rectangular geographic bounding + * box. + * + * @param {string} key The key to be constrained. + * @param {Parse.GeoPoint} southwest + * The lower-left inclusive corner of the box. + * @param {Parse.GeoPoint} northeast + * The upper-right inclusive corner of the box. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + withinGeoBox(key: string, southwest: ParseGeoPoint, northeast: ParseGeoPoint): ParseQuery; + /** + * Adds a constraint to the query that requires a particular key's + * coordinates be contained within and on the bounds of a given polygon. + * Supports closed and open (last point is connected to first) paths + * + * Polygon must have at least 3 points + * + * @param {string} key The key to be constrained. + * @param {Array} points Array of Coordinates / GeoPoints + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + withinPolygon(key: string, points: Array>): ParseQuery; + /** + * Add a constraint to the query that requires a particular key's + * coordinates that contains a ParseGeoPoint + * + * @param {string} key The key to be constrained. + * @param {Parse.GeoPoint} point + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + polygonContains(key: string, point: ParseGeoPoint): ParseQuery; + /** + * Sorts the results in ascending order by the given key. + * + * @param {(string|string[])} keys The key to order by, which is a + * string of comma separated values, or an Array of keys, or multiple keys. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + ascending(...keys: Array): ParseQuery; + /** + * Sorts the results in ascending order by the given key, + * but can also add secondary sort descriptors without overwriting _order. + * + * @param {(string|string[])} keys The key to order by, which is a + * string of comma separated values, or an Array of keys, or multiple keys. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + addAscending(...keys: Array): ParseQuery; + /** + * Sorts the results in descending order by the given key. + * + * @param {(string|string[])} keys The key to order by, which is a + * string of comma separated values, or an Array of keys, or multiple keys. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + descending(...keys: Array): ParseQuery; + /** + * Sorts the results in descending order by the given key, + * but can also add secondary sort descriptors without overwriting _order. + * + * @param {(string|string[])} keys The key to order by, which is a + * string of comma separated values, or an Array of keys, or multiple keys. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + addDescending(...keys: Array): ParseQuery; + /** + * Sets the number of results to skip before returning any results. + * This is useful for pagination. + * Default is to skip zero results. + * + * @param {number} n the number of results to skip. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + skip(n: number): ParseQuery; + /** + * Sets the limit of the number of results to return. The default limit is 100. + * + * @param {number} n the number of results to limit to. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + limit(n: number): ParseQuery; + /** + * Sets the flag to include with response the total number of objects satisfying this query, + * despite limits/skip. Might be useful for pagination. + * Note that result of this query will be wrapped as an object with + * `results`: holding {ParseObject} array and `count`: integer holding total number + * + * @param {boolean} includeCount false - disable, true - enable. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + withCount(includeCount?: boolean): ParseQuery; + /** + * Includes nested Parse.Objects for the provided key. You can use dot + * notation to specify which fields in the included object are also fetched. + * + * You can include all nested Parse.Objects by passing in '*'. + * Requires Parse Server 3.0.0+ + *
    query.include('*');
    + * + * @param {...string|Array} keys The name(s) of the key(s) to include. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + include(...keys: Array>): ParseQuery; + /** + * Includes all nested Parse.Objects one level deep. + * + * Requires Parse Server 3.0.0+ + * + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + includeAll(): ParseQuery; + /** + * Restricts the fields of the returned Parse.Objects to include only the + * provided keys. If this is called multiple times, then all of the keys + * specified in each of the calls will be included. + * + * @param {...string|Array} keys The name(s) of the key(s) to include. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + select(...keys: Array>): ParseQuery; + /** + * Restricts the fields of the returned Parse.Objects to all keys except the + * provided keys. Exclude takes precedence over select and include. + * + * Requires Parse Server 3.6.0+ + * + * @param {...string|Array} keys The name(s) of the key(s) to exclude. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + exclude(...keys: Array>): ParseQuery; + /** + * Restricts live query to trigger only for watched fields. + * + * Requires Parse Server 6.0.0+ + * + * @param {...string|Array} keys The name(s) of the key(s) to watch. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + watch(...keys: Array>): ParseQuery; + /** + * Changes the read preference that the backend will use when performing the query to the database. + * + * @param {string} readPreference The read preference for the main query. + * @param {string} includeReadPreference The read preference for the queries to include pointers. + * @param {string} subqueryReadPreference The read preference for the sub queries. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + readPreference(readPreference: string, includeReadPreference?: string, subqueryReadPreference?: string): ParseQuery; + /** + * Subscribe this query to get liveQuery updates + * + * @param {string} sessionToken (optional) Defaults to the currentUser + * @returns {Promise} Returns the liveQuerySubscription, it's an event emitter + * which can be used to get liveQuery updates. + */ + subscribe(sessionToken?: string): Promise; + /** + * Constructs a Parse.Query that is the OR of the passed in queries. For + * example: + *
    var compoundQuery = Parse.Query.or(query1, query2, query3);
    + * + * will create a compoundQuery that is an or of the query1, query2, and + * query3. + * + * @param {...Parse.Query} queries The list of queries to OR. + * @static + * @returns {Parse.Query} The query that is the OR of the passed in queries. + */ + static or(...queries: Array): ParseQuery; + /** + * Constructs a Parse.Query that is the AND of the passed in queries. For + * example: + *
    var compoundQuery = Parse.Query.and(query1, query2, query3);
    + * + * will create a compoundQuery that is an and of the query1, query2, and + * query3. + * + * @param {...Parse.Query} queries The list of queries to AND. + * @static + * @returns {Parse.Query} The query that is the AND of the passed in queries. + */ + static and(...queries: Array): ParseQuery; + /** + * Constructs a Parse.Query that is the NOR of the passed in queries. For + * example: + *
    const compoundQuery = Parse.Query.nor(query1, query2, query3);
    + * + * will create a compoundQuery that is a nor of the query1, query2, and + * query3. + * + * @param {...Parse.Query} queries The list of queries to NOR. + * @static + * @returns {Parse.Query} The query that is the NOR of the passed in queries. + */ + static nor(...queries: Array): ParseQuery; + /** + * Change the source of this query to the server. + * + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + fromNetwork(): ParseQuery; + /** + * Changes the source of this query to all pinned objects. + * + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + fromLocalDatastore(): ParseQuery; + /** + * Changes the source of this query to the default group of pinned objects. + * + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + fromPin(): ParseQuery; + /** + * Changes the source of this query to a specific group of pinned objects. + * + * @param {string} name The name of query source. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + fromPinWithName(name?: string | null): ParseQuery; + /** + * Cancels the current network request (if any is running). + * + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + cancel(): ParseQuery; + _setRequestTask(options: any): void; + /** + * Sets a comment to the query so that the query + * can be identified when using a the profiler for MongoDB. + * + * @param {string} value a comment can make your profile data easier to interpret and trace. + * @returns {Parse.Query} Returns the query, so you can chain this call. + */ + comment(value: string): ParseQuery; } export default ParseQuery; diff --git a/types/ParseRelation.d.ts b/types/ParseRelation.d.ts index 5426f7c83..1bc728867 100644 --- a/types/ParseRelation.d.ts +++ b/types/ParseRelation.d.ts @@ -14,43 +14,43 @@ import type ParseQuery from './ParseQuery'; * @alias Parse.Relation */ declare class ParseRelation { - parent?: ParseObject; - key?: string; - targetClassName?: string | null; - /** - * @param {Parse.Object} parent The parent of this relation. - * @param {string} key The key for this relation on the parent. - */ - constructor(parent?: ParseObject, key?: string); - _ensureParentAndKey(parent: ParseObject, key: string): void; - /** - * Adds a Parse.Object or an array of Parse.Objects to the relation. - * - * @param {(Parse.Object|Array)} objects The item or items to add. - * @returns {Parse.Object} The parent of the relation. - */ - add(objects: ParseObject | Array): ParseObject; - /** - * Removes a Parse.Object or an array of Parse.Objects from this relation. - * - * @param {(Parse.Object|Array)} objects The item or items to remove. - */ - remove(objects: ParseObject | Array): void; - /** - * Returns a JSON version of the object suitable for saving to disk. - * - * @returns {object} JSON representation of Relation - */ - toJSON(): { - __type: 'Relation'; - className: string | null; - }; - /** - * Returns a Parse.Query that is limited to objects in this - * relation. - * - * @returns {Parse.Query} Relation Query - */ - query(): ParseQuery; + parent?: ParseObject; + key?: string; + targetClassName?: string | null; + /** + * @param {Parse.Object} parent The parent of this relation. + * @param {string} key The key for this relation on the parent. + */ + constructor(parent?: ParseObject, key?: string); + _ensureParentAndKey(parent: ParseObject, key: string): void; + /** + * Adds a Parse.Object or an array of Parse.Objects to the relation. + * + * @param {(Parse.Object|Array)} objects The item or items to add. + * @returns {Parse.Object} The parent of the relation. + */ + add(objects: ParseObject | Array): ParseObject; + /** + * Removes a Parse.Object or an array of Parse.Objects from this relation. + * + * @param {(Parse.Object|Array)} objects The item or items to remove. + */ + remove(objects: ParseObject | Array): void; + /** + * Returns a JSON version of the object suitable for saving to disk. + * + * @returns {object} JSON representation of Relation + */ + toJSON(): { + __type: 'Relation'; + className: string | null; + }; + /** + * Returns a Parse.Query that is limited to objects in this + * relation. + * + * @returns {Parse.Query} Relation Query + */ + query(): ParseQuery; } export default ParseRelation; diff --git a/types/ParseRole.d.ts b/types/ParseRole.d.ts index 55b255279..32da55c56 100644 --- a/types/ParseRole.d.ts +++ b/types/ParseRole.d.ts @@ -17,62 +17,62 @@ import type ParseRelation from './ParseRelation'; * @augments Parse.Object */ declare class ParseRole extends ParseObject { - /** - * @param {string} name The name of the Role to create. - * @param {Parse.ACL} acl The ACL for this role. Roles must have an ACL. - * A Parse.Role is a local representation of a role persisted to the Parse - * cloud. - */ - constructor(name: string, acl: ParseACL); - /** - * Gets the name of the role. You can alternatively call role.get("name") - * - * @returns {string} the name of the role. - */ - getName(): string | null; - /** - * Sets the name for a role. This value must be set before the role has - * been saved to the server, and cannot be set once the role has been - * saved. - * - *

    - * A role's name can only contain alphanumeric characters, _, -, and - * spaces. - *

    - * - *

    This is equivalent to calling role.set("name", name)

    - * - * @param {string} name The name of the role. - * @param {object} options Standard options object with success and error - * callbacks. - * @returns {(ParseObject|boolean)} true if the set succeeded. - */ - setName(name: string, options?: any): ParseObject | boolean; - /** - * Gets the Parse.Relation for the Parse.Users that are direct - * children of this role. These users are granted any privileges that this - * role has been granted (e.g. read or write access through ACLs). You can - * add or remove users from the role through this relation. - * - *

    This is equivalent to calling role.relation("users")

    - * - * @returns {Parse.Relation} the relation for the users belonging to this - * role. - */ - getUsers(): ParseRelation; - /** - * Gets the Parse.Relation for the Parse.Roles that are direct - * children of this role. These roles' users are granted any privileges that - * this role has been granted (e.g. read or write access through ACLs). You - * can add or remove child roles from this role through this relation. - * - *

    This is equivalent to calling role.relation("roles")

    - * - * @returns {Parse.Relation} the relation for the roles belonging to this - * role. - */ - getRoles(): ParseRelation; - _validateName(newName: any): void; - validate(attrs: AttributeMap, options?: any): ParseError | boolean; + /** + * @param {string} name The name of the Role to create. + * @param {Parse.ACL} acl The ACL for this role. Roles must have an ACL. + * A Parse.Role is a local representation of a role persisted to the Parse + * cloud. + */ + constructor(name: string, acl: ParseACL); + /** + * Gets the name of the role. You can alternatively call role.get("name") + * + * @returns {string} the name of the role. + */ + getName(): string | null; + /** + * Sets the name for a role. This value must be set before the role has + * been saved to the server, and cannot be set once the role has been + * saved. + * + *

    + * A role's name can only contain alphanumeric characters, _, -, and + * spaces. + *

    + * + *

    This is equivalent to calling role.set("name", name)

    + * + * @param {string} name The name of the role. + * @param {object} options Standard options object with success and error + * callbacks. + * @returns {(ParseObject|boolean)} true if the set succeeded. + */ + setName(name: string, options?: any): ParseObject | boolean; + /** + * Gets the Parse.Relation for the Parse.Users that are direct + * children of this role. These users are granted any privileges that this + * role has been granted (e.g. read or write access through ACLs). You can + * add or remove users from the role through this relation. + * + *

    This is equivalent to calling role.relation("users")

    + * + * @returns {Parse.Relation} the relation for the users belonging to this + * role. + */ + getUsers(): ParseRelation; + /** + * Gets the Parse.Relation for the Parse.Roles that are direct + * children of this role. These roles' users are granted any privileges that + * this role has been granted (e.g. read or write access through ACLs). You + * can add or remove child roles from this role through this relation. + * + *

    This is equivalent to calling role.relation("roles")

    + * + * @returns {Parse.Relation} the relation for the roles belonging to this + * role. + */ + getRoles(): ParseRelation; + _validateName(newName: any): void; + validate(attrs: AttributeMap, options?: any): ParseError | boolean; } export default ParseRole; diff --git a/types/ParseSchema.d.ts b/types/ParseSchema.d.ts index 8285acf4c..b4ea24241 100644 --- a/types/ParseSchema.d.ts +++ b/types/ParseSchema.d.ts @@ -1,9 +1,9 @@ import ParseCLP from './ParseCLP'; import type { PermissionsMap } from './ParseCLP'; type FieldOptions = { - required?: boolean; - defaultValue?: any; - targetClass?: string; + required?: boolean; + defaultValue?: any; + targetClass?: string; }; /** * A Parse.Schema object is for handling schema data from Parse. @@ -23,216 +23,216 @@ type FieldOptions = { * @alias Parse.Schema */ declare class ParseSchema { - className: string; - _fields: { - [key: string]: any; - }; - _indexes: { - [key: string]: any; - }; - _clp: { - [key: string]: any; - }; - /** - * @param {string} className Parse Class string. - */ - constructor(className: string); - /** - * Static method to get all schemas - * - * @returns {Promise} A promise that is resolved with the result when - * the query completes. - */ - static all(): Promise; - /** - * Get the Schema from Parse - * - * @returns {Promise} A promise that is resolved with the result when - * the query completes. - */ - get(): Promise<{ - results: ParseSchema[]; - }>; - /** - * Create a new Schema on Parse - * - * @returns {Promise} A promise that is resolved with the result when - * the query completes. - */ - save(): Promise; - /** - * Update a Schema on Parse - * - * @returns {Promise} A promise that is resolved with the result when - * the query completes. - */ - update(): Promise; - /** - * Removing a Schema from Parse - * Can only be used on Schema without objects - * - * @returns {Promise} A promise that is resolved with the result when - * the query completes. - */ - delete(): Promise; - /** - * Removes all objects from a Schema (class) in Parse. - * EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed - * - * @returns {Promise} A promise that is resolved with the result when - * the query completes. - */ - purge(): Promise; - /** - * Assert if ClassName has been filled - * - * @private - */ - assertClassName(): void; - /** - * Sets Class Level Permissions when creating / updating a Schema. - * EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed - * - * @param {object | Parse.CLP} clp Class Level Permissions - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - setCLP(clp: PermissionsMap | ParseCLP): this; - /** - * Adding a Field to Create / Update a Schema - * - * @param {string} name Name of the field that will be created on Parse - * @param {string} type Can be a (String|Number|Boolean|Date|Parse.File|Parse.GeoPoint|Array|Object|Pointer|Parse.Relation) - * @param {object} options - * Valid options are:
      - *
    • required: If field is not set, save operation fails (Requires Parse Server 3.7.0+) - *
    • defaultValue: If field is not set, a default value is selected (Requires Parse Server 3.7.0+) - *
    • targetClass: Required if type is Pointer or Parse.Relation - *
    - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - addField(name: string, type: string, options?: FieldOptions): this; - /** - * Adding an Index to Create / Update a Schema - * - * @param {string} name Name of the index - * @param {object} index { field: value } - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - * - *
    -   * schema.addIndex('index_name', { 'field': 1 });
    -   * 
    - */ - addIndex(name: string, index: any): this; - /** - * Adding String Field - * - * @param {string} name Name of the field that will be created on Parse - * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - addString(name: string, options: FieldOptions): this; - /** - * Adding Number Field - * - * @param {string} name Name of the field that will be created on Parse - * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - addNumber(name: string, options: FieldOptions): this; - /** - * Adding Boolean Field - * - * @param {string} name Name of the field that will be created on Parse - * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - addBoolean(name: string, options: FieldOptions): this; - /** - * Adding Bytes Field - * - * @param {string} name Name of the field that will be created on Parse - * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - addBytes(name: string, options: FieldOptions): this; - /** - * Adding Date Field - * - * @param {string} name Name of the field that will be created on Parse - * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - addDate(name: string, options: FieldOptions): this; - /** - * Adding File Field - * - * @param {string} name Name of the field that will be created on Parse - * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - addFile(name: string, options: FieldOptions): this; - /** - * Adding GeoPoint Field - * - * @param {string} name Name of the field that will be created on Parse - * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - addGeoPoint(name: string, options: FieldOptions): this; - /** - * Adding Polygon Field - * - * @param {string} name Name of the field that will be created on Parse - * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - addPolygon(name: string, options: FieldOptions): this; - /** - * Adding Array Field - * - * @param {string} name Name of the field that will be created on Parse - * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - addArray(name: string, options: FieldOptions): this; - /** - * Adding Object Field - * - * @param {string} name Name of the field that will be created on Parse - * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - addObject(name: string, options: FieldOptions): this; - /** - * Adding Pointer Field - * - * @param {string} name Name of the field that will be created on Parse - * @param {string} targetClass Name of the target Pointer Class - * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - addPointer(name: string, targetClass: string, options?: FieldOptions): this; - /** - * Adding Relation Field - * - * @param {string} name Name of the field that will be created on Parse - * @param {string} targetClass Name of the target Pointer Class - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - addRelation(name: string, targetClass: string): this; - /** - * Deleting a Field to Update on a Schema - * - * @param {string} name Name of the field - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - deleteField(name: string): this; - /** - * Deleting an Index to Update on a Schema - * - * @param {string} name Name of the field - * @returns {Parse.Schema} Returns the schema, so you can chain this call. - */ - deleteIndex(name: string): this; + className: string; + _fields: { + [key: string]: any; + }; + _indexes: { + [key: string]: any; + }; + _clp: { + [key: string]: any; + }; + /** + * @param {string} className Parse Class string. + */ + constructor(className: string); + /** + * Static method to get all schemas + * + * @returns {Promise} A promise that is resolved with the result when + * the query completes. + */ + static all(): Promise; + /** + * Get the Schema from Parse + * + * @returns {Promise} A promise that is resolved with the result when + * the query completes. + */ + get(): Promise<{ + results: ParseSchema[]; + }>; + /** + * Create a new Schema on Parse + * + * @returns {Promise} A promise that is resolved with the result when + * the query completes. + */ + save(): Promise; + /** + * Update a Schema on Parse + * + * @returns {Promise} A promise that is resolved with the result when + * the query completes. + */ + update(): Promise; + /** + * Removing a Schema from Parse + * Can only be used on Schema without objects + * + * @returns {Promise} A promise that is resolved with the result when + * the query completes. + */ + delete(): Promise; + /** + * Removes all objects from a Schema (class) in Parse. + * EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed + * + * @returns {Promise} A promise that is resolved with the result when + * the query completes. + */ + purge(): Promise; + /** + * Assert if ClassName has been filled + * + * @private + */ + assertClassName(): void; + /** + * Sets Class Level Permissions when creating / updating a Schema. + * EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed + * + * @param {object | Parse.CLP} clp Class Level Permissions + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + setCLP(clp: PermissionsMap | ParseCLP): this; + /** + * Adding a Field to Create / Update a Schema + * + * @param {string} name Name of the field that will be created on Parse + * @param {string} type Can be a (String|Number|Boolean|Date|Parse.File|Parse.GeoPoint|Array|Object|Pointer|Parse.Relation) + * @param {object} options + * Valid options are:
      + *
    • required: If field is not set, save operation fails (Requires Parse Server 3.7.0+) + *
    • defaultValue: If field is not set, a default value is selected (Requires Parse Server 3.7.0+) + *
    • targetClass: Required if type is Pointer or Parse.Relation + *
    + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addField(name: string, type: string, options?: FieldOptions): this; + /** + * Adding an Index to Create / Update a Schema + * + * @param {string} name Name of the index + * @param {object} index { field: value } + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + * + *
    +     * schema.addIndex('index_name', { 'field': 1 });
    +     * 
    + */ + addIndex(name: string, index: any): this; + /** + * Adding String Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addString(name: string, options: FieldOptions): this; + /** + * Adding Number Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addNumber(name: string, options: FieldOptions): this; + /** + * Adding Boolean Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addBoolean(name: string, options: FieldOptions): this; + /** + * Adding Bytes Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addBytes(name: string, options: FieldOptions): this; + /** + * Adding Date Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addDate(name: string, options: FieldOptions): this; + /** + * Adding File Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addFile(name: string, options: FieldOptions): this; + /** + * Adding GeoPoint Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addGeoPoint(name: string, options: FieldOptions): this; + /** + * Adding Polygon Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addPolygon(name: string, options: FieldOptions): this; + /** + * Adding Array Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addArray(name: string, options: FieldOptions): this; + /** + * Adding Object Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addObject(name: string, options: FieldOptions): this; + /** + * Adding Pointer Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {string} targetClass Name of the target Pointer Class + * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField} + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addPointer(name: string, targetClass: string, options?: FieldOptions): this; + /** + * Adding Relation Field + * + * @param {string} name Name of the field that will be created on Parse + * @param {string} targetClass Name of the target Pointer Class + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + addRelation(name: string, targetClass: string): this; + /** + * Deleting a Field to Update on a Schema + * + * @param {string} name Name of the field + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + deleteField(name: string): this; + /** + * Deleting an Index to Update on a Schema + * + * @param {string} name Name of the field + * @returns {Parse.Schema} Returns the schema, so you can chain this call. + */ + deleteIndex(name: string): this; } export default ParseSchema; diff --git a/types/ParseSession.d.ts b/types/ParseSession.d.ts index 307bac6cb..aeb0d8c43 100644 --- a/types/ParseSession.d.ts +++ b/types/ParseSession.d.ts @@ -9,37 +9,37 @@ import type { FullOptions } from './RESTController'; * @augments Parse.Object */ declare class ParseSession extends ParseObject { - /** - * @param {object} attributes The initial set of data to store in the user. - */ - constructor(attributes?: any); - /** - * Returns the session token string. - * - * @returns {string} - */ - getSessionToken(): string; - static readOnlyAttributes(): string[]; - /** - * Retrieves the Session object for the currently logged in session. - * - * @param {object} options useMasterKey - * @static - * @returns {Promise} A promise that is resolved with the Parse.Session - * object after it has been fetched. If there is no current user, the - * promise will be rejected. - */ - static current(options: FullOptions): Promise; - /** - * Determines whether the current session token is revocable. - * This method is useful for migrating Express.js or Node.js web apps to - * use revocable sessions. If you are migrating an app that uses the Parse - * SDK in the browser only, please use Parse.User.enableRevocableSession() - * instead, so that sessions can be automatically upgraded. - * - * @static - * @returns {boolean} - */ - static isCurrentSessionRevocable(): boolean; + /** + * @param {object} attributes The initial set of data to store in the user. + */ + constructor(attributes?: any); + /** + * Returns the session token string. + * + * @returns {string} + */ + getSessionToken(): string; + static readOnlyAttributes(): string[]; + /** + * Retrieves the Session object for the currently logged in session. + * + * @param {object} options useMasterKey + * @static + * @returns {Promise} A promise that is resolved with the Parse.Session + * object after it has been fetched. If there is no current user, the + * promise will be rejected. + */ + static current(options: FullOptions): Promise; + /** + * Determines whether the current session token is revocable. + * This method is useful for migrating Express.js or Node.js web apps to + * use revocable sessions. If you are migrating an app that uses the Parse + * SDK in the browser only, please use Parse.User.enableRevocableSession() + * instead, so that sessions can be automatically upgraded. + * + * @static + * @returns {boolean} + */ + static isCurrentSessionRevocable(): boolean; } export default ParseSession; diff --git a/types/ParseUser.d.ts b/types/ParseUser.d.ts index 98295d105..473fc8870 100644 --- a/types/ParseUser.d.ts +++ b/types/ParseUser.d.ts @@ -2,16 +2,16 @@ import ParseObject from './ParseObject'; import type { AttributeMap } from './ObjectStateMutations'; import type { RequestOptions, FullOptions } from './RESTController'; export type AuthData = { - [key: string]: any; + [key: string]: any; }; export type AuthProviderType = { - authenticate?(options: { - error?: (provider: AuthProviderType, error: string | any) => void; - success?: (provider: AuthProviderType, result: AuthData) => void; - }): void; - restoreAuthentication(authData: any): boolean; - getAuthType(): string; - deauthenticate?(): void; + authenticate?(options: { + error?: (provider: AuthProviderType, error: string | any) => void; + success?: (provider: AuthProviderType, result: AuthData) => void; + }): void; + restoreAuthentication(authData: any): boolean; + getAuthType(): string; + deauthenticate?(): void; }; /** *

    A Parse.User object is a local representation of a user persisted to the @@ -24,533 +24,495 @@ export type AuthProviderType = { * @augments Parse.Object */ declare class ParseUser extends ParseObject { - /** - * @param {object} attributes The initial set of data to store in the user. - */ - constructor(attributes?: AttributeMap); - /** - * Request a revocable session token to replace the older style of token. - * - * @param {object} options - * Valid options are:

      - *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    - * @returns {Promise} A promise that is resolved when the replacement - * token has been fetched. - */ - _upgradeToRevocableSession(options: RequestOptions): Promise; - /** - * Parse allows you to link your users with {@link https://docs.parseplatform.org/parse-server/guide/#oauth-and-3rd-party-authentication 3rd party authentication}, enabling - * your users to sign up or log into your application using their existing identities. - * Since 2.9.0 - * - * @see {@link https://docs.parseplatform.org/js/guide/#linking-users Linking Users} - * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider} - * @param {object} options - * @param {object} [options.authData] AuthData to link with - *
      - *
    • If provider is string, options is {@link http://docs.parseplatform.org/parse-server/guide/#supported-3rd-party-authentications authData} - *
    • If provider is AuthProvider, options is saveOpts - *
    - * @param {object} saveOpts useMasterKey / sessionToken - * @returns {Promise} A promise that is fulfilled with the user is linked - */ - linkWith( - provider: AuthProviderType, - options: { - authData?: AuthData; - }, - saveOpts?: FullOptions - ): Promise; - /** - * @param provider - * @param options - * @param {object} [options.authData] - * @param saveOpts - * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} - * @returns {Promise} - */ - _linkWith( - provider: any, - options: { - authData?: AuthData; - }, - saveOpts?: FullOptions - ): Promise; - /** - * Synchronizes auth data for a provider (e.g. puts the access token in the - * right place to be used by the Facebook SDK). - * - * @param provider - */ - _synchronizeAuthData(provider: string | AuthProviderType): void; - /** - * Synchronizes authData for all providers. - */ - _synchronizeAllAuthData(): void; - /** - * Removes null values from authData (which exist temporarily for unlinking) - */ - _cleanupAuthData(): void; - /** - * Unlinks a user from a service. - * - * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider} - * @param {object} options MasterKey / SessionToken - * @returns {Promise} A promise that is fulfilled when the unlinking - * finishes. - */ - _unlinkFrom(provider: any, options?: FullOptions): Promise; - /** - * Checks whether a user is linked to a service. - * - * @param {object} provider service to link to - * @returns {boolean} true if link was successful - */ - _isLinked(provider: any): boolean; - /** - * Deauthenticates all providers. - */ - _logOutWithAll(): void; - /** - * Deauthenticates a single provider (e.g. removing access tokens from the - * Facebook SDK). - * - * @param {object} provider service to logout of - */ - _logOutWith(provider: any): void; - /** - * Class instance method used to maintain specific keys when a fetch occurs. - * Used to ensure that the session token is not lost. - * - * @returns {object} sessionToken - */ - _preserveFieldsOnFetch(): AttributeMap; - /** - * Returns true if current would return this user. - * - * @returns {boolean} true if user is cached on disk - */ - isCurrent(): boolean; - /** - * Returns true if current would return this user. - * - * @returns {Promise} true if user is cached on disk - */ - isCurrentAsync(): Promise; - stripAnonymity(): void; - restoreAnonimity(anonymousData: any): void; - /** - * Returns get("username"). - * - * @returns {string} - */ - getUsername(): string | null; - /** - * Calls set("username", username, options) and returns the result. - * - * @param {string} username - */ - setUsername(username: string): void; - /** - * Calls set("password", password, options) and returns the result. - * - * @param {string} password User's Password - */ - setPassword(password: string): void; - /** - * Returns get("email"). - * - * @returns {string} User's Email - */ - getEmail(): string | null; - /** - * Calls set("email", email) and returns the result. - * - * @param {string} email - * @returns {boolean} - */ - setEmail(email: string): this; - /** - * Returns the session token for this user, if the user has been logged in, - * or if it is the result of a query with the master key. Otherwise, returns - * undefined. - * - * @returns {string} the session token, or undefined - */ - getSessionToken(): string | null; - /** - * Checks whether this user is the current user and has been authenticated. - * - * @returns {boolean} whether this user is the current user and is logged in. - */ - authenticated(): boolean; - /** - * Signs up a new user. You should call this instead of save for - * new Parse.Users. This will create a new Parse.User on the server, and - * also persist the session on disk so that you can access the user using - * current. - * - *

    A username and password must be set before calling signUp.

    - * - * @param {object} attrs Extra fields to set on the new user, or null. - * @param {object} options - * Valid options are:
      - *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    • installationId: the installationId which made the request - *
    • context: A dictionary that is accessible in Cloud Code `beforeLogin` and `afterLogin` triggers. - *
    - * @returns {Promise} A promise that is fulfilled when the signup - * finishes. - */ - signUp( - attrs: AttributeMap, - options?: FullOptions & { - context?: AttributeMap; - } - ): Promise; - /** - * Logs in a Parse.User. On success, this saves the session to disk, - * so you can retrieve the currently logged in user using - * current. - * - *

    A username and password must be set before calling logIn.

    - * - * @param {object} options - * Valid options are:
      - *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    • usePost: Use POST method to make the request (default: true) - *
    • installationId: the installationId which made the request - *
    • context: A dictionary that is accessible in Cloud Code `beforeLogin` and `afterLogin` triggers. - *
    - * @returns {Promise} A promise that is fulfilled with the user when - * the login is complete. - */ - logIn( - options?: FullOptions & { - context?: AttributeMap; - } - ): Promise; - /** - * Wrap the default save behavior with functionality to save to local - * storage if this is current user. - * - * @param {...any} args - * @returns {Promise} - */ - save(...args: Array): Promise; - /** - * Wrap the default destroy behavior with functionality that logs out - * the current user when it is destroyed - * - * @param {...any} args - * @returns {Parse.User} - */ - destroy(...args: Array): Promise; - /** - * Wrap the default fetch behavior with functionality to save to local - * storage if this is current user. - * - * @param {...any} args - * @returns {Parse.User} - */ - fetch(...args: Array): Promise; - /** - * Wrap the default fetchWithInclude behavior with functionality to save to local - * storage if this is current user. - * - * @param {...any} args - * @returns {Parse.User} - */ - fetchWithInclude(...args: Array): Promise; - /** - * Verify whether a given password is the password of the current user. - * - * @param {string} password The password to be verified. - * @param {object} options The options. - * @param {boolean} [options.ignoreEmailVerification] Set to `true` to bypass email verification and verify - * the password regardless of whether the email has been verified. This requires the master key. - * @returns {Promise} A promise that is fulfilled with a user when the password is correct. - */ - verifyPassword(password: string, options?: RequestOptions): Promise; - static readOnlyAttributes(): string[]; - /** - * Adds functionality to the existing Parse.User class. - * - * @param {object} protoProps A set of properties to add to the prototype - * @param {object} classProps A set of static properties to add to the class - * @static - * @returns {Parse.User} The newly extended Parse.User class - */ - static extend( - protoProps: { - [prop: string]: any; - }, - classProps: { - [prop: string]: any; - } - ): typeof ParseUser; - /** - * Retrieves the currently logged in ParseUser with a valid session, - * either from memory or localStorage, if necessary. - * - * @static - * @returns {Parse.Object} The currently logged in Parse.User. - */ - static current(): ParseUser | null; - /** - * Retrieves the currently logged in ParseUser from asynchronous Storage. - * - * @static - * @returns {Promise} A Promise that is resolved with the currently - * logged in Parse User - */ - static currentAsync(): Promise; - /** - * Signs up a new user with a username (or email) and password. - * This will create a new Parse.User on the server, and also persist the - * session in localStorage so that you can access the user using - * {@link #current}. - * - * @param {string} username The username (or email) to sign up with. - * @param {string} password The password to sign up with. - * @param {object} attrs Extra fields to set on the new user. - * @param {object} options - * @static - * @returns {Promise} A promise that is fulfilled with the user when - * the signup completes. - */ - static signUp( - username: string, - password: string, - attrs: AttributeMap, - options?: FullOptions - ): Promise; - /** - * Logs in a user with a username (or email) and password. On success, this - * saves the session to disk, so you can retrieve the currently logged in - * user using current. - * - * @param {string} username The username (or email) to log in with. - * @param {string} password The password to log in with. - * @param {object} options - * @static - * @returns {Promise} A promise that is fulfilled with the user when - * the login completes. - */ - static logIn(username: string, password: string, options?: FullOptions): Promise; - /** - * Logs in a user with a username (or email) and password, and authData. On success, this - * saves the session to disk, so you can retrieve the currently logged in - * user using current. - * - * @param {string} username The username (or email) to log in with. - * @param {string} password The password to log in with. - * @param {object} authData The authData to log in with. - * @param {object} options - * @static - * @returns {Promise} A promise that is fulfilled with the user when - * the login completes. - */ - static logInWithAdditionalAuth( - username: string, - password: string, - authData: AuthData, - options?: FullOptions - ): Promise; - /** - * Logs in a user with an objectId. On success, this saves the session - * to disk, so you can retrieve the currently logged in user using - * current. - * - * @param {string} userId The objectId for the user. - * @static - * @returns {Promise} A promise that is fulfilled with the user when - * the login completes. - */ - static loginAs(userId: string): Promise; - /** - * Logs in a user with a session token. On success, this saves the session - * to disk, so you can retrieve the currently logged in user using - * current. - * - * @param {string} sessionToken The sessionToken to log in with. - * @param {object} options - * @param {boolean} [options.useMasterKey] - * @static - * @returns {Promise} A promise that is fulfilled with the user when - * the login completes. - */ - static become(sessionToken: string, options?: RequestOptions): Promise; - /** - * Retrieves a user with a session token. - * - * @param {string} sessionToken The sessionToken to get user with. - * @param {object} options - * @param {boolean} [options.useMasterKey] - * @static - * @returns {Promise} A promise that is fulfilled with the user is fetched. - */ - static me(sessionToken: string, options?: RequestOptions): Promise; - /** - * Logs in a user with a session token. On success, this saves the session - * to disk, so you can retrieve the currently logged in user using - * current. If there is no session token the user will not logged in. - * - * @param {object} userJSON The JSON map of the User's data - * @static - * @returns {Promise} A promise that is fulfilled with the user when - * the login completes. - */ - static hydrate(userJSON: AttributeMap): Promise; - /** - * Static version of {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} - * - * @param provider - * @param options - * @param {object} [options.authData] - * @param saveOpts - * @static - * @returns {Promise} - */ - static logInWith( - provider: any, - options: { - authData?: AuthData; - }, - saveOpts?: FullOptions - ): Promise; - /** - * Logs out the currently logged in user session. This will remove the - * session from disk, log out of linked services, and future calls to - * current will return null. - * - * @param {object} options - * @static - * @returns {Promise} A promise that is resolved when the session is - * destroyed on the server. - */ - static logOut(options?: RequestOptions): Promise; - /** - * Requests a password reset email to be sent to the specified email address - * associated with the user account. This email allows the user to securely - * reset their password on the Parse site. - * - * @param {string} email The email address associated with the user that - * forgot their password. - * @param {object} options - * Valid options are:
      - *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    - * @static - * @returns {Promise} - */ - static requestPasswordReset(email: string, options?: RequestOptions): Promise; - /** - * Request an email verification. - * - * @param {string} email The email address associated with the user that - * needs to verify their email. - * @param {object} options - * Valid options are:
      - *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to - * be used for this request. - *
    - * @static - * @returns {Promise} - */ - static requestEmailVerification(email: string, options?: RequestOptions): Promise; - /** - * Verify whether a given password is the password of the current user. - * @static - * - * @param {string} username The username of the user whose password should be verified. - * @param {string} password The password to be verified. - * @param {object} options The options. - * @param {boolean} [options.ignoreEmailVerification] Set to `true` to bypass email verification and verify - * the password regardless of whether the email has been verified. This requires the master key. - * @returns {Promise} A promise that is fulfilled with a user when the password is correct. - */ - static verifyPassword( - username: string, - password: string, - options?: RequestOptions - ): Promise; - /** - * Allow someone to define a custom User class without className - * being rewritten to _User. The default behavior is to rewrite - * User to _User for legacy reasons. This allows developers to - * override that behavior. - * - * @param {boolean} isAllowed Whether or not to allow custom User class - * @static - */ - static allowCustomUserClass(isAllowed: boolean): void; - /** - * Allows a legacy application to start using revocable sessions. If the - * current session token is not revocable, a request will be made for a new, - * revocable session. - * It is not necessary to call this method from cloud code unless you are - * handling user signup or login from the server side. In a cloud code call, - * this function will not attempt to upgrade the current token. - * - * @param {object} options - * @static - * @returns {Promise} A promise that is resolved when the process has - * completed. If a replacement session token is requested, the promise - * will be resolved after a new token has been fetched. - */ - static enableRevocableSession(options?: RequestOptions): Promise; - /** - * Enables the use of become or the current user in a server - * environment. These features are disabled by default, since they depend on - * global objects that are not memory-safe for most servers. - * - * @static - */ - static enableUnsafeCurrentUser(): void; - /** - * Disables the use of become or the current user in any environment. - * These features are disabled on servers by default, since they depend on - * global objects that are not memory-safe for most servers. - * - * @static - */ - static disableUnsafeCurrentUser(): void; - /** - * When registering users with {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} a basic auth provider - * is automatically created for you. - * - * For advanced authentication, you can register an Auth provider to - * implement custom authentication, deauthentication. - * - * @param provider - * @see {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider} - * @see {@link https://docs.parseplatform.org/js/guide/#custom-authentication-module Custom Authentication Module} - * @static - */ - static _registerAuthenticationProvider(provider: any): void; - /** - * @param provider - * @param options - * @param {object} [options.authData] - * @param saveOpts - * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith} - * @static - * @returns {Promise} - */ - static _logInWith( - provider: any, - options: { - authData?: AuthData; - }, - saveOpts?: FullOptions - ): Promise; - static _clearCache(): void; - static _setCurrentUserCache(user: ParseUser): void; + /** + * @param {object} attributes The initial set of data to store in the user. + */ + constructor(attributes?: AttributeMap); + /** + * Request a revocable session token to replace the older style of token. + * + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    + * @returns {Promise} A promise that is resolved when the replacement + * token has been fetched. + */ + _upgradeToRevocableSession(options: RequestOptions): Promise; + /** + * Parse allows you to link your users with {@link https://docs.parseplatform.org/parse-server/guide/#oauth-and-3rd-party-authentication 3rd party authentication}, enabling + * your users to sign up or log into your application using their existing identities. + * Since 2.9.0 + * + * @see {@link https://docs.parseplatform.org/js/guide/#linking-users Linking Users} + * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider} + * @param {object} options + * @param {object} [options.authData] AuthData to link with + *
      + *
    • If provider is string, options is {@link http://docs.parseplatform.org/parse-server/guide/#supported-3rd-party-authentications authData} + *
    • If provider is AuthProvider, options is saveOpts + *
    + * @param {object} saveOpts useMasterKey / sessionToken + * @returns {Promise} A promise that is fulfilled with the user is linked + */ + linkWith(provider: AuthProviderType, options: { + authData?: AuthData; + }, saveOpts?: FullOptions): Promise; + /** + * @param provider + * @param options + * @param {object} [options.authData] + * @param saveOpts + * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} + * @returns {Promise} + */ + _linkWith(provider: any, options: { + authData?: AuthData; + }, saveOpts?: FullOptions): Promise; + /** + * Synchronizes auth data for a provider (e.g. puts the access token in the + * right place to be used by the Facebook SDK). + * + * @param provider + */ + _synchronizeAuthData(provider: string | AuthProviderType): void; + /** + * Synchronizes authData for all providers. + */ + _synchronizeAllAuthData(): void; + /** + * Removes null values from authData (which exist temporarily for unlinking) + */ + _cleanupAuthData(): void; + /** + * Unlinks a user from a service. + * + * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider} + * @param {object} options MasterKey / SessionToken + * @returns {Promise} A promise that is fulfilled when the unlinking + * finishes. + */ + _unlinkFrom(provider: any, options?: FullOptions): Promise; + /** + * Checks whether a user is linked to a service. + * + * @param {object} provider service to link to + * @returns {boolean} true if link was successful + */ + _isLinked(provider: any): boolean; + /** + * Deauthenticates all providers. + */ + _logOutWithAll(): void; + /** + * Deauthenticates a single provider (e.g. removing access tokens from the + * Facebook SDK). + * + * @param {object} provider service to logout of + */ + _logOutWith(provider: any): void; + /** + * Class instance method used to maintain specific keys when a fetch occurs. + * Used to ensure that the session token is not lost. + * + * @returns {object} sessionToken + */ + _preserveFieldsOnFetch(): AttributeMap; + /** + * Returns true if current would return this user. + * + * @returns {boolean} true if user is cached on disk + */ + isCurrent(): boolean; + /** + * Returns true if current would return this user. + * + * @returns {Promise} true if user is cached on disk + */ + isCurrentAsync(): Promise; + stripAnonymity(): void; + restoreAnonimity(anonymousData: any): void; + /** + * Returns get("username"). + * + * @returns {string} + */ + getUsername(): string | null; + /** + * Calls set("username", username, options) and returns the result. + * + * @param {string} username + */ + setUsername(username: string): void; + /** + * Calls set("password", password, options) and returns the result. + * + * @param {string} password User's Password + */ + setPassword(password: string): void; + /** + * Returns get("email"). + * + * @returns {string} User's Email + */ + getEmail(): string | null; + /** + * Calls set("email", email) and returns the result. + * + * @param {string} email + * @returns {boolean} + */ + setEmail(email: string): this; + /** + * Returns the session token for this user, if the user has been logged in, + * or if it is the result of a query with the master key. Otherwise, returns + * undefined. + * + * @returns {string} the session token, or undefined + */ + getSessionToken(): string | null; + /** + * Checks whether this user is the current user and has been authenticated. + * + * @returns {boolean} whether this user is the current user and is logged in. + */ + authenticated(): boolean; + /** + * Signs up a new user. You should call this instead of save for + * new Parse.Users. This will create a new Parse.User on the server, and + * also persist the session on disk so that you can access the user using + * current. + * + *

    A username and password must be set before calling signUp.

    + * + * @param {object} attrs Extra fields to set on the new user, or null. + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • installationId: the installationId which made the request + *
    • context: A dictionary that is accessible in Cloud Code `beforeLogin` and `afterLogin` triggers. + *
    + * @returns {Promise} A promise that is fulfilled when the signup + * finishes. + */ + signUp(attrs: AttributeMap, options?: FullOptions & { + context?: AttributeMap; + }): Promise; + /** + * Logs in a Parse.User. On success, this saves the session to disk, + * so you can retrieve the currently logged in user using + * current. + * + *

    A username and password must be set before calling logIn.

    + * + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    • usePost: Use POST method to make the request (default: true) + *
    • installationId: the installationId which made the request + *
    • context: A dictionary that is accessible in Cloud Code `beforeLogin` and `afterLogin` triggers. + *
    + * @returns {Promise} A promise that is fulfilled with the user when + * the login is complete. + */ + logIn(options?: FullOptions & { + context?: AttributeMap; + }): Promise; + /** + * Wrap the default save behavior with functionality to save to local + * storage if this is current user. + * + * @param {...any} args + * @returns {Promise} + */ + save(...args: Array): Promise; + /** + * Wrap the default destroy behavior with functionality that logs out + * the current user when it is destroyed + * + * @param {...any} args + * @returns {Parse.User} + */ + destroy(...args: Array): Promise; + /** + * Wrap the default fetch behavior with functionality to save to local + * storage if this is current user. + * + * @param {...any} args + * @returns {Parse.User} + */ + fetch(...args: Array): Promise; + /** + * Wrap the default fetchWithInclude behavior with functionality to save to local + * storage if this is current user. + * + * @param {...any} args + * @returns {Parse.User} + */ + fetchWithInclude(...args: Array): Promise; + /** + * Verify whether a given password is the password of the current user. + * + * @param {string} password The password to be verified. + * @param {object} options The options. + * @param {boolean} [options.ignoreEmailVerification] Set to `true` to bypass email verification and verify + * the password regardless of whether the email has been verified. This requires the master key. + * @returns {Promise} A promise that is fulfilled with a user when the password is correct. + */ + verifyPassword(password: string, options?: RequestOptions): Promise; + static readOnlyAttributes(): string[]; + /** + * Adds functionality to the existing Parse.User class. + * + * @param {object} protoProps A set of properties to add to the prototype + * @param {object} classProps A set of static properties to add to the class + * @static + * @returns {Parse.User} The newly extended Parse.User class + */ + static extend(protoProps: { + [prop: string]: any; + }, classProps: { + [prop: string]: any; + }): typeof ParseUser; + /** + * Retrieves the currently logged in ParseUser with a valid session, + * either from memory or localStorage, if necessary. + * + * @static + * @returns {Parse.Object} The currently logged in Parse.User. + */ + static current(): ParseUser | null; + /** + * Retrieves the currently logged in ParseUser from asynchronous Storage. + * + * @static + * @returns {Promise} A Promise that is resolved with the currently + * logged in Parse User + */ + static currentAsync(): Promise; + /** + * Signs up a new user with a username (or email) and password. + * This will create a new Parse.User on the server, and also persist the + * session in localStorage so that you can access the user using + * {@link #current}. + * + * @param {string} username The username (or email) to sign up with. + * @param {string} password The password to sign up with. + * @param {object} attrs Extra fields to set on the new user. + * @param {object} options + * @static + * @returns {Promise} A promise that is fulfilled with the user when + * the signup completes. + */ + static signUp(username: string, password: string, attrs: AttributeMap, options?: FullOptions): Promise; + /** + * Logs in a user with a username (or email) and password. On success, this + * saves the session to disk, so you can retrieve the currently logged in + * user using current. + * + * @param {string} username The username (or email) to log in with. + * @param {string} password The password to log in with. + * @param {object} options + * @static + * @returns {Promise} A promise that is fulfilled with the user when + * the login completes. + */ + static logIn(username: string, password: string, options?: FullOptions): Promise; + /** + * Logs in a user with a username (or email) and password, and authData. On success, this + * saves the session to disk, so you can retrieve the currently logged in + * user using current. + * + * @param {string} username The username (or email) to log in with. + * @param {string} password The password to log in with. + * @param {object} authData The authData to log in with. + * @param {object} options + * @static + * @returns {Promise} A promise that is fulfilled with the user when + * the login completes. + */ + static logInWithAdditionalAuth(username: string, password: string, authData: AuthData, options?: FullOptions): Promise; + /** + * Logs in a user with an objectId. On success, this saves the session + * to disk, so you can retrieve the currently logged in user using + * current. + * + * @param {string} userId The objectId for the user. + * @static + * @returns {Promise} A promise that is fulfilled with the user when + * the login completes. + */ + static loginAs(userId: string): Promise; + /** + * Logs in a user with a session token. On success, this saves the session + * to disk, so you can retrieve the currently logged in user using + * current. + * + * @param {string} sessionToken The sessionToken to log in with. + * @param {object} options + * @param {boolean} [options.useMasterKey] + * @static + * @returns {Promise} A promise that is fulfilled with the user when + * the login completes. + */ + static become(sessionToken: string, options?: RequestOptions): Promise; + /** + * Retrieves a user with a session token. + * + * @param {string} sessionToken The sessionToken to get user with. + * @param {object} options + * @param {boolean} [options.useMasterKey] + * @static + * @returns {Promise} A promise that is fulfilled with the user is fetched. + */ + static me(sessionToken: string, options?: RequestOptions): Promise; + /** + * Logs in a user with a session token. On success, this saves the session + * to disk, so you can retrieve the currently logged in user using + * current. If there is no session token the user will not logged in. + * + * @param {object} userJSON The JSON map of the User's data + * @static + * @returns {Promise} A promise that is fulfilled with the user when + * the login completes. + */ + static hydrate(userJSON: AttributeMap): Promise; + /** + * Static version of {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} + * + * @param provider + * @param options + * @param {object} [options.authData] + * @param saveOpts + * @static + * @returns {Promise} + */ + static logInWith(provider: any, options: { + authData?: AuthData; + }, saveOpts?: FullOptions): Promise; + /** + * Logs out the currently logged in user session. This will remove the + * session from disk, log out of linked services, and future calls to + * current will return null. + * + * @param {object} options + * @static + * @returns {Promise} A promise that is resolved when the session is + * destroyed on the server. + */ + static logOut(options?: RequestOptions): Promise; + /** + * Requests a password reset email to be sent to the specified email address + * associated with the user account. This email allows the user to securely + * reset their password on the Parse site. + * + * @param {string} email The email address associated with the user that + * forgot their password. + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    + * @static + * @returns {Promise} + */ + static requestPasswordReset(email: string, options?: RequestOptions): Promise; + /** + * Request an email verification. + * + * @param {string} email The email address associated with the user that + * needs to verify their email. + * @param {object} options + * Valid options are:
      + *
    • useMasterKey: In Cloud Code and Node only, causes the Master Key to + * be used for this request. + *
    + * @static + * @returns {Promise} + */ + static requestEmailVerification(email: string, options?: RequestOptions): Promise; + /** + * Verify whether a given password is the password of the current user. + * @static + * + * @param {string} username The username of the user whose password should be verified. + * @param {string} password The password to be verified. + * @param {object} options The options. + * @param {boolean} [options.ignoreEmailVerification] Set to `true` to bypass email verification and verify + * the password regardless of whether the email has been verified. This requires the master key. + * @returns {Promise} A promise that is fulfilled with a user when the password is correct. + */ + static verifyPassword(username: string, password: string, options?: RequestOptions): Promise; + /** + * Allow someone to define a custom User class without className + * being rewritten to _User. The default behavior is to rewrite + * User to _User for legacy reasons. This allows developers to + * override that behavior. + * + * @param {boolean} isAllowed Whether or not to allow custom User class + * @static + */ + static allowCustomUserClass(isAllowed: boolean): void; + /** + * Allows a legacy application to start using revocable sessions. If the + * current session token is not revocable, a request will be made for a new, + * revocable session. + * It is not necessary to call this method from cloud code unless you are + * handling user signup or login from the server side. In a cloud code call, + * this function will not attempt to upgrade the current token. + * + * @param {object} options + * @static + * @returns {Promise} A promise that is resolved when the process has + * completed. If a replacement session token is requested, the promise + * will be resolved after a new token has been fetched. + */ + static enableRevocableSession(options?: RequestOptions): Promise; + /** + * Enables the use of become or the current user in a server + * environment. These features are disabled by default, since they depend on + * global objects that are not memory-safe for most servers. + * + * @static + */ + static enableUnsafeCurrentUser(): void; + /** + * Disables the use of become or the current user in any environment. + * These features are disabled on servers by default, since they depend on + * global objects that are not memory-safe for most servers. + * + * @static + */ + static disableUnsafeCurrentUser(): void; + /** + * When registering users with {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} a basic auth provider + * is automatically created for you. + * + * For advanced authentication, you can register an Auth provider to + * implement custom authentication, deauthentication. + * + * @param provider + * @see {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider} + * @see {@link https://docs.parseplatform.org/js/guide/#custom-authentication-module Custom Authentication Module} + * @static + */ + static _registerAuthenticationProvider(provider: any): void; + /** + * @param provider + * @param options + * @param {object} [options.authData] + * @param saveOpts + * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith} + * @static + * @returns {Promise} + */ + static _logInWith(provider: any, options: { + authData?: AuthData; + }, saveOpts?: FullOptions): Promise; + static _clearCache(): void; + static _setCurrentUserCache(user: ParseUser): void; } export default ParseUser; diff --git a/types/Push.d.ts b/types/Push.d.ts index 24bf5214c..367171126 100644 --- a/types/Push.d.ts +++ b/types/Push.d.ts @@ -3,10 +3,10 @@ import type ParseObject from './ParseObject'; import type { WhereClause } from './ParseQuery'; import type { FullOptions } from './RESTController'; export type PushData = { - where?: WhereClause | ParseQuery; - push_time?: Date | string; - expiration_time?: Date | string; - expiration_interval?: number; + where?: WhereClause | ParseQuery; + push_time?: Date | string; + expiration_time?: Date | string; + expiration_interval?: number; }; /** * Contains functions to deal with Push in Parse. @@ -57,7 +57,4 @@ export declare function send(data: PushData, options?: FullOptions): Promise * @returns {Parse.Object} Status of Push. */ -export declare function getPushStatus( - pushStatusId: string, - options?: FullOptions -): Promise; +export declare function getPushStatus(pushStatusId: string, options?: FullOptions): Promise; diff --git a/types/RESTController.d.ts b/types/RESTController.d.ts index ad7416781..366c963a0 100644 --- a/types/RESTController.d.ts +++ b/types/RESTController.d.ts @@ -1,41 +1,33 @@ export type RequestOptions = { - useMasterKey?: boolean; - sessionToken?: string; - installationId?: string; - returnStatus?: boolean; - batchSize?: number; - include?: any; - progress?: any; - context?: any; - usePost?: boolean; - ignoreEmailVerification?: boolean; - transaction?: boolean; + useMasterKey?: boolean; + sessionToken?: string; + installationId?: string; + returnStatus?: boolean; + batchSize?: number; + include?: any; + progress?: any; + context?: any; + usePost?: boolean; + ignoreEmailVerification?: boolean; + transaction?: boolean; }; export type FullOptions = { - success?: any; - error?: any; - useMasterKey?: boolean; - sessionToken?: string; - installationId?: string; - progress?: any; - usePost?: boolean; + success?: any; + error?: any; + useMasterKey?: boolean; + sessionToken?: string; + installationId?: string; + progress?: any; + usePost?: boolean; }; declare const RESTController: { - ajax( - method: string, - url: string, - data: any, - headers?: any, - options?: FullOptions - ): - | (Promise & { + ajax(method: string, url: string, data: any, headers?: any, options?: FullOptions): (Promise & { resolve: (res: any) => void; reject: (err: any) => void; - }) - | Promise; - request(method: string, path: string, data: any, options?: RequestOptions): Promise; - handleError(response: any): Promise; - _setXHR(xhr: any): void; - _getXHR(): any; + }) | Promise; + request(method: string, path: string, data: any, options?: RequestOptions): Promise; + handleError(response: any): Promise; + _setXHR(xhr: any): void; + _getXHR(): any; }; export default RESTController; diff --git a/types/SingleInstanceStateController.d.ts b/types/SingleInstanceStateController.d.ts index 1b93bff1f..09743b91e 100644 --- a/types/SingleInstanceStateController.d.ts +++ b/types/SingleInstanceStateController.d.ts @@ -17,11 +17,8 @@ export declare function estimateAttributes(obj: ParseObject): AttributeMap; export declare function commitServerChanges(obj: ParseObject, changes: AttributeMap): void; export declare function enqueueTask(obj: ParseObject, task: () => Promise): Promise; export declare function clearAllState(): void; -export declare function duplicateState( - source: { +export declare function duplicateState(source: { id: string; - }, - dest: { +}, dest: { id: string; - } -): void; +}): void; diff --git a/types/Socket.weapp.d.ts b/types/Socket.weapp.d.ts index de97ad385..c2d9d015f 100644 --- a/types/Socket.weapp.d.ts +++ b/types/Socket.weapp.d.ts @@ -1,10 +1,10 @@ declare class SocketWeapp { - onopen: () => void; - onmessage: () => void; - onclose: () => void; - onerror: () => void; - constructor(serverURL: any); - send(data: any): void; - close(): void; + onopen: () => void; + onmessage: () => void; + onclose: () => void; + onerror: () => void; + constructor(serverURL: any); + send(data: any): void; + close(): void; } export default SocketWeapp; diff --git a/types/Storage.d.ts b/types/Storage.d.ts index 4ecb4c2f2..08d6483df 100644 --- a/types/Storage.d.ts +++ b/types/Storage.d.ts @@ -1,14 +1,14 @@ declare const Storage: { - async(): boolean; - getItem(path: string): string | null; - getItemAsync(path: string): Promise; - setItem(path: string, value: string): void; - setItemAsync(path: string, value: string): Promise; - removeItem(path: string): void; - removeItemAsync(path: string): Promise; - getAllKeys(): Array; - getAllKeysAsync(): Promise>; - generatePath(path: string): string; - _clear(): void; + async(): boolean; + getItem(path: string): string | null; + getItemAsync(path: string): Promise; + setItem(path: string, value: string): void; + setItemAsync(path: string, value: string): Promise; + removeItem(path: string): void; + removeItemAsync(path: string): Promise; + getAllKeys(): Array; + getAllKeysAsync(): Promise>; + generatePath(path: string): string; + _clear(): void; }; export default Storage; diff --git a/types/StorageController.browser.d.ts b/types/StorageController.browser.d.ts index 1d736ba19..00976a894 100644 --- a/types/StorageController.browser.d.ts +++ b/types/StorageController.browser.d.ts @@ -1,9 +1,9 @@ declare const StorageController: { - async: number; - getItem(path: string): string | null; - setItem(path: string, value: string): void; - removeItem(path: string): void; - getAllKeys(): string[]; - clear(): void; + async: number; + getItem(path: string): string | null; + setItem(path: string, value: string): void; + removeItem(path: string): void; + getAllKeys(): string[]; + clear(): void; }; export default StorageController; diff --git a/types/StorageController.default.d.ts b/types/StorageController.default.d.ts index 1d736ba19..00976a894 100644 --- a/types/StorageController.default.d.ts +++ b/types/StorageController.default.d.ts @@ -1,9 +1,9 @@ declare const StorageController: { - async: number; - getItem(path: string): string | null; - setItem(path: string, value: string): void; - removeItem(path: string): void; - getAllKeys(): string[]; - clear(): void; + async: number; + getItem(path: string): string | null; + setItem(path: string, value: string): void; + removeItem(path: string): void; + getAllKeys(): string[]; + clear(): void; }; export default StorageController; diff --git a/types/StorageController.react-native.d.ts b/types/StorageController.react-native.d.ts index 538a3654a..a95ebbf73 100644 --- a/types/StorageController.react-native.d.ts +++ b/types/StorageController.react-native.d.ts @@ -1,11 +1,11 @@ declare const StorageController: { - async: number; - getItemAsync(path: string): Promise; - setItemAsync(path: string, value: string): Promise; - removeItemAsync(path: string): Promise; - getAllKeysAsync(): Promise; - multiGet(keys: Array): Promise; - multiRemove(keys: Array): Promise>; - clear(): Promise; + async: number; + getItemAsync(path: string): Promise; + setItemAsync(path: string, value: string): Promise; + removeItemAsync(path: string): Promise; + getAllKeysAsync(): Promise; + multiGet(keys: Array): Promise; + multiRemove(keys: Array): Promise>; + clear(): Promise; }; export default StorageController; diff --git a/types/StorageController.weapp.d.ts b/types/StorageController.weapp.d.ts index 267cbfe81..29408def5 100644 --- a/types/StorageController.weapp.d.ts +++ b/types/StorageController.weapp.d.ts @@ -1,9 +1,9 @@ declare const StorageController: { - async: number; - getItem(path: string): string | null; - setItem(path: string, value: string): void; - removeItem(path: string): void; - getAllKeys(): any; - clear(): void; + async: number; + getItem(path: string): string | null; + setItem(path: string, value: string): void; + removeItem(path: string): void; + getAllKeys(): any; + clear(): void; }; export default StorageController; diff --git a/types/TaskQueue.d.ts b/types/TaskQueue.d.ts index ff3eed61f..ae7e55fe9 100644 --- a/types/TaskQueue.d.ts +++ b/types/TaskQueue.d.ts @@ -1,11 +1,11 @@ type Task = { - task: () => Promise; - _completion: any; + task: () => Promise; + _completion: any; }; declare class TaskQueue { - queue: Array; - constructor(); - enqueue(task: () => Promise): Promise; - _dequeue(): void; + queue: Array; + constructor(); + enqueue(task: () => Promise): Promise; + _dequeue(): void; } export default TaskQueue; diff --git a/types/Xhr.weapp.d.ts b/types/Xhr.weapp.d.ts index c214a1677..c314abf06 100644 --- a/types/Xhr.weapp.d.ts +++ b/types/Xhr.weapp.d.ts @@ -1,29 +1,29 @@ declare class XhrWeapp { - UNSENT: number; - OPENED: number; - HEADERS_RECEIVED: number; - LOADING: number; - DONE: number; - header: any; - readyState: any; - status: number; - response: string | undefined; - responseType: string; - responseText: string; - responseHeader: any; - method: string; - url: string; - onabort: () => void; - onprogress: () => void; - onerror: () => void; - onreadystatechange: () => void; - requestTask: any; - constructor(); - getAllResponseHeaders(): string; - getResponseHeader(key: any): any; - setRequestHeader(key: any, value: any): void; - open(method: any, url: any): void; - abort(): void; - send(data: any): void; + UNSENT: number; + OPENED: number; + HEADERS_RECEIVED: number; + LOADING: number; + DONE: number; + header: any; + readyState: any; + status: number; + response: string | undefined; + responseType: string; + responseText: string; + responseHeader: any; + method: string; + url: string; + onabort: () => void; + onprogress: () => void; + onerror: () => void; + onreadystatechange: () => void; + requestTask: any; + constructor(); + getAllResponseHeaders(): string; + getResponseHeader(key: any): any; + setRequestHeader(key: any, value: any): void; + open(method: any, url: any): void; + abort(): void; + send(data: any): void; } export default XhrWeapp; diff --git a/types/encode.d.ts b/types/encode.d.ts index 943bcb39d..d63c1e75a 100644 --- a/types/encode.d.ts +++ b/types/encode.d.ts @@ -1,7 +1 @@ -export default function ( - value: any, - disallowObjects?: boolean, - forcePointers?: boolean, - seen?: Array, - offline?: boolean -): any; +export default function (value: any, disallowObjects?: boolean, forcePointers?: boolean, seen?: Array, offline?: boolean): any; diff --git a/types/promiseUtils.d.ts b/types/promiseUtils.d.ts index a0f44e7c1..e652712a0 100644 --- a/types/promiseUtils.d.ts +++ b/types/promiseUtils.d.ts @@ -1,11 +1,9 @@ export declare function resolvingPromise(): Promise & { - resolve: (res: T) => void; - reject: (err: any) => void; + resolve: (res: T) => void; + reject: (err: any) => void; }; -export declare function when(promises: any): - | Promise - | (Promise & { - resolve: (res: any) => void; - reject: (err: any) => void; - }); +export declare function when(promises: any): Promise | (Promise & { + resolve: (res: any) => void; + reject: (err: any) => void; +}); export declare function continueWhile(test: () => any, emitter: () => Promise): any; diff --git a/types/unsavedChildren.d.ts b/types/unsavedChildren.d.ts index 1e55e3aa4..57881ba36 100644 --- a/types/unsavedChildren.d.ts +++ b/types/unsavedChildren.d.ts @@ -8,7 +8,4 @@ import type ParseObject from './ParseObject'; * @param {boolean} allowDeepUnsaved * @returns {Array} */ -export default function unsavedChildren( - obj: ParseObject, - allowDeepUnsaved?: boolean -): Array; +export default function unsavedChildren(obj: ParseObject, allowDeepUnsaved?: boolean): Array;