declare namespace AV { export var applicationId: string; export var applicationKey: string; export var masterKey: string; export interface AuthOptions { /** * In Cloud Code and Node only, causes the Master Key to be used for this request. */ useMasterKey?: boolean; sessionToken?: string; user?: User; } export interface WaitOption { /** * Set to true to wait for the server to confirm success * before triggering an event. */ wait?: boolean; } export interface SilentOption { /** * Set to true to avoid firing the event. */ silent?: boolean; } export interface IBaseObject { toJSON(): any; } export class BaseObject implements IBaseObject { toJSON(): any; } /** * Creates a new ACL. * If no argument is given, the ACL has no permissions for anyone. * If the argument is a AV.User, the ACL will have read and write * permission for only that user. * If the argument is any other JSON object, that object will be interpretted * as a serialized ACL created with toJSON(). * @see AV.Object#setACL * @class * *
An ACL, or Access Control List can be added to any
* AV.Object to restrict access to only a subset of users
* of your application.
* var fileUploadControl = $("#profilePhotoFileUpload")[0];
* if (fileUploadControl.files.length > 0) {
* var file = fileUploadControl.files[0];
* var name = "photo.jpg";
* var AVFile = new AV.File(name, file);
* AVFile.save().then(function() {
* // The file has been saved to AV.
* }, function(error) {
* // The file either could not be read, or could not be saved to AV.
* });
* }
* @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.
*/
export class File {
constructor(name: string, data: any, type?: string);
static withURL(name: string, url: string): File;
static createWithoutData(objectId: string): File;
destroy
* new GeoPoint(otherGeoPoint)
* new GeoPoint(30, 30)
* new GeoPoint([30, 30])
* new GeoPoint({latitude: 30, longitude: 30})
* new GeoPoint() // defaults to (0, 0)
*
* @class
*
* Represents a latitude / longitude point that may be associated * with a key in a AVObject or used as a reference point for geo queries. * This allows proximity-based queries on the key.
* *Only one key in a class may contain a GeoPoint.
* *Example:
* var point = new AV.GeoPoint(30.0, -20.0);
* var object = new AV.Object("PlaceObject");
* object.set("location", point);
* object.save();
*/
export class GeoPoint extends BaseObject {
latitude: number;
longitude: number;
constructor(arg1?: any, arg2?: any);
static current(options?: AuthOptions): PromiseYou won't normally call this method directly. It is recommended that
* you use a subclass of AV.Object instead, created by calling
* extend.
However, if you don't want to use a subclass, or aren't sure which * subclass is appropriate, you can use this form:
* var object = new AV.Object("ClassName");
*
* That is basically equivalent to:
* var MyClass = AV.Object.extend("ClassName");
* var object = new MyClass();
*
*
* @param {Object} attributes The initial set of data to store in the object.
* @param {Object} options A set of Backbone-like options for creating the
* object. The only option currently supported is "collection".
* @see AV.Object.extend
*
* @class
*
* The fundamental unit of AV data, which implements the Backbone Model * interface.
*/ export class Object extends BaseObject { id: any; createdAt: any; updatedAt: any; attributes: any; cid: string; changed: boolean; className: string; constructor(className?: string, options?: any); constructor(attributes?: string[], options?: any); /** Create a local AV.Object by class name and objectId. @param {string} className class name. @param {string} objectId of the target AV.Object. @static*/ static createWithoutData(className: string, objectId: string): Object; static extend(className: string, protoProps?: any, classProps?: any): any; static fetchAllAV.Events is a fork of Backbone's Events module, provided for your * convenience.
* *A module that can be mixed in to any object in order to provide * it with custom events. You may bind callback functions to an event * with `on`, or remove these functions with `off`. * Triggering an event fires all callbacks in the order that `on` was * called. * *
* var object = {};
* _.extend(object, AV.Events);
* object.on('expand', function(){ alert('expanded'); });
* object.trigger('expand');
*
* For more information, see the * Backbone * documentation.
*/ export class Events { static off(events: string[], callback?: Function, context?: any): Events; static on(events: string[], callback?: Function, context?: any): Events; static trigger(events: string[]): Events; static bind(): Events; static unbind(): Events; on(eventName: string, callback?: Function, context?: any): Events; off(eventName?: string, callback?: Function, context?: any): Events; trigger(eventName: string, ...args: any[]): Events; bind(eventName: string, callback: Function, context?: any): Events; unbind(eventName?: string, callback?: Function, context?: any): Events; } /** * Creates a new AV AV.Query for the given AV.Object subclass. * @param objectClass - * An instance of a subclass of AV.Object, or a AV className string. * @class * *AV.Query defines a query that is used to fetch AV.Objects. The
* most common use case is finding all objects that match a query through the
* find method. For example, this sample code fetches all objects
* of class MyClass. It calls a different function depending on
* whether the fetch succeeded or not.
*
*
* var query = new AV.Query(MyClass);
* query.find({
* success: function(results) {
* // results is an array of AV.Object.
* },
*
* error: function(error) {
* // error is an instance of AV.Error.
* }
* });
*
* A AV.Query can also be used to retrieve a single object whose id is
* known, through the get method. For example, this sample code fetches an
* object of class MyClass and id myId. It calls a
* different function depending on whether the fetch succeeded or not.
*
*
* var query = new AV.Query(MyClass);
* query.get(myId, {
* success: function(object) {
* // object is an instance of AV.Object.
* },
*
* error: function(object, error) {
* // error is an instance of AV.Error.
* }
* });
*
* A AV.Query can also be used to count the number of objects that match
* the query without retrieving all of those objects. For example, this
* sample code counts the number of objects of the class MyClass
*
* var query = new AV.Query(MyClass);
* query.count({
* success: function(number) {
* // There are number instances of MyClass.
* },
*
* error: function(error) {
* // error is an instance of AV.Error.
* }
* });
*/
export class Query extends BaseObject {
objectClass: any;
className: string;
constructor(objectClass: any);
static or(...var_args: Query[]): Query;
static and(...var_args: Query[]): Query;
static doCloudQueryRoles must have a name (which cannot be changed after creation of the * role), and must specify an ACL.
* @class * A AV.Role is a local representation of a role persisted to the AV * cloud. */ export class Role extends Object { constructor(name: string, acl?: ACL); getRoles(): Relation; getUsers(): Relation; getName(): string; setName(name: string): Role; } /** * @class * *A AV.User object is a local representation of a user persisted to the * AV cloud. This class is a subclass of a AV.Object, and retains the * same functionality of a AV.Object, but also extends it with various * user specific methods, like authentication, signing up, and validation of * uniqueness.
*/ export class User extends Object { static current(): User; static signUpobject.set("foo", "bar")
* is an example of a AV.Op.Set. Calling object.unset("foo")
* is a AV.Op.Unset. These operations are stored in a AV.Object and
* sent to the server as part of object.save() operations.
* Instances of AV.Op should be immutable.
*
* You should not create subclasses of AV.Op or instantiate AV.Op
* directly.
*/
export namespace Op {
interface BaseOperation extends IBaseObject {
objects(): any[];
}
interface Add extends BaseOperation {
}
interface AddUnique extends BaseOperation {
}
interface Increment extends IBaseObject {
amount: number;
}
interface Relation extends IBaseObject {
added(): Object[];
removed: Object[];
}
interface Set extends IBaseObject {
value(): any;
}
interface Unset extends IBaseObject {
}
}
/**
* Contains functions to deal with Push in AV
* @name AV.Push
* @namespace
*/
export namespace Push {
function send