-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathstorage.d.ts
1590 lines (1426 loc) · 43.9 KB
/
storage.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { Realtime } from 'leancloud-realtime';
import { Adapters } from '@leancloud/adapter-types';
export as namespace AV;
interface IteratorResult<T> {
done: boolean;
value: T;
}
interface AsyncIterator<T> {
next(): Promise<IteratorResult<T>>;
}
declare class EventEmitter<T> {
on<K extends keyof T>(event: K, listener: T[K]): this;
on(evt: string, listener: Function): this;
once<K extends keyof T>(event: K, listener: T[K]): this;
once(evt: string, listener: Function): this;
off<K extends keyof T>(event: T | string, listener?: Function): this;
emit<K extends keyof T>(event: T | string, ...args: any[]): boolean;
}
export var applicationId: string;
export var applicationKey: string;
export var masterKey: string;
interface FetchOptions {
keys?: string | string[];
include?: string | string[];
includeACL?: boolean;
}
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;
}
interface SMSAuthOptions extends AuthOptions {
validateToken?: string;
}
interface CaptchaOptions {
size?: number;
width?: number;
height?: number;
ttl?: number;
}
interface FileSaveOptions extends AuthOptions {
keepFileName?: boolean;
key?: string;
onprogress?: (event: {
loaded: number;
total: number;
percent: number;
}) => any;
}
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 AnonymousAuthData {
/**
* random UUID with lowercase hexadecimal digits
*/
id: string;
[extraAttribute: string]: any;
}
export interface AuthDataWithUID {
uid: string;
access_token: string;
[extraAttribute: string]: any;
}
export interface AuthDataWithOpenID {
openid: string;
access_token: string;
[extraAttribute: string]: any;
}
export type AuthData = AnonymousAuthData | AuthDataWithUID | AuthDataWithOpenID;
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
*
* <p>An ACL, or Access Control List can be added to any
* <code>AV.Object</code> to restrict access to only a subset of users
* of your application.</p>
*/
export class ACL extends BaseObject {
constructor(arg1?: any);
setPublicReadAccess(allowed: boolean): void;
getPublicReadAccess(): boolean;
setPublicWriteAccess(allowed: boolean): void;
getPublicWriteAccess(): boolean;
setReadAccess(userId: User, allowed: boolean): void;
getReadAccess(userId: User): boolean;
setReadAccess(userId: string, allowed: boolean): void;
getReadAccess(userId: string): boolean;
setRoleReadAccess(role: Role, allowed: boolean): void;
setRoleReadAccess(role: string, allowed: boolean): void;
getRoleReadAccess(role: Role): boolean;
getRoleReadAccess(role: string): boolean;
setRoleWriteAccess(role: Role, allowed: boolean): void;
setRoleWriteAccess(role: string, allowed: boolean): void;
getRoleWriteAccess(role: Role): boolean;
getRoleWriteAccess(role: string): boolean;
setWriteAccess(userId: User, allowed: boolean): void;
setWriteAccess(userId: string, allowed: boolean): void;
getWriteAccess(userId: User): boolean;
getWriteAccess(userId: string): boolean;
}
export namespace File {
export type CensorResult = 'rejected' | 'passed' | 'review';
}
/**
* A AV.File is a local representation of a file that is saved to the AV
* cloud.
* @class
* @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. 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:<pre>
* 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.
* });
* }</pre>
* @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 extends BaseObject {
id?: string;
createdAt?: Date;
updatedAt?: Date;
constructor(name: string, data: any, type?: string);
static withURL(name: string, url: string): File;
static createWithoutData(objectId: string): File;
static censor(objectId: string): Promise<File.CensorResult>;
destroy(options?: AuthOptions): Promise<void>;
fetch(fetchOptions?: FetchOptions, options?: AuthOptions): Promise<this>;
get(key: string): any;
getACL(): ACL;
metaData(): any;
metaData(metaKey: string): any;
metaData(metaKey: string, metaValue: any): any;
name(): string;
ownerId(): string;
url(): string;
save(options?: FileSaveOptions): Promise<this>;
set(key: string, value: any): this;
set(data: { [key: string]: any }): this;
setACL(acl: ACL): this;
setUploadHeader(key: string, value: string): this;
size(): any;
thumbnailURL(width: number, height: number): string;
censor(): Promise<File.CensorResult>;
toFullJSON(): any;
}
/**
* Creates a new GeoPoint with any of the following forms:<br>
* <pre>
* new GeoPoint(otherGeoPoint)
* new GeoPoint(30, 30)
* new GeoPoint([30, 30])
* new GeoPoint({latitude: 30, longitude: 30})
* new GeoPoint() // defaults to (0, 0)
* </pre>
* @class
*
* <p>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.</p>
*
* <p>Only one key in a class may contain a GeoPoint.</p>
*
* <p>Example:<pre>
* var point = new AV.GeoPoint(30.0, -20.0);
* var object = new AV.Object("PlaceObject");
* object.set("location", point);
* object.save();</pre></p>
*/
export class GeoPoint extends BaseObject {
latitude: number;
longitude: number;
constructor(other: GeoPoint);
// -90.0 <= latitude <= 90.0, and -180.0 <= longitude <= 180.0,
// but TypeScript does not support refinement types yet (Microsoft/TypeScript#7599),
// so we just specify number here.
constructor(lat: number, lon: number);
constructor(latLon: [number, number]);
constructor(latLonObj: { latitude: number; longitude: number });
constructor();
static current(options?: AuthOptions): Promise<GeoPoint>;
radiansTo(point: GeoPoint): number;
kilometersTo(point: GeoPoint): number;
milesTo(point: GeoPoint): number;
}
/**
* A class that is used to access all of the children of a many-to-many relationship.
* Each instance of AV.Relation is associated with a particular parent object and key.
*/
export class Relation<T extends Queriable> extends BaseObject {
parent: Object;
key: string;
targetClassName: string;
constructor(parent?: Object, key?: string);
static reverseQuery<U extends Queriable>(
parentClass: string | U,
relationKey: string,
child: Object
): Query<U>;
//Adds a AV.Object or an array of AV.Objects to the relation.
add(object: T): void;
// Returns a AV.Query that is limited to objects in this relation.
query(): Query<T>;
// Removes a AV.Object or an array of AV.Objects from this relation.
remove(object: T): void;
}
/**
* Creates a new model with defined attributes. A client id (cid) is
* automatically generated and assigned for you.
*
* <p>You won't normally call this method directly. It is recommended that
* you use a subclass of <code>AV.Object</code> instead, created by calling
* <code>extend</code>.</p>
*
* <p>However, if you don't want to use a subclass, or aren't sure which
* subclass is appropriate, you can use this form:<pre>
* var object = new AV.Object("ClassName");
* </pre>
* That is basically equivalent to:<pre>
* var MyClass = AV.Object.extend("ClassName");
* var object = new MyClass();
* </pre></p>
*
* @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
*
* <p>The fundamental unit of AV data, which implements the Backbone Model
* interface.</p>
*/
export class Object extends BaseObject {
id?: string;
createdAt?: Date;
updatedAt?: Date;
attributes: any;
changed: boolean;
className: string;
query: Query<this>;
constructor(className?: string, options?: any);
constructor(attributes?: string[], options?: any);
static createWithoutData<T extends Object>(
className: string,
objectId: string
): T;
static createWithoutData<T extends Object>(
className: new (...args: any[]) => T,
objectId: string
): T;
static extend(
className: string,
protoProps?: any,
classProps?: any
): typeof Object;
static fetchAll<T extends Object>(
list: T[],
options?: AuthOptions
): Promise<Array<T | Error>>;
static destroyAll(
list: Object[],
options?: Object.DestroyAllOptions
): Promise<Array<void | Error>>;
static saveAll<T extends Object>(
list: T[],
options?: Object.SaveAllOptions
): Promise<Array<T | Error>>;
static register(klass: new (...args: any[]) => Object, name?: string): void;
initialize(): void;
add(attributeName: string, item: any): this;
addUnique(attributeName: string, item: any): any;
bitAnd(attributeName: string, item: number): this;
bitOr(attributeName: string, item: number): this;
bitXor(attributeName: string, item: number): this;
change(options: any): this;
clear(options: any): any;
revert(keys?: string | string[]): this;
clone(): this;
destroy(options?: Object.DestroyOptions): Promise<this>;
dirty(key?: string): boolean;
dirtyKeys(): string[];
escape(attr: string): string;
fetch(fetchOptions?: FetchOptions, options?: AuthOptions): Promise<this>;
fetchWhenSave(enable: boolean): void;
get(attr: string): any;
getACL(): ACL;
getCreatedAt(): Date;
getObjectId(): string;
getUpdatedAt(): Date;
has(attr: string): boolean;
increment(attr: string, amount?: number): this;
isValid(): boolean;
op(attr: string): any;
previous(attr: string): any;
previousAttributes(): any;
relation<T extends Queriable>(attr: string): Relation<T>;
remove(attr: string, item: any): this;
save(
attrs?: object | null,
options?: Object.SaveOptions<this>
): Promise<this>;
save(
key: string,
value: any,
options?: Object.SaveOptions<this>
): Promise<this>;
set(key: string, value: any, options?: Object.SetOptions): this;
set(data: { [key: string]: any }, options?: Object.SetOptions): this;
setACL(acl: ACL, options?: Object.SetOptions): this;
unset(attr: string, options?: Object.SetOptions): this;
validate(attrs: any): any;
toFullJSON(): any;
ignoreHook(
hookName:
| 'beforeSave'
| 'afterSave'
| 'beforeUpdate'
| 'afterUpdate'
| 'beforeDelete'
| 'afterDelete'
): void;
disableBeforeHook(): void;
disableAfterHook(): void;
}
export namespace Object {
interface DestroyOptions extends AuthOptions, WaitOption {}
interface DestroyAllOptions extends AuthOptions {}
interface SaveOptions<T extends Queriable>
extends AuthOptions,
SilentOption,
WaitOption {
fetchWhenSave?: boolean;
query?: Query<T>;
}
interface SaveAllOptions extends AuthOptions {
fetchWhenSave?: boolean;
}
interface SetOptions extends SilentOption {}
}
/**
* Every AV application installed on a device registered for
* push notifications has an associated Installation object.
*/
export class Installation extends Object {
badge: any;
channels: string[];
timeZone: any;
deviceType: string;
pushType: string;
installationId: string;
deviceToken: string;
channelUris: string;
appName: string;
appVersion: string;
AVVersion: string;
appIdentifier: string;
}
/**
* @class
*
* <p>AV.Events is a fork of Backbone's Events module, provided for your
* convenience.</p>
*
* <p>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.
*
* <pre>
* var object = {};
* _.extend(object, AV.Events);
* object.on('expand', function(){ alert('expanded'); });
* object.trigger('expand');</pre></p>
*
* <p>For more information, see the
* <a href="http://documentcloud.github.com/backbone/#Events">Backbone
* documentation</a>.</p>
*/
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;
}
declare type Queriable = Object | File;
declare class BaseQuery<T extends Queriable> extends BaseObject {
className: string;
constructor(objectClass: new (...args: any[]) => T);
constructor(objectClass: string);
addAscending(key: string): this;
addAscending(key: string[]): this;
addDescending(key: string): this;
addDescending(key: string[]): this;
ascending(key: string): this;
ascending(key: string[]): this;
descending(key: string): this;
descending(key: string[]): this;
include(...keys: string[]): this;
include(keys: string[]): this;
select(...keys: string[]): this;
select(keys: string[]): this;
limit(n: number): this;
skip(n: number): this;
find(options?: AuthOptions): Promise<T[]>;
}
/**
* 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
*
* <p>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
* <code>find</code> method. For example, this sample code fetches all objects
* of class <code>MyClass</code>. It calls a different function depending on
* whether the fetch succeeded or not.
*
* <pre>
* 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.
* }
* });</pre></p>
*
* <p>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 <code>MyClass</code> and id <code>myId</code>. It calls a
* different function depending on whether the fetch succeeded or not.
*
* <pre>
* 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.
* }
* });</pre></p>
*
* <p>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 <code>MyClass</code>
* <pre>
* 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.
* }
* });</pre></p>
*/
export class Query<T extends Queriable> extends BaseQuery<T> {
static or<U extends Queriable>(...querys: Query<U>[]): Query<U>;
static and<U extends Queriable>(...querys: Query<U>[]): Query<U>;
static doCloudQuery<U extends Queriable>(
cql: string,
pvalues?: any,
options?: AuthOptions
): Promise<U>;
static fromJSON<U extends Queriable>(json: object): Query<U>;
containedIn(key: string, values: any[]): this;
contains(key: string, substring: string): this;
containsAll(key: string, values: any[]): this;
count(options?: AuthOptions): Promise<number>;
descending(key: string): this;
descending(key: string[]): this;
destroyAll(options?: AuthOptions): Promise<void>;
doesNotExist(key: string): this;
doesNotMatchKeyInQuery<U extends Queriable>(
key: string,
queryKey: string,
query: Query<U>
): this;
doesNotMatchQuery<U extends Queriable>(key: string, query: Query<U>): this;
each(callback: Function, options?: AuthOptions): Promise<T>;
endsWith(key: string, suffix: string): this;
equalTo(key: string, value: any): this;
exists(key: string): this;
findAndCount(options?: AuthOptions): Promise<[T[], number]>;
first(options?: AuthOptions): Promise<T | undefined>;
get(objectId: string, options?: AuthOptions): Promise<T>;
greaterThan(key: string, value: any): this;
greaterThanOrEqualTo(key: string, value: any): this;
includeACL(value?: boolean): this;
lessThan(key: string, value: any): this;
lessThanOrEqualTo(key: string, value: any): this;
matches(key: string, regex: RegExp, modifiers?: any): this;
matchesKeyInQuery<U extends Queriable>(
key: string,
queryKey: string,
query: Query<U>
): this;
matchesQuery<U extends Queriable>(key: string, query: Query<U>): this;
near(key: string, point: GeoPoint): this;
notContainedIn(key: string, values: any[]): this;
notEqualTo(key: string, value: any): this;
sizeEqualTo(key: string, value: number): this;
startsWith(key: string, prefix: string): this;
withinGeoBox(key: string, southwest: GeoPoint, northeast: GeoPoint): this;
withinKilometers(key: string, point: GeoPoint, maxDistance: number): this;
withinMiles(key: string, point: GeoPoint, maxDistance: number): this;
withinRadians(key: string, point: GeoPoint, maxDistance: number): this;
scan(
options?: { orderedBy?: string; batchSize?: number },
authOptions?: AuthOptions
): AsyncIterator<T>;
subscribe(options?: { subscriptionId?: string }): Promise<LiveQuery<T>>;
}
export class LiveQuery<T> extends EventEmitter<LiveQueryEvent<T>> {
static pause(): void;
static resume(): void;
unsubscribe(): Promise<void>;
}
declare interface LiveQueryEvent<T> {
create: (target?: T) => any;
update: (target?: T, updatedKeys?: string[]) => any;
enter: (target?: T, updatedKeys?: string[]) => any;
leave: (target?: T, updatedKeys?: string[]) => any;
delete: (target?: T) => any;
}
export class SearchQuery<T extends Queriable> extends BaseQuery<T> {
sid(sid: string): this;
queryString(q: string): this;
highlights(highlights: string[]): this;
highlights(highlight: string): this;
sortBy(builder: SearchSortBuilder): this;
hits(): number;
hasMore(): boolean;
reset(): void;
}
export class SearchSortBuilder {
constructor();
ascending(key: string, mode?: string, missingKeyBehaviour?: string): this;
descending(key: string, mode?: string, missingKeyBehaviour?: string): this;
whereNear(
key: string,
point?: GeoPoint,
options?: { order?: string; mode?: string; unit?: string }
): this;
build(): string;
}
/**
* Represents a Role on the AV server. Roles represent groupings of
* Users for the purposes of granting permissions (e.g. specifying an ACL
* for an Object). Roles are specified by their sets of child users and
* child roles, all of which are granted any permissions that the parent
* role has.
*
* <p>Roles must have a name (which cannot be changed after creation of the
* role), and must specify an ACL.</p>
* @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<Role>;
getUsers(): Relation<User>;
getName(): string;
setName(name: string): Role;
}
interface OAuthLoginOptions extends AuthOptions {
failOnNotExist?: boolean;
}
interface UnionOptions {
unionIdPlatform?: string;
asMainAccount?: boolean;
}
interface UnionLoginOptions extends OAuthLoginOptions, UnionOptions {}
interface MiniappOptions extends UnionOptions {
preferUnionId: boolean;
}
interface MiniappLoginOptions extends OAuthLoginOptions, MiniappOptions {}
interface AuthInfo {
authData: { [key: string]: any };
provider: string;
platform?: string;
}
/**
* @class
*
* <p>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.</p>
*/
export class User extends Object {
static current(): User;
static currentAsync(): Promise<User>;
static signUp(
username: string,
password: string,
attrs?: any,
options?: AuthOptions
): Promise<User>;
static logIn(username: string, password: string): Promise<User>;
static logOut(): Promise<User>;
static become(sessionToken: string): Promise<User>;
static loginAnonymously(): Promise<User>;
static loginWithMiniApp(
authInfo?: AuthInfo,
options?: OAuthLoginOptions
): Promise<User>;
static loginWithWeapp(options?: MiniappLoginOptions): Promise<User>;
static loginWithWeappWithUnionId(
unionId: string,
unionLoginOptions?: UnionLoginOptions
): Promise<User>;
static loginWithQQApp(options?: MiniappLoginOptions): Promise<User>;
static loginWithQQAppWithUnionId(
unionId: string,
unionLoginOptions?: UnionLoginOptions
): Promise<User>;
static logInWithMobilePhone(
mobilePhone: string,
password: string
): Promise<User>;
static logInWithMobilePhoneSmsCode(
mobilePhone: string,
smsCode: string
): Promise<User>;
static loginWithEmail(email: string, password: string): Promise<User>;
static loginWithAuthData(
authData: AuthData,
platform: string,
options?: OAuthLoginOptions
): Promise<User>;
static signUpOrlogInWithAuthData(
authData: AuthData,
platform: string,
options?: OAuthLoginOptions
): Promise<User>;
static loginWithAuthDataAndUnionId(
authData: AuthData,
platform: string,
unionId: string,
unionLoginOptions?: UnionLoginOptions
): Promise<User>;
static signUpOrlogInWithAuthDataAndUnionId(
authData: AuthData,
platform: string,
unionId: string,
unionLoginOptions?: UnionLoginOptions
): Promise<User>;
static signUpOrlogInWithMobilePhone(
mobilePhoneNumber: string,
smsCode: string,
attributes?: any,
options?: AuthOptions
): Promise<User>;
static requestEmailVerify(
email: string,
options?: AuthOptions
): Promise<User>;
static requestLoginSmsCode(
mobilePhoneNumber: string,
options?: SMSAuthOptions
): Promise<void>;
static requestMobilePhoneVerify(
mobilePhoneNumber: string,
options?: SMSAuthOptions
): Promise<void>;
static requestPasswordReset(
email: string,
options?: AuthOptions
): Promise<User>;
static requestPasswordResetBySmsCode(
mobilePhoneNumber: string,
options?: SMSAuthOptions
): Promise<void>;
static resetPasswordBySmsCode(
code: string,
password: string,
mobilePhoneNumber: string,
options?: AuthOptions
): Promise<User>;
static verifyMobilePhone(
code: string,
mobilePhoneNumber: string,
options?: AuthOptions
): Promise<User>;
static requestChangePhoneNumber(
mobilePhoneNumber: string,
ttl?: number,
options?: SMSAuthOptions
): Promise<void>;
static changePhoneNumber(
mobilePhoneNumber: string,
code: string
): Promise<void>;
static followerQuery<T extends User>(userObjectId: string): Query<T>;
static followeeQuery<T extends User>(userObjectId: string): Query<T>;
loginWithWeapp(options?: MiniappLoginOptions): Promise<User>;
loginWithWeappWithUnionId(
unionId: string,
unionLoginOptions?: UnionLoginOptions
): Promise<User>;
loginWithQQApp(options?: MiniappLoginOptions): Promise<User>;
loginWithQQAppWithUnionId(
unionId: string,
unionLoginOptions?: UnionLoginOptions
): Promise<User>;
loginWithAuthData(
authData: AuthData,
platform: string,
options?: OAuthLoginOptions
): Promise<User>;
loginWithAuthDataAndUnionId(
authData: AuthData,
platform: string,
unionId: string,
unionLoginOptions?: UnionLoginOptions
): Promise<User>;
signUp(attrs?: any, options?: AuthOptions): Promise<User>;
logIn(): Promise<User>;
linkWithWeapp(): Promise<User>;
isAuthenticated(): Promise<boolean>;
isAnonymous(): boolean;
isCurrent(): boolean;
associateWithWeapp(options?: MiniappOptions): Promise<User>;
associateWithWeappWithUnionId(
unionId: string,
unionOptions?: UnionOptions
): Promise<User>;
associateWithQQApp(options?: MiniappOptions): Promise<User>;
associateWithQQAppWithUnionId(
unionId: string,
unionOptions?: UnionOptions
): Promise<User>;
associateWithAuthData(authData: AuthData, platform: string): Promise<User>;
associateWithAuthDataAndUnionId(
authData: AuthData,
platform: string,
unionId: string,
unionOptions?: UnionOptions
): Promise<User>;
dissociateAuthData(platform: string): Promise<User>;
getEmail(): string;
setEmail(email: string): boolean;
setMobilePhoneNumber(mobilePhoneNumber: string): boolean;
getMobilePhoneNumber(): string;
getUsername(): string;
setUsername(username: string): boolean;
setPassword(password: string): boolean;
getSessionToken(): string;
refreshSessionToken(options?: AuthOptions): Promise<User>;
getRoles(options?: AuthOptions): Promise<Role[]>;
follow(user: User | string, authOptions?: AuthOptions): Promise<void>;
follow(
options: { user: User | string; attributes?: object },
authOptions?: AuthOptions
): Promise<void>;
unfollow(user: User | string, authOptions?: AuthOptions): Promise<void>;
unfollow(
options: { user: User | string },
authOptions?: AuthOptions
): Promise<void>;
followerQuery(): Query<this>;
followeeQuery(): Query<this>;
getFollowersAndFollowees(
options?: { skip?: number; limit?: number },
authOptions?: AuthOptions
): Promise<{ followers: User[]; followees: User[] }>;
}
export class Friendship {
static request(
friend: User | string,
authOptions?: AuthOptions
): Promise<void>;
static request(
options: { friend: User | string; attributes?: object },
authOptions?: AuthOptions
): Promise<void>;
static acceptRequest(
request: Object | string,
authOptions?: AuthOptions
): Promise<void>;
static acceptRequest(
options: { request: Object | string; attributes?: object },
authOptions?: AuthOptions
): Promise<void>;
static declineRequest(
request: Object | string,
authOptions?: AuthOptions
): Promise<void>;
}
export class Captcha {
url: string;
captchaToken: string;
validateToken: string;
static request(
options?: CaptchaOptions,
authOptions?: AuthOptions
): Promise<Captcha>;
refresh(): Promise<string>;
verify(code: string): Promise<string>;
bind(
elements?: {
textInput?: string | HTMLInputElement;
image?: string | HTMLImageElement;
verifyButton?: string | HTMLElement;
},
callbacks?: {
success?: (validateToken: string) => any;
error?: (error: Error) => any;
}
): void;
unbind(): void;
}
/**
* @class AV.Conversation
* <p>An AV.Conversation is a local representation of a LeanCloud realtime's
* conversation. This class is a subclass of AV.Object, and retains the
* same functionality of an AV.Object, but also extends it with various
* conversation specific methods, like get members, creators of this conversation.
* </p>
*
* @param {String} name The name of the Role to create.
* @param {Boolean} [options.isSystem] Set this conversation as system conversation.
* @param {Boolean} [options.isTransient] Set this conversation as transient conversation.
*/
export class Conversation extends Object {
constructor(
name: string,
options?: { isSytem?: boolean; isTransient?: boolean }
);
getCreator(): string;
getLastMessageAt(): Date;
getMembers(): string[];
addMember(member: string): Conversation;
getMutedMembers(): string[];
getName(): string;
isTransient(): boolean;
isSystem(): boolean;
send(
fromClient: string,
message: string | object,
options?: { transient?: boolean; pushData?: object; toClients?: string[] },
authOptions?: AuthOptions
): Promise<void>;
broadcast(
fromClient: string,
message: string | object,
options?: { pushData?: object; validTill?: number | Date },
authOptions?: AuthOptions
): Promise<void>;
}
declare class Statistic {
name: string;
value: number;
version?: number;
}
declare interface Ranking {