-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
1998 lines (1844 loc) · 83.9 KB
/
index.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
/// <reference types="node" />
/// <reference path="node.d.ts" />
/// <reference path="react-native.d.ts" />
import { EventEmitter } from "events";
declare enum ErrorCode {
/** Error code indicating some error other than those enumerated here */
OTHER_CAUSE = -1,
/** Error code indicating that something has gone wrong with the server. */
INTERNAL_SERVER_ERROR = 1,
/** Error code indicating the connection to the Parse servers failed. */
CONNECTION_FAILED = 100,
/** Error code indicating the specified object doesn't exist. */
OBJECT_NOT_FOUND = 101,
/**
* Error code indicating you tried to query with a datatype that doesn't
* support it, like exact matching an array or object.
*/
INVALID_QUERY = 102,
/*
* 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.
*/
INVALID_CLASS_NAME = 103,
/** Error code indicating an unspecified object id. */
MISSING_OBJECT_ID = 104,
/**
* 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.
*/
INVALID_KEY_NAME = 105,
/**
* Error code indicating a malformed pointer. You should not see this unless
* you have been mucking about changing internal Parse code.
*/
INVALID_POINTER = 106,
/*
* 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.
*/
INVALID_JSON = 107,
/**
* Error code indicating that the feature you tried to access is only
* available internally for testing purposes.
*/
COMMAND_UNAVAILABLE = 108,
/** You must call Parse.initialize before using the Parse library. */
NOT_INITIALIZED = 109,
/** Error code indicating that a field was set to an inconsistent type. */
INCORRECT_TYPE = 111,
/**
* 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.
*/
INVALID_CHANNEL_NAME = 112,
/** Error code indicating that push is misconfigured. */
PUSH_MISCONFIGURED = 115,
/** Error code indicating that the object is too large. */
OBJECT_TOO_LARGE = 116,
/** Error code indicating that the operation isn't allowed for clients. */
OPERATION_FORBIDDEN = 119,
/** Error code indicating the result was not found in the cache. */
CACHE_MISS = 120,
/** Error code indicating that an invalid key was used in a nested JSONObject. */
INVALID_NESTED_KEY = 121,
/**
* 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.
*/
INVALID_FILE_NAME = 122,
/** Error code indicating an invalid ACL was provided. */
INVALID_ACL = 123,
/**
* Error code indicating that the request timed out on the server. Typically
* this indicates that the request is too expensive to run.
*/
TIMEOUT = 124,
/** Error code indicating that the email address was invalid. */
INVALID_EMAIL_ADDRESS = 125,
/** Error code indicating a missing content type. */
MISSING_CONTENT_TYPE = 126,
/** Error code indicating a missing content length. */
MISSING_CONTENT_LENGTH = 127,
/** Error code indicating an invalid content length. */
INVALID_CONTENT_LENGTH = 128,
/** Error code indicating a file that was too large. */
FILE_TOO_LARGE = 129,
/** Error code indicating an error saving a file. */
FILE_SAVE_ERROR = 130,
/**
* Error code indicating that a unique field was given a value that is
* already taken.
*/
DUPLICATE_VALUE = 137,
/** Error code indicating that a role's name is invalid. */
INVALID_ROLE_NAME = 139,
/**
* Error code indicating that an application quota was exceeded.
* Upgrade to resolve.
*/
EXCEEDED_QUOTA = 140,
/** Error code indicating that a Cloud Code script failed. */
SCRIPT_FAILED = 141,
/** Error code indicating that a Cloud Code validation failed. */
VALIDATION_ERROR = 142,
/** Error code indicating that invalid image data was provided. */
INVALID_IMAGE_DATA = 150,
/** Error code indicating an unsaved file. */
UNSAVED_FILE_ERROR = 151,
/** Error code indicating an invalid push time. */
INVALID_PUSH_TIME_ERROR = 152,
/** Error code indicating an error deleting a file. */
FILE_DELETE_ERROR = 153,
/** Error code indicating that the application has exceeded its request limit. */
REQUEST_LIMIT_EXCEEDED = 155,
/**
* Error code indicating that the request was a duplicate and has been discarded due to
* idempotency rules.
*/
DUPLICATE_REQUEST = 159,
/** Error code indicating an invalid event name. */
INVALID_EVENT_NAME = 160,
/** Error code indicating an error deleting an unnamed file. */
FILE_DELETE_UNNAMED_ERROR = 161,
/** Error code indicating that the username is missing or empty. */
USERNAME_MISSING = 200,
/** Error code indicating that the password is missing or empty. */
PASSWORD_MISSING = 201,
/** Error code indicating that the username has already been taken. */
USERNAME_TAKEN = 202,
/** Error code indicating that the email has already been taken. */
EMAIL_TAKEN = 203,
/** Error code indicating that the email is missing, but must be specified. */
EMAIL_MISSING = 204,
/** Error code indicating that a user with the specified email was not found. */
EMAIL_NOT_FOUND = 205,
/**
* Error code indicating that a user object without a valid session could
* not be altered.
*/
SESSION_MISSING = 206,
/** Error code indicating that a user can only be created through signup. */
MUST_CREATE_USER_THROUGH_SIGNUP = 207,
/**
* Error code indicating that an an account being linked is already linked
* to another user.
*/
ACCOUNT_ALREADY_LINKED = 208,
/** Error code indicating that the current session token is invalid. */
INVALID_SESSION_TOKEN = 209,
/** Error code indicating an error enabling or verifying MFA */
MFA_ERROR = 210,
/** Error code indicating that a valid MFA token must be provided */
MFA_TOKEN_REQUIRED = 211,
/**
* Error code indicating that a user cannot be linked to an account because
* that account's id could not be found.
*/
LINKED_ID_MISSING = 250,
/**
* Error code indicating that a user with a linked (e.g. Facebook) account
* has an invalid session.
*/
INVALID_LINKED_SESSION = 251,
/**
* Error code indicating that a service being linked (e.g. Facebook or
* Twitter) is unsupported.
*/
UNSUPPORTED_SERVICE = 252,
/** Error code indicating an invalid operation occured on schema */
INVALID_SCHEMA_OPERATION = 255,
/**
* 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.
*/
AGGREGATE_ERROR = 600,
/** Error code indicating the client was unable to read an input file. */
FILE_READ_ERROR = 601,
/*
* 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.
*/
X_DOMAIN_REQUEST = 602,
}
declare global {
namespace Parse {
let applicationId: string;
let javaScriptKey: string | undefined;
let liveQueryServerURL: string;
let masterKey: string | undefined;
let serverAuthToken: string | undefined;
let serverAuthType: string | undefined;
let serverURL: string;
let secret: string;
let idempotency: boolean;
let encryptedUser: boolean;
interface BatchSizeOption {
batchSize?: number | undefined;
}
interface CascadeSaveOption {
/** If `false`, nested objects will not be saved (default is `true`). */
cascadeSave?: boolean | undefined;
}
interface SuccessOption {
success?: Function | undefined;
}
interface ErrorOption {
error?: Function | undefined;
}
interface ContextOption {
context?: { [key: string]: any };
}
interface FullOptions {
success?: Function | undefined;
error?: Function | undefined;
useMasterKey?: boolean | undefined;
sessionToken?: string | undefined;
installationId?: string | undefined;
progress?: Function | undefined;
/**
* logIn will default to POST instead of GET method since
* version 3.0.0 for security reasons.
* If you need to use GET set this to `false`.
*/
usePost?: boolean;
}
interface RequestOptions {
useMasterKey?: boolean | undefined;
sessionToken?: string | undefined;
installationId?: string | undefined;
batchSize?: number | undefined;
include?: string | string[] | undefined;
progress?: Function | undefined;
}
interface SuccessFailureOptions extends SuccessOption, ErrorOption {}
interface SignUpOptions {
useMasterKey?: boolean | undefined;
installationId?: string | undefined;
}
interface SessionTokenOption {
sessionToken?: string | undefined;
}
interface WaitOption {
/**
* Set to true to wait for the server to confirm success
* before triggering an event.
*/
wait?: boolean | undefined;
}
interface UseMasterKeyOption {
/**
* In Cloud Code and Node only, causes the Master Key to be used for this request.
*/
useMasterKey?: boolean | undefined;
}
/**
* https://github.com/parse-community/Parse-SDK-JS/pull/1294/files
* feat: Add option to return raw json from queries
*/
interface RawJSONOptions {
/** (3.0.0+) json: Return raw json without converting to Parse.Object */
json?: boolean;
}
interface ScopeOptions extends SessionTokenOption, UseMasterKeyOption {}
interface SilentOption {
/**
* Set to true to avoid firing the event.
*/
silent?: boolean | undefined;
}
interface Pointer {
__type: string;
className: string;
objectId: string;
}
interface AuthData {
[key: string]: any;
}
/**
* Interface declaration for Authentication Providers
* https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html
*/
interface AuthProvider {
/**
* Called when _linkWith isn't passed authData. Handle your own authentication here.
*/
authenticate: () => void;
/**
* (Optional) Called when service is unlinked. Handle any cleanup here.
*/
deauthenticate?: (() => void) | undefined;
/**
* Unique identifier for this Auth Provider.
*/
getAuthType: () => string;
/**
* Called when auth data is syncronized. Can be used to determine if authData is still valid
*/
restoreAuthentication: () => boolean;
}
interface BaseAttributes {
createdAt: Date;
objectId: string;
updatedAt: Date;
}
interface CommonAttributes {
ACL: ACL;
}
interface JSONBaseAttributes {
createdAt: string;
objectId: string;
updatedAt: string;
}
/**
* Creates a new ACL.
* If no argument is given, the ACL has no permissions for anyone.
* If the argument is a Parse.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 Parse.Object#setACL
*
* <p>An ACL, or Access Control List can be added to any
* <code>Parse.Object</code> to restrict access to only a subset of users
* of your application.</p>
*/
class ACL {
permissionsById: any;
constructor(arg1?: any);
setPublicReadAccess(allowed: boolean): void;
getPublicReadAccess(): boolean;
setPublicWriteAccess(allowed: boolean): void;
getPublicWriteAccess(): boolean;
setReadAccess(userId: User | string, allowed: boolean): void;
getReadAccess(userId: User | string): boolean;
setWriteAccess(userId: User | string, allowed: boolean): void;
getWriteAccess(userId: User | string): boolean;
setRoleReadAccess(role: Role | string, allowed: boolean): void;
getRoleReadAccess(role: Role | string): boolean;
setRoleWriteAccess(role: Role | string, allowed: boolean): void;
getRoleWriteAccess(role: Role | string): boolean;
toJSON(): any;
}
/**
* A Parse.File is a local representation of a file that is saved to the Parse
* cloud.
* @param name 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 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 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.
* });
* }</pre>
* @param type Optional Content-Type header to use for the file. If
* this is omitted, the content type will be inferred from the name's
* extension.
*/
class File {
constructor(
name: string,
data: number[] | { base64: string } | { size: number; type: string } | { uri: string },
type?: string,
);
/**
* 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 that is resolved with base64 data
*/
getData(): Promise<string>;
url(options?: { forceSecure?: boolean | undefined }): string;
metadata(): Record<string, any>;
tags(): Record<string, any>;
name(): string;
save(options?: FullOptions): Promise<File>;
cancel(): void;
destroy(options?: FullOptions): Promise<File>;
toJSON(): { __type: string; name: string; url: string };
equals(other: File): boolean;
setMetadata(metadata: Record<string, any>): void;
addMetadata(key: string, value: any): void;
setTags(tags: Record<string, any>): void;
addTag(key: string, value: any): void;
readonly _url: string;
}
/**
* 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>
*
* <p>Represents a latitude / longitude point that may be associated
* with a key in a ParseObject 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 Parse.GeoPoint(30.0, -20.0);
* var object = new Parse.Object("PlaceObject");
* object.set("location", point);
* object.save();</pre></p>
*/
class GeoPoint {
latitude: number;
longitude: number;
constructor(latitude: number, longitude: number);
constructor(coords?: { latitude: number; longitude: number } | [number, number]);
current(options?: SuccessFailureOptions): GeoPoint;
radiansTo(point: GeoPoint): number;
kilometersTo(point: GeoPoint): number;
milesTo(point: GeoPoint): number;
toJSON(): any;
}
/**
* A class that is used to access all of the children of a many-to-many relationship.
* Each instance of Parse.Relation is associated with a particular parent object and key.
*/
class Relation<S extends Object = Object, T extends Object = Object> {
parent: S;
key: string;
targetClassName: string;
constructor(parent?: S, key?: string);
// Adds a Parse.Object or an array of Parse.Objects to the relation.
add(object: T | T[]): void;
// Returns a Parse.Query that is limited to objects in this relation.
query(): Query<T>;
// Removes a Parse.Object or an array of Parse.Objects from this relation.
remove(object: T | T[]): void;
toJSON(): any;
}
interface Attributes {
[key: string]: any;
}
/**
* 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>Parse.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 Parse.Object("ClassName");
* </pre>
* That is basically equivalent to:<pre>
* var MyClass = Parse.Object.extend("ClassName");
* var object = new MyClass();
* </pre></p>
*
* @param attributes The initial set of data to store in the object.
* @param options The options for this object instance.
* @see Parse.Object.extend
*
* Creates a new model with defined attributes.
*/
interface Object<T extends Attributes = Attributes> {
id: string;
createdAt: Date;
updatedAt: Date;
attributes: T;
className: string;
add<K extends { [K in keyof T]: NonNullable<T[K]> extends any[] ? K : never }[keyof T]>(
attr: K,
item: NonNullable<T[K]>[number],
): this | false;
addAll<K extends { [K in keyof T]: NonNullable<T[K]> extends any[] ? K : never }[keyof T]>(
attr: K,
items: NonNullable<T[K]>,
): this | false;
addAllUnique: this["addAll"];
addUnique: this["add"];
clear(options: any): any;
clone(): this;
destroy(options?: Object.DestroyOptions): Promise<this>;
/** EventuallyQueue API; added in version 3.0.0 */
destroyEventually(options?: Object.DestroyOptions): Promise<this>;
dirty(attr?: Extract<keyof T, string>): boolean;
dirtyKeys(): string[];
equals<T extends Object>(other: T): boolean;
escape(attr: Extract<keyof T, string>): string;
existed(): boolean;
exists(options?: RequestOptions): Promise<boolean>;
fetch(options?: Object.FetchOptions): Promise<this>;
fetchFromLocalDatastore(): Promise<this>;
fetchWithInclude<K extends Extract<keyof T, string>>(
keys: K | Array<K | K[]>,
options?: RequestOptions,
): Promise<this>;
get<K extends Extract<keyof T, string>>(attr: K): T[K];
getACL(): ACL | undefined;
has(attr: Extract<keyof T, string>): boolean;
increment(attr: Extract<keyof T, string>, amount?: number): this | false;
decrement(attr: Extract<keyof T, string>, amount?: number): this | false;
initialize(): void;
isDataAvailable(): boolean;
isNew(): boolean;
isPinned(): Promise<boolean>;
isValid(): boolean;
newInstance(): this;
op(attr: Extract<keyof T, string>): any;
pin(): Promise<void>;
pinWithName(name: string): Promise<void>;
relation<R extends Object, K extends Extract<keyof T, string> = Extract<keyof T, string>>(
attr: T[K] extends Relation ? K : never,
): Relation<this, R>;
remove: this["add"];
removeAll: this["addAll"];
revert(...keys: Array<Extract<keyof (T & CommonAttributes), string>>): void;
// "Pick<T, K> | T" is a trick to keep IntelliSense working, see:
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3bdadbf9583c2335197c7e999b9a30880e055f62/types/react/index.d.ts#L482
save<K extends Extract<keyof T, string>>(
attrs?: Pick<T, K> | T | null,
options?: Object.SaveOptions,
): Promise<this>;
save<K extends Extract<keyof T, string>>(
key: K,
value: T[K] extends undefined ? never : T[K],
options?: Object.SaveOptions,
): Promise<this>;
/** EventuallyQueue API; added in version 3.0.0 */
saveEventually(options?: Object.SaveOptions): Promise<this>;
set<K extends Extract<keyof T, string>>(attrs: Pick<T, K> | T, options?: Object.SetOptions): this | false;
set<K extends Extract<keyof T, string>>(
key: K,
value: T[K] extends undefined ? never : T[K],
options?: Object.SetOptions,
): this | false;
setACL(acl: ACL, options?: SuccessFailureOptions): this | false;
toJSON(): Object.ToJSON<T> & JSONBaseAttributes;
toPointer(): Pointer;
unPin(): Promise<void>;
unPinWithName(name: string): Promise<void>;
unset(attr: Extract<keyof T, string>, options?: any): this | false;
validate(attrs: Attributes, options?: SuccessFailureOptions): Error | false;
}
interface ObjectStatic<T extends Object = Object> {
createWithoutData(id: string): T;
destroyAll<T extends Object>(list: T[], options?: Object.DestroyAllOptions): Promise<T[]>;
extend(className: string | { className: string }, protoProps?: any, classProps?: any): any;
fetchAll<T extends Object>(list: T[], options: Object.FetchAllOptions): Promise<T[]>;
fetchAllIfNeeded<T extends Object>(list: T[], options?: Object.FetchAllOptions): Promise<T[]>;
fetchAllIfNeededWithInclude<T extends Object>(
list: T[],
keys: keyof T["attributes"] | Array<keyof T["attributes"]>,
options?: RequestOptions,
): Promise<T[]>;
fetchAllWithInclude<T extends Object>(
list: T[],
keys: keyof T["attributes"] | Array<keyof T["attributes"]>,
options?: RequestOptions,
): Promise<T[]>;
fromJSON(json: any, override?: boolean): T;
pinAll(objects: Object[]): Promise<void>;
pinAllWithName(name: string, objects: Object[]): Promise<void>;
registerSubclass(className: string, clazz: new(options?: any) => T): void;
saveAll<T extends readonly Object[]>(list: T, options?: Object.SaveAllOptions): Promise<T>;
unPinAll(objects: Object[]): Promise<void>;
unPinAllObjects(): Promise<void>;
unPinAllObjectsWithName(name: string): Promise<void>;
unPinAllWithName(name: string, objects: Object[]): Promise<void>;
}
interface ObjectConstructor extends ObjectStatic {
new<T extends Attributes>(className: string, attributes: T, options?: any): Object<T>;
new(className?: string, attributes?: Attributes, options?: any): Object;
}
const Object: ObjectConstructor;
namespace Object {
interface DestroyOptions extends SuccessFailureOptions, WaitOption, ScopeOptions {}
interface DestroyAllOptions extends BatchSizeOption, ScopeOptions {}
interface FetchAllOptions extends SuccessFailureOptions, ScopeOptions {}
interface FetchOptions extends SuccessFailureOptions, ScopeOptions {}
interface SaveOptions
extends CascadeSaveOption, SuccessFailureOptions, SilentOption, ScopeOptions, ContextOption, WaitOption
{}
interface SaveAllOptions extends BatchSizeOption, ScopeOptions {}
interface SetOptions extends ErrorOption, SilentOption {
promise?: any;
}
// From https://github.com/parse-community/Parse-SDK-JS/blob/master/src/encode.js
type Encode<T> = T extends Object ? ReturnType<T["toJSON"]> | Pointer
: T extends ACL | GeoPoint | Polygon | Relation | File ? ReturnType<T["toJSON"]>
: T extends Date ? { __type: "Date"; iso: string }
: T extends RegExp ? string
: T extends Array<infer R>
// This recursion is unsupported in <=3.6
? Array<Encode<R>>
: T extends object ? ToJSON<T>
: T;
type ToJSON<T> = {
[K in keyof T]: Encode<T[K]>;
};
}
class Polygon {
constructor(arg1: GeoPoint[] | number[][]);
containsPoint(point: GeoPoint): boolean;
equals(other: any): boolean;
toJSON(): any;
}
/**
* Every Parse application installed on a device registered for
* push notifications has an associated Installation object.
*/
interface Installation<T extends Attributes = Attributes> extends Object<T> {
badge: any;
channels: string[];
timeZone: any;
deviceType: string;
pushType: string;
installationId: string;
deviceToken: string;
channelUris: string;
appName: string;
appVersion: string;
parseVersion: string;
appIdentifier: string;
}
interface InstallationConstructor extends ObjectStatic<Installation> {
new<T extends Attributes>(attributes: T): Installation<T>;
new(): Installation;
}
const Installation: InstallationConstructor;
/**
* Creates a new parse Parse.Query for the given Parse.Object subclass.
* @param objectClass -
* An instance of a subclass of Parse.Object, or a Parse className string.
*
* <p>Parse.Query defines a query that is used to fetch Parse.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 Parse.Query(MyClass);
* query.find({
* success: function(results) {
* // results is an array of Parse.Object.
* },
*
* error: function(error) {
* // error is an instance of Parse.Error.
* }
* });</pre></p>
*
* <p>A Parse.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 Parse.Query(MyClass);
* query.get(myId, {
* success: function(object) {
* // object is an instance of Parse.Object.
* },
*
* error: function(object, error) {
* // error is an instance of Parse.Error.
* }
* });</pre></p>
*
* <p>A Parse.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 Parse.Query(MyClass);
* query.count({
* success: function(number) {
* // There are number instances of MyClass.
* },
*
* error: function(error) {
* // error is an instance of Parse.Error.
* }
* });</pre></p>
*/
class Query<T extends Object = Object> {
objectClass: any;
className: string;
constructor(objectClass: string | (new(...args: any[]) => T | Object));
static and<U extends Object>(...args: Array<Query<U>>): Query<U>;
static fromJSON<U extends Object>(className: string | (new() => U), json: any): Query<U>;
static nor<U extends Object>(...args: Array<Query<U>>): Query<U>;
static or<U extends Object>(...var_args: Array<Query<U>>): Query<U>;
addAscending<K extends keyof T["attributes"] | keyof BaseAttributes>(key: K | K[]): this;
addDescending<K extends keyof T["attributes"] | keyof BaseAttributes>(key: K | K[]): this;
ascending<K extends keyof T["attributes"] | keyof BaseAttributes>(key: K | K[]): this;
aggregate<V = any>(pipeline: Query.AggregationOptions | Query.AggregationOptions[]): Promise<V>;
containedBy<K extends keyof T["attributes"] | keyof BaseAttributes>(
key: K,
values: Array<T["attributes"][K] | (T["attributes"][K] extends Object ? string : never)>,
): this;
containedIn<K extends keyof T["attributes"] | keyof BaseAttributes>(
key: K,
values: Array<T["attributes"][K] | (T["attributes"][K] extends Object ? string : never)>,
): this;
contains<K extends keyof T["attributes"] | keyof BaseAttributes>(key: K, substring: string): this;
containsAll<K extends keyof T["attributes"] | keyof BaseAttributes>(key: K, values: any[]): this;
containsAllStartingWith<K extends keyof T["attributes"] | keyof BaseAttributes>(
key: K,
values: any[],
): this;
count(options?: Query.CountOptions): Promise<number>;
descending<K extends keyof T["attributes"] | keyof BaseAttributes>(key: K | K[]): this;
doesNotExist<K extends keyof T["attributes"] | keyof BaseAttributes>(key: K): this;
doesNotMatchKeyInQuery<
U extends Object,
K extends keyof T["attributes"] | keyof BaseAttributes,
X extends Extract<keyof U["attributes"], string>,
>(key: K, queryKey: X, query: Query<U>): this;
doesNotMatchQuery<U extends Object, K extends keyof T["attributes"]>(key: K, query: Query<U>): this;
distinct<K extends keyof T["attributes"], V = T["attributes"][K]>(key: K): Promise<V[]>;
eachBatch(callback: (objs: T[]) => PromiseLike<void> | void, options?: Query.BatchOptions): Promise<void>;
each(callback: (obj: T) => PromiseLike<void> | void, options?: Query.BatchOptions): Promise<void>;
hint(value: string | object): this;
explain(explain: boolean): this;
map<U>(
callback: (currentObject: T, index: number, query: Query) => PromiseLike<U> | U,
options?: Query.BatchOptions,
): Promise<U[]>;
reduce(
callback: (accumulator: T, currentObject: T, index: number) => PromiseLike<T> | T,
initialValue?: undefined,
options?: Query.BatchOptions,
): Promise<T>;
reduce<U>(
callback: (accumulator: U, currentObject: T, index: number) => PromiseLike<U> | U,
initialValue: U,
options?: Query.BatchOptions,
): Promise<U>;
filter(
callback: (currentObject: T, index: number, query: Query) => PromiseLike<boolean> | boolean,
options?: Query.BatchOptions,
): Promise<T[]>;
endsWith<K extends keyof T["attributes"] | keyof BaseAttributes>(key: K, suffix: string): this;
equalTo<K extends keyof T["attributes"] | keyof BaseAttributes>(
key: K,
value:
| T["attributes"][K]
| (T["attributes"][K] extends Object ? Pointer
: T["attributes"][K] extends Array<infer E> ? E
: never),
): this;
exclude<K extends keyof T["attributes"] | keyof BaseAttributes>(...keys: K[]): this;
exists<K extends keyof T["attributes"] | keyof BaseAttributes>(key: K): this;
find(options?: Query.FindOptions): Promise<T[]>;
findAll(options?: Query.BatchOptions): Promise<T[]>;
first(options?: Query.FirstOptions): Promise<T | undefined>;
fromNetwork(): this;
fromLocalDatastore(): this;
fromPin(): this;
fromPinWithName(name: string): this;
cancel(): this;
fullText<K extends keyof T["attributes"] | keyof BaseAttributes>(
key: K,
value: string,
options?: Query.FullTextOptions,
): this;
get(objectId: string, options?: Query.GetOptions): Promise<T>;
greaterThan<K extends keyof T["attributes"] | keyof BaseAttributes>(
key: K,
value: T["attributes"][K],
): this;
greaterThanOrEqualTo<K extends keyof T["attributes"] | keyof BaseAttributes>(
key: K,
value: T["attributes"][K],
): this;
include<K extends keyof T["attributes"] | keyof BaseAttributes>(...key: K[]): this;
include<K extends keyof T["attributes"] | keyof BaseAttributes>(key: K[]): this;
includeAll(): Query<T>;
lessThan<K extends keyof T["attributes"] | keyof BaseAttributes>(key: K, value: T["attributes"][K]): this;
lessThanOrEqualTo<K extends keyof T["attributes"] | keyof BaseAttributes>(
key: K,
value: T["attributes"][K],
): this;
limit(n: number): Query<T>;
matches<K extends keyof T["attributes"] | keyof BaseAttributes>(
key: K,
regex: RegExp,
modifiers?: string,
): this;
matchesKeyInQuery<
U extends Object,
K extends keyof T["attributes"],
X extends Extract<keyof U["attributes"], string>,
>(key: K, queryKey: X, query: Query<U>): this;
matchesQuery<U extends Object, K extends keyof T["attributes"]>(key: K, query: Query<U>): this;
near<K extends keyof T["attributes"] | keyof BaseAttributes>(key: K, point: GeoPoint): this;
notContainedIn<K extends keyof T["attributes"] | keyof BaseAttributes>(
key: K,
values: Array<T["attributes"][K]>,
): this;
notEqualTo<K extends keyof T["attributes"] | keyof BaseAttributes>(
key: K,
value:
| T["attributes"][K]
| (T["attributes"][K] extends Object ? Pointer
: T["attributes"][K] extends Array<infer E> ? E
: never),
): this;
polygonContains<K extends keyof T["attributes"] | keyof BaseAttributes>(key: K, point: GeoPoint): this;
select<K extends keyof T["attributes"] | keyof BaseAttributes>(...keys: K[]): this;
select<K extends keyof T["attributes"] | keyof BaseAttributes>(keys: K[]): this;
skip(n: number): Query<T>;
sortByTextScore(): this;
startsWith<K extends keyof T["attributes"] | keyof BaseAttributes>(key: K, prefix: string): this;
subscribe(sessionToken?: string): Promise<LiveQuerySubscription>;
toJSON(): any;
withJSON(json: any): this;
withCount(includeCount?: boolean): this;
withinGeoBox<K extends keyof T["attributes"] | keyof BaseAttributes>(
key: K,
southwest: GeoPoint,
northeast: GeoPoint,
): this;
withinKilometers<K extends keyof T["attributes"] | keyof BaseAttributes>(
key: K,
point: GeoPoint,
maxDistance: number,
sorted?: boolean,
): this;
withinMiles<K extends keyof T["attributes"] | keyof BaseAttributes>(
key: K,
point: GeoPoint,
maxDistance: number,
sorted?: boolean,
): this;
withinPolygon<K extends keyof T["attributes"] | keyof BaseAttributes>(key: K, points: number[][]): this;
withinRadians<K extends keyof T["attributes"] | keyof BaseAttributes>(
key: K,
point: GeoPoint,
maxDistance: number,
): this;
}
namespace Query {
interface EachOptions extends SuccessFailureOptions, ScopeOptions {}
interface CountOptions extends SuccessFailureOptions, ScopeOptions {}
interface FindOptions extends SuccessFailureOptions, ScopeOptions, RawJSONOptions {}
interface FirstOptions extends SuccessFailureOptions, ScopeOptions, RawJSONOptions {}
interface GetOptions extends SuccessFailureOptions, ScopeOptions, RawJSONOptions {}
// According to http://docs.parseplatform.org/rest/guide/#aggregate-queries
interface AggregationOptions {
group?: (Record<string, any> & { objectId?: string }) | undefined;
match?: Record<string, any> | undefined;
project?: Record<string, any> | undefined;
limit?: number | undefined;
skip?: number | undefined;
// Sort documentation https://docs.mongodb.com/v3.2/reference/operator/aggregation/sort/#pipe._S_sort
sort?: Record<string, 1 | -1> | undefined;
// Sample documentation: https://docs.mongodb.com/v3.2/reference/operator/aggregation/sample/
sample?: { size: number } | undefined;
// Count documentation: https://docs.mongodb.com/manual/reference/operator/aggregation/count/
count?: string | undefined;
// Lookup documentation: https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/
lookup?:
| {
from: string;
localField: string;
foreignField: string;
as: string;
}
| {
from: string;
let?: Record<string, any>;
pipeline: Record<string, any>;
as: string;
}
| undefined;
// Graph Lookup documentation: https://docs.mongodb.com/manual/reference/operator/aggregation/graphLookup/
graphLookup?:
| {
from: string;
startWith?: string;
connectFromField: string;
connectToField: string;
as: string;
maxDepth?: number;
depthField?: string;
restrictSearchWithMatch?: Record<string, any>;
}
| undefined;
// Facet documentation: https://docs.mongodb.com/manual/reference/operator/aggregation/facet/
facet?: Record<string, Array<Record<string, any>>> | undefined;
// Unwind documentation: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/
unwind?:
| {
path: string;
includeArrayIndex?: string;
preserveNullAndEmptyArrays?: boolean;
}
| string
| undefined;
}
// According to https://parseplatform.org/Parse-SDK-JS/api/2.1.0/Parse.Query.html#fullText
interface FullTextOptions {
language?: string | undefined;
caseSensitive?: boolean | undefined;
diacriticSensitive?: boolean | undefined;
}
interface BatchOptions extends FullOptions {
batchSize?: number | undefined;
}
}
/**
* Represents a LiveQuery Subscription.
*
* @see https://docs.parseplatform.org/js/guide/#live-queries
* @see NodeJS.EventEmitter