import { Parse } from 'parse'; export declare enum operators { EqualTo = "=", NotEqualTo = "!=", GreatherThan = ">", LessThan = "<", LessThanOrEqualTo = "<=", GreatherThanOrEqualTo = ">=", ValueMatches = "matches", ValueStartsWith = "starts", ValueEndsWith = "ends", InArray = "in", NotInArray = "!in", Exists = "exists", NotExists = "!exists" } export declare type EqualTo = '='; export declare type NotEqualTo = '!='; export declare type GreatherThan = '>'; export declare type LessThan = '<'; export declare type LessThanOrEqualTo = '<='; export declare type GreatherThanOrEqualTo = '>='; export declare type InArray = 'in'; export declare type NotInArray = '!in'; export declare type ValueMatches = 'matches'; export declare type ValueStartsWith = 'starts'; export declare type ValueEndsWith = 'ends'; export declare type Exists = 'exists'; export declare type NotExists = '!exists'; export declare type operator = EqualTo | NotEqualTo | GreatherThan | LessThan | GreatherThanOrEqualTo | LessThanOrEqualTo | ValueMatches | ValueStartsWith | ValueEndsWith | InArray | NotInArray; export declare type SimpleQuery = [string | string[], (EqualTo | NotEqualTo), any] | [string | string[], (GreatherThan | LessThan | GreatherThanOrEqualTo | LessThanOrEqualTo), (number | Date)] | [string | string[], (Exists | NotExists)] | [string | string[], (ValueMatches | ValueStartsWith | ValueEndsWith), string] | [string | string[], (InArray | NotInArray), any[]]; export interface AndQuery { and?: [SimpleQuery | AndQuery | OrQuery, SimpleQuery | AndQuery | OrQuery]; } export interface OrQuery { or?: [SimpleQuery | AndQuery | OrQuery, SimpleQuery | AndQuery | OrQuery]; } /** * Parse File Parameters * @param {string} name Name of the file * @param {(string | ArrayBuffer)} data The ArrayBuffer (base64) data from the file * @param {string} type (Optional) Used only to set HTTP Request Header * @param {object} metadata (Optional) Save in metadata the file important informations * @example { size: file.size, type: file.type, ... } * @param {object} tags (Optional) Add usefull tags to the file * @example { user_id: user.id, description: '', ... } */ export interface ParseFile { name: string; data: string | ArrayBuffer; metadata?: object | { size?: number; type?: string; owner?: Parse.User; }; tags?: object; } /** * Query List Params * @param {string} table - The Class name * @param {SimpleQuery[]]} where - Array of SimpleQuerys, in the format: ['column', 'opetator' (=, !=, <, >, <=, >=, starts, ends, matchess, in, !in, exists, !exists), value] * @example [['name', '=', 'shoe'], ['price', 'exists']] * @param {string} or - Use to build boolean querys starting with or where or values pass to this param * @param {string} and - Use to build boolean querys starting with or where or values pass to this param * @param {string} orderBy - the ordering of the results (ascending by default) * @param {boolean} descending - if the result's order is descending instead of the default * @param {number} skip - the number of rows to skip * @param {number} limit - the max number of rows in the result * @param {string} include - the pointers that you wanna included in the result object. eg 'categories' or '*' * @param {string} distinct - only results with distinct results for this column * @param {boolean} count - Include in result the number of elements */ export interface GetListQuery { table: string; where?: SimpleQuery[]; and?: [SimpleQuery] | [SimpleQuery | AndQuery | OrQuery, SimpleQuery | AndQuery | OrQuery]; or?: [SimpleQuery] | [SimpleQuery | AndQuery | OrQuery, SimpleQuery | AndQuery | OrQuery]; orderBy?: string; descending?: boolean; skip?: number; limit?: number; include?: string; distinct?: string; count?: boolean; } /** * Query Relation Params * @param {Parse.Object} item - Parse item * @param {string} relation - The name of the relation column * @param {SimpleQuery[]]} where - Array of SimpleQuerys, in the format: ['column', 'opetator' (=, !=, <, >, <=, >=, starts, ends, matchess, in, !in, exists, !exists), value] * @example [['name', '=', 'shoe'], ['price', 'exists']] * @param {string} or - Use to build boolean querys starting with or where or values pass to this param * @param {string} and - Use to build boolean querys starting with or where or values pass to this param * @param {string} orderBy - the ordering of the results (ascending by default) * @param {boolean} descending - if the result's order is descending instead of the default * @param {number} skip - the number of rows to skip * @param {number} limit - the max number of rows in the result * @param {string} include - the pointers that you wanna included in the result object. eg 'categories' or '*' * @param {string} distinct - only results with distinct results for this column * @param {boolean} count - Include in result the number of elements */ export interface GetRelationQuery { item: Parse.Object; relation: string; where?: SimpleQuery[]; and?: [SimpleQuery] | [SimpleQuery | AndQuery | OrQuery, SimpleQuery | AndQuery | OrQuery]; or?: [SimpleQuery] | [SimpleQuery | AndQuery | OrQuery, SimpleQuery | AndQuery | OrQuery]; orderBy?: string; descending?: boolean; skip?: number; limit?: number; include?: string; distinct?: string; count?: boolean; } /** * Query Where Params * @param {string} table - The Class name * @param {SimpleQuery[]]} where - Array of SimpleQuerys, in the format: ['column', 'opetator' (=, !=, <, >, <=, >=, starts, ends, matchess, in, !in, exists, !exists), value] * @example [['name', '=', 'shoe'], ['price', 'exists']] * @param {string} or - Use to build boolean querys starting with or where or values pass to this param * @param {string} and - Use to build boolean querys starting with or where or values pass to this param * @param {string} orderBy - the ordering of the results (ascending by default) * @param {boolean} descending - if the result's order is descending instead of the default * @param {string} include - the pointers that you wanna included in the result object. eg 'categories' or '*' */ export interface GetWhereQuery { table: string; where?: SimpleQuery[]; and?: [SimpleQuery] | [SimpleQuery | AndQuery | OrQuery, SimpleQuery | AndQuery | OrQuery]; or?: [SimpleQuery] | [SimpleQuery | AndQuery | OrQuery, SimpleQuery | AndQuery | OrQuery]; orderBy?: string; descending?: boolean; include?: string; } /** * Query Relation Params * @param {Parse.Object} item - Parse item * @param {string} relation - The name of the relation column * @param {Parse.Object} relationItem - Parse.Object to be put on the relation * @param {Parse.Object[]]} relationItems - Array of Parse.Object to be put on the relation */ export interface SetRelationObject { item: Parse.Object; relation: string; relationItem?: Parse.Object; relationItems?: Parse.Object[]; } /** * DreamParse Service configurations */ export declare class DreamparseOptions { serverURL: string; appId: string; masterKey?: string; } export declare class Dreamparse { currentUser: Parse.User; parentUser: any; private config; constructor(config: DreamparseOptions); /** * Set the current user */ setUser(): void; /** * Returns the current user or null, if is not logged * @returns {Parse.User} */ getUser(): Parse.User; /** * Returns the Parent user, if exists, or the current otherwise * @returns {Parse.User} */ getParentUser(): Parse.User; /** * Returns true if the current user is an Parent User * @returns {boolean} */ isParent(): boolean; /** * Do the login with email and password * @param {string} email * @param {string} password * @returns {Parse.User} The logged user */ logIn(email: any, password: any): Promise; /** * Register the user * @param {object} params - In the format {name: 'jon doe', email: 'email@email.com', password: '123', .... } * @returns {Parse.User} The new logged user */ signUp(params: any): Promise; /** * Log the user out from parse * @returns {null} */ logOut(): Promise; /** * Send an email to reset the user's password * @param {string} email - The user email * @returns {boolean} If the request was successful */ resetPass(email: any): Promise; /** * Update the current user's informations * @param {object} params - The json object with the params, like: {name: 'jon doe', username: 'jondoe', email: 'email@email.com', password: '123'} * @returns {Parse.User} The current logged user, with the new information */ updateUser(params: any): Promise; /** * Create an Object on Parse * @param {string} table - The Class name * @param {object} params - The json object with the params, like: {name: 'shoe', price: 10.55, units:5, ... } * @returns {Parse.Object} The new created Object */ saveItem(table: string, params: object): Promise; saveItems(table: string, items: object[]): Promise; /** * Get an Object from Parse by the Id * @param {string} table - The Class name * @param {number} itemId - The objectId of the object * @returns {Parse.Object} The requested object or null */ getItem(table: any, itemId: any): Promise; /** * Get an Object from Parse with multiples params * @property {string} table - The Class name * @property {array[sting, operator, any]} where - Array of SimpleQuery * @example [['name', '=', 'shoe'], ['price', 'exists', true]] * @property {string} orderBy - the ordering of the results (ascending by default) * @property {boolean} descending - if the result's order is descending instead of the default * @property {string} include - the pointers that you wanna included in the result object. eg 'categories' or '*' * @returns {Parse.Object} The requested object or null */ getWhere(params: GetWhereQuery): Promise; /** * Update a Parse Object * @param {Parse.Object} item - The Item be update (not the id) * @param {object} params - The json object with the params, like: {name: 'shoe', price: 10.55, units:5, ... } * @returns {Parse.Object} The saved Object */ updateItem(item: any, params: any): Promise; /** * Delete an Object on Parse * @param {Parse.Object} item - The Item be destroyed (not the id) * @returns {boolean} If the operation was successful */ deleteItem(item: any): Promise; private setQuery; private buildBooleanQuery; /** * Query List Params * @property {string} table - The Class name * @property {SimpleQuery[]]} where - Array of SimpleQuerys, in the format: ['column', 'opetator' (=, !=, <, >, <=, >=, starts, ends, matchess, in, !in, exists, !exists), value] * @example [['name', '=', 'shoe'], ['price', 'exists']] * @property {string} or - Use to build boolean querys starting with or where or values pass to this param * @property {string} and - Use to build boolean querys starting with or where or values pass to this param * @property {string} orderBy - the ordering of the results (ascending by default) * @property {boolean} descending - if the result's order is descending instead of the default * @property {number} skip - the number of rows to skip * @property {number} limit - the max number of rows in the result * @property {string} include - the pointers that you wanna included in the result object. eg 'categories' or '*' * @property {string} distinct - only results with distinct results for this column * @property {boolean} count - Include in result the number of elements * @returns {Parse.Object[]} The results from the query */ getList(params: GetListQuery): Promise; /** * Get the number of items on this Class * @param {string} table - The Class name * @param {SimpleQuery[]]} where - Array of SimpleQuerys, in the format: ['column', 'opetator' (=, !=, <, >, <=, >=, starts, ends, matchess, in, !in, exists, !exists), value] * @example [['name', '=', 'shoe'], ['price', 'exists']] * @returns {number} Number of items */ count(table: any, where?: any): Promise; /** * Get a query results from a relation on a Object * @property {Parse.Object} item - Parse item * @property {string} relation - The name of the relation column * @property {SimpleQuery[]]} where - Array of SimpleQuerys, in the format: ['column', 'opetator' (=, !=, <, >, <=, >=, starts, ends, matchess, in, !in, exists, !exists), value] * @example [['name', '=', 'shoe'], ['price', 'exists']] * @property {string} or - Use to build boolean querys starting with or where or values pass to this param * @property {string} and - Use to build boolean querys starting with or where or values pass to this param * @property {string} orderBy - the ordering of the results (ascending by default) * @property {boolean} descending - if the result's order is descending instead of the default * @property {number} skip - the number of rows to skip * @property {number} limit - the max number of rows in the result * @property {string} include - the pointers that you wanna included in the result object. eg 'categories' or '*' * @property {string} distinct - only results with distinct results for this column * @property {boolean} count - Include in result the number of elements * @returns { Parse.Object[] } The results from the query */ getRelation(params: GetRelationQuery): Promise; /** * Put a new Relation in the object * @propety {Parse.Object} item - Parse item * @propety {string} relation - The name of the relation column * @propety {Parse.Object} relationItem - Parse.Object to be put on the relation * @propety {Parse.Object[]]} relationItems - Array of Parse.Object to be put on the relation * @returns { Parse.Object} The results from the query */ putRelation(params: SetRelationObject): Promise; /** * Put a new Relation in the object * @propety {Parse.Object} item - Parse item * @propety {string} relation - The name of the relation column * @propety {Parse.Object} relationItem - Parse.Object to be put on the relation * @propety {Parse.Object[]]} relationItems - Array of Parse.Object to be put on the relation * @returns { Parse.Object} The results from the query */ removeRelation(params: SetRelationObject): Promise; /** * Get the Parse Config * @returns {object} object with the configurationattributes */ getConfig(): Promise; /** * Subscribe for livequery on a Object * @param {string} table - The Class name * @param {string} itemId - The id of the item to be observed * @returns {subscription} The parse subscription */ subscribeItem(table: any, itemId: any): Promise; /** * Subscribe to a query * @property {string} table - The Class name * @property {SimpleQuery[]]} where - Array of SimpleQuerys, in the format: ['column', 'opetator' (=, !=, <, >, <=, >=, starts, ends, matchess, in, !in, exists, !exists), value] * @example [['name', '=', 'shoe'], ['price', 'exists']] * @property {string} or - Use to build boolean querys starting with or where or values pass to this param * @property {string} and - Use to build boolean querys starting with or where or values pass to this param * @property {string} orderBy - the ordering of the results (ascending by default) * @property {boolean} descending - if the result's order is descending instead of the default * @property {number} skip - the number of rows to skip * @property {number} limit - the max number of rows in the result * @property {string} include - the pointers that you wanna included in the result object. eg 'categories' or '*' * @property {string} distinct - only results with distinct results for this column * @property {boolean} count - Include in result the number of elements * @returns {subscription} The results from the query */ subscribeQuery(params: GetListQuery): Promise; /** * Stop the subscription for livequery on a query or item * @param {subscription} subscription - The parse subscription * @returns {boolean} The success of the operation */ unsubscribe(subscription: any): Promise; /** * Parse File Parameters * @property {string} name Name of the file * @property {(string | ArrayBuffer)} data The ArrayBuffer (base64) data from the file * @property {string} type (Optional) Used only to set HTTP Request Header * @property {object} metadata (Optional) Save in metadata the file important informations * @example { size: file.size, type: file.type, ... } * @property {object} tags (Optional) Add usefull tags to the file * @example { user_id: user.id, description: '', ... } * @returns {Parse.Object} The created file */ saveFile(file: ParseFile): Promise; /** * Parse File Parameters * @property {string} name Name of the file * @property {(string | ArrayBuffer)} data The ArrayBuffer (base64) data from the file * @property {string} type (Optional) Used only to set HTTP Request Header * @property {object} metadata (Optional) Save in metadata the file important informations * @example { size: file.size, type: file.type, ... } * @property {object} tags (Optional) Add usefull tags to the file * @example { user_id: user.id, description: '', ... } * @returns {Parse.Object} The created file */ saveFiles(files: ParseFile[]): Promise; /** * Calls a Cloud Function * @param {string} functionName - The name of the Cloud Function * @param {Object} params - the params for the Cloud Function * @returns {any} Whatever the Cloud Function returns */ cloudFunction(functionName: any, params: any): Promise; /** * Loads Parse Class schema * @param {string} class_name - The name of the table in parse * @returns {Object} - Object with the schema of the class */ getSchema(class_name: any): Promise; isSelf(user: any): boolean; isAdmin(user: any): any; createParseObject(className: any): any; saveParseObject(object: any): Promise; }