/
index.d.ts
826 lines (752 loc) · 27.2 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
// Type definitions for appwrite 1.1.0
// Project: Appwrite
/*~ This declaration specifies that the class constructor function
*~ is the exported object from the file
*/
export = Appwrite;
/*~ Write your module's methods and properties in this class */
declare class Appwrite {
constructor();
/**
* @param {string} endpoint
* @returns {this}
*/
setEndpoint(endpoint: string): this;
/**
* Set Project
*
* Your project ID
*
* @param value string
*
* @return this
*/
setProject(project: string): this;
/**
* Set Locale
*
* @param value string
*
* @return this
*/
setLocale(locale: string): this;
account:Appwrite.Account;
avatars:Appwrite.Avatars;
database:Appwrite.Database;
locale:Appwrite.Locale;
storage:Appwrite.Storage;
teams:Appwrite.Teams;
}
declare namespace Appwrite {
export interface Account {
/**
* Get Account
*
* Get currently logged in user data as JSON object.
*
* @throws {Error}
* @return {Promise}
*/
get(): Promise<object>;
/**
* Create Account
*
* Use this endpoint to allow a new user to register a new account in your
* project. After the user registration completes successfully, you can use
* the [/account/verfication](/docs/account#createVerification) route to start
* verifying the user email address. To allow your new user to login to his
* new account, you need to create a new [account
* session](/docs/account#createSession).
*
* @param {string} email
* @param {string} password
* @param {string} name
* @throws {Error}
* @return {Promise}
*/
create(email: string, password: string, name: string): Promise<object>;
/**
* Delete Account
*
* Delete a currently logged in user account. Behind the scene, the user
* record is not deleted but permanently blocked from any access. This is done
* to avoid deleted accounts being overtaken by new users with the same email
* address. Any user-related resources like documents or storage files should
* be deleted separately.
*
* @throws {Error}
* @return {Promise}
*/
delete(): Promise<object>;
/**
* Update Account Email
*
* Update currently logged in user account email address. After changing user
* address, user confirmation status is being reset and a new confirmation
* mail is sent. For security measures, user password is required to complete
* this request.
*
* @param {string} email
* @param {string} password
* @throws {Error}
* @return {Promise}
*/
updateEmail(email: string, password: string): Promise<object>;
/**
* Get Account Logs
*
* Get currently logged in user list of latest security activity logs. Each
* log returns user IP address, location and date and time of log.
*
* @throws {Error}
* @return {Promise}
*/
getLogs(): Promise<object>;
/**
* Update Account Name
*
* Update currently logged in user account name.
*
* @param {string} name
* @throws {Error}
* @return {Promise}
*/
updateName(name: string): Promise<object>;
/**
* Update Account Password
*
* Update currently logged in user password. For validation, user is required
* to pass the password twice.
*
* @param {string} password
* @param {string} oldPassword
* @throws {Error}
* @return {Promise}
*/
updatePassword(password: string, oldPassword: string): Promise<object>;
/**
* Get Account Preferences
*
* Get currently logged in user preferences as a key-value object.
*
* @throws {Error}
* @return {Promise}
*/
getPrefs(): Promise<object>;
/**
* Update Account Preferences
*
* Update currently logged in user account preferences. You can pass only the
* specific settings you wish to update.
*
* @param {object} prefs
* @throws {Error}
* @return {Promise}
*/
updatePrefs(prefs: object): Promise<object>;
/**
* Create Password Recovery
*
* Sends the user an email with a temporary secret key for password reset.
* When the user clicks the confirmation link he is redirected back to your
* app password reset URL with the secret key and email address values
* attached to the URL query string. Use the query string params to submit a
* request to the [PUT /account/recovery](/docs/account#updateRecovery)
* endpoint to complete the process.
*
* @param {string} email
* @param {string} url
* @throws {Error}
* @return {Promise}
*/
createRecovery(email: string, url: string): Promise<object>;
/**
* Complete Password Recovery
*
* Use this endpoint to complete the user account password reset. Both the
* **userId** and **secret** arguments will be passed as query parameters to
* the redirect URL you have provided when sending your request to the [POST
* /account/recovery](/docs/account#createRecovery) endpoint.
*
* Please note that in order to avoid a [Redirect
* Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
* the only valid redirect URLs are the ones from domains you have set when
* adding your platforms in the console interface.
*
* @param {string} userId
* @param {string} secret
* @param {string} password
* @param {string} passwordAgain
* @throws {Error}
* @return {Promise}
*/
updateRecovery(userId: string, secret: string, password: string, passwordAgain: string): Promise<object>;
/**
* Get Account Sessions
*
* Get currently logged in user list of active sessions across different
* devices.
*
* @throws {Error}
* @return {Promise}
*/
getSessions(): Promise<object>;
/**
* Create Account Session
*
* Allow the user to login into his account by providing a valid email and
* password combination. This route will create a new session for the user.
*
* @param {string} email
* @param {string} password
* @throws {Error}
* @return {Promise}
*/
createSession(email: string, password: string): Promise<object>;
/**
* Delete All Account Sessions
*
* Delete all sessions from the user account and remove any sessions cookies
* from the end client.
*
* @throws {Error}
* @return {Promise}
*/
deleteSessions(): Promise<object>;
/**
* Create Account Session with OAuth2
*
* Allow the user to login to his account using the OAuth2 provider of his
* choice. Each OAuth2 provider should be enabled from the Appwrite console
* first. Use the success and failure arguments to provide a redirect URL's
* back to your app when login is completed.
*
* @param {string} provider
* @param {string} success
* @param {string} failure
* @throws {Error}
* @return {Promise}
*/
createOAuth2Session(provider: string, success: string, failure: string): Promise<object>;
/**
* Delete Account Session
*
* Use this endpoint to log out the currently logged in user from all his
* account sessions across all his different devices. When using the option id
* argument, only the session unique ID provider will be deleted.
*
* @param {string} sessionId
* @throws {Error}
* @return {Promise}
*/
deleteSession(sessionId: string): Promise<object>;
/**
* Create Email Verification
*
* Use this endpoint to send a verification message to your user email address
* to confirm they are the valid owners of that address. Both the **userId**
* and **secret** arguments will be passed as query parameters to the URL you
* have provider to be attached to the verification email. The provided URL
* should redirect the user back for your app and allow you to complete the
* verification process by verifying both the **userId** and **secret**
* parameters. Learn more about how to [complete the verification
* process](/docs/account#updateAccountVerification).
*
* Please note that in order to avoid a [Redirect
* Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
* the only valid redirect URLs are the ones from domains you have set when
* adding your platforms in the console interface.
*
* @param {string} url
* @throws {Error}
* @return {Promise}
*/
createVerification(url: string): Promise<object>;
/**
* Complete Email Verification
*
* Use this endpoint to complete the user email verification process. Use both
* the **userId** and **secret** parameters that were attached to your app URL
* to verify the user email ownership. If confirmed this route will return a
* 200 status code.
*
* @param {string} userId
* @param {string} secret
* @throws {Error}
* @return {Promise}
*/
updateVerification(userId: string, secret: string): Promise<object>;
}
export interface Avatars {
/**
* Get Browser Icon
*
* You can use this endpoint to show different browser icons to your users.
* The code argument receives the browser code as it appears in your user
* /account/sessions endpoint. Use width, height and quality arguments to
* change the output settings.
*
* @param {string} code
* @param {number} width
* @param {number} height
* @param {number} quality
* @throws {Error}
* @return {Promise}
*/
getBrowser(code: string, width: number, height: number, quality: number): Promise<object>;
/**
* Get Credit Card Icon
*
* Need to display your users with your billing method or their payment
* methods? The credit card endpoint will return you the icon of the credit
* card provider you need. Use width, height and quality arguments to change
* the output settings.
*
* @param {string} code
* @param {number} width
* @param {number} height
* @param {number} quality
* @throws {Error}
* @return {string}
*/
getCreditCard(code: string, width: number, height: number, quality: number): string;
/**
* Get Favicon
*
* Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote
* website URL.
*
* @param {string} url
* @throws {Error}
* @return {string}
*/
getFavicon(url: string): string;
/**
* Get Country Flag
*
* You can use this endpoint to show different country flags icons to your
* users. The code argument receives the 2 letter country code. Use width,
* height and quality arguments to change the output settings.
*
* @param {string} code
* @param {number} width
* @param {number} height
* @param {number} quality
* @throws {Error}
* @return {string}
*/
getFlag(code: string, width: number, height: number, quality: number): string;
/**
* Get Image from URL
*
* Use this endpoint to fetch a remote image URL and crop it to any image size
* you want. This endpoint is very useful if you need to crop and display
* remote images in your app or in case you want to make sure a 3rd party
* image is properly served using a TLS protocol.
*
* @param {string} url
* @param {number} width
* @param {number} height
* @throws {Error}
* @return {string}
*/
getImage(url: string, width: number, height: number): string;
/**
* Get QR Code
*
* Converts a given plain text to a QR code image. You can use the query
* parameters to change the size and style of the resulting image.
*
* @param {string} text
* @param {number} size
* @param {number} margin
* @param {number} download
* @throws {Error}
* @return {string}
*/
getQR(text: string, size: number, margin: number, download: number): string;
}
export interface Database {
/**
* List Documents
*
* Get a list of all the user documents. You can use the query params to
* filter your results. On admin mode, this endpoint will return a list of all
* of the project documents. [Learn more about different API
* modes](/docs/admin).
*
* @param {string} collectionId
* @param {string[]} filters
* @param {number} offset
* @param {number} limit
* @param {string} orderField
* @param {string} orderType
* @param {string} orderCast
* @param {string} search
* @param {number} first
* @param {number} last
* @throws {Error}
* @return {Promise}
*/
listDocuments(collectionId: string, filters: string[], offset: number, limit: number, orderField: string, orderType: string, orderCast: string, search: string, first: number, last: number): Promise<object>;
/**
* Create Document
*
* Create a new Document.
*
* @param {string} collectionId
* @param {object} data
* @param {string[]} read
* @param {string[]} write
* @param {string} parentDocument
* @param {string} parentProperty
* @param {string} parentPropertyType
* @throws {Error}
* @return {Promise}
*/
createDocument(collectionId: string, data: object, read: string[], write: string[], parentDocument: string, parentProperty: string, parentPropertyType: string): Promise<object>;
/**
* Get Document
*
* Get document by its unique ID. This endpoint response returns a JSON object
* with the document data.
*
* @param {string} collectionId
* @param {string} documentId
* @throws {Error}
* @return {Promise}
*/
getDocument(collectionId: string, documentId: string): Promise<object>;
/**
* Update Document
*
*
* @param {string} collectionId
* @param {string} documentId
* @param {object} data
* @param {string[]} read
* @param {string[]} write
* @throws {Error}
* @return {Promise}
*/
updateDocument(collectionId: string, documentId: string, data: object, read: string[], write: string[]): Promise<object>;
/**
* Delete Document
*
* Delete document by its unique ID. This endpoint deletes only the parent
* documents, his attributes and relations to other documents. Child documents
* **will not** be deleted.
*
* @param {string} collectionId
* @param {string} documentId
* @throws {Error}
* @return {Promise}
*/
deleteDocument(collectionId: string, documentId: string): Promise<object>;
}
export interface Locale {
/**
* Get User Locale
*
* Get the current user location based on IP. Returns an object with user
* country code, country name, continent name, continent code, ip address and
* suggested currency. You can use the locale header to get the data in a
* supported language.
*
* ([IP Geolocation by DB-IP](https://db-ip.com))
*
* @throws {Error}
* @return {Promise}
*/
get(): Promise<object>;
/**
* List Continents
*
* List of all continents. You can use the locale header to get the data in a
* supported language.
*
* @throws {Error}
* @return {Promise}
*/
getContinents(): Promise<object>;
/**
* List Countries
*
* List of all countries. You can use the locale header to get the data in a
* supported language.
*
* @throws {Error}
* @return {Promise}
*/
getCountries(): Promise<object>;
/**
* List EU Countries
*
* List of all countries that are currently members of the EU. You can use the
* locale header to get the data in a supported language.
*
* @throws {Error}
* @return {Promise}
*/
getCountriesEU(): Promise<object>;
/**
* List Countries Phone Codes
*
* List of all countries phone codes. You can use the locale header to get the
* data in a supported language.
*
* @throws {Error}
* @return {Promise}
*/
getCountriesPhones(): Promise<object>;
/**
* List Currencies
*
* List of all currencies, including currency symol, name, plural, and decimal
* digits for all major and minor currencies. You can use the locale header to
* get the data in a supported language.
*
* @throws {Error}
* @return {Promise}
*/
getCurrencies(): Promise<object>;
}
export interface Storage {
/**
* List Files
*
* Get a list of all the user files. You can use the query params to filter
* your results. On admin mode, this endpoint will return a list of all of the
* project files. [Learn more about different API modes](/docs/admin).
*
* @param {string} search
* @param {number} limit
* @param {number} offset
* @param {string} orderType
* @throws {Error}
* @return {Promise}
*/
listFiles(search: string, limit: number, offset: number, orderType: string): Promise<object>;
/**
* Create File
*
* Create a new file. The user who creates the file will automatically be
* assigned to read and write access unless he has passed custom values for
* read and write arguments.
*
* @param {File} file
* @param {string[]} read
* @param {string[]} write
* @throws {Error}
* @return {Promise}
*/
createFile(file: File, read: string[], write: string[]): Promise<object>;
/**
* Get File
*
* Get file by its unique ID. This endpoint response returns a JSON object
* with the file metadata.
*
* @param {string} fileId
* @throws {Error}
* @return {Promise}
*/
getFile(fileId: string): Promise<object>;
/**
* Update File
*
* Update file by its unique ID. Only users with write permissions have access
* to update this resource.
*
* @param {string} fileId
* @param {string[]} read
* @param {string[]} write
* @throws {Error}
* @return {Promise}
*/
updateFile(fileId: string, read: string[], write: string[]): Promise<object>;
/**
* Delete File
*
* Delete a file by its unique ID. Only users with write permissions have
* access to delete this resource.
*
* @param {string} fileId
* @throws {Error}
* @return {Promise}
*/
deleteFile(fileId: string): Promise<object>;
/**
* Get File for Download
*
* Get file content by its unique ID. The endpoint response return with a
* 'Content-Disposition: attachment' header that tells the browser to start
* downloading the file to user downloads directory.
*
* @param {string} fileId
* @throws {Error}
* @return {string}
*/
getFileDownload(fileId: string): string;
/**
* Get File Preview
*
* Get a file preview image. Currently, this method supports preview for image
* files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
* and spreadsheets, will return the file icon image. You can also pass query
* string arguments for cutting and resizing your preview image.
*
* @param {string} fileId
* @param {number} width
* @param {number} height
* @param {number} quality
* @param {string} background
* @param {string} output
* @throws {Error}
* @return {string}
*/
getFilePreview(fileId: string, width: number, height: number, quality: number, background: string, output: string): string;
/**
* Get File for View
*
* Get file content by its unique ID. This endpoint is similar to the download
* method but returns with no 'Content-Disposition: attachment' header.
*
* @param {string} fileId
* @param {string} as
* @throws {Error}
* @return {string}
*/
getFileView(fileId: string, as: string): string;
}
export interface Teams {
/**
* List Teams
*
* Get a list of all the current user teams. You can use the query params to
* filter your results. On admin mode, this endpoint will return a list of all
* of the project teams. [Learn more about different API modes](/docs/admin).
*
* @param {string} search
* @param {number} limit
* @param {number} offset
* @param {string} orderType
* @throws {Error}
* @return {Promise}
*/
list(search: string, limit: number, offset: number, orderType: string): Promise<object>;
/**
* Create Team
*
* Create a new team. The user who creates the team will automatically be
* assigned as the owner of the team. The team owner can invite new members,
* who will be able add new owners and update or delete the team from your
* project.
*
* @param {string} name
* @param {string[]} roles
* @throws {Error}
* @return {Promise}
*/
create(name: string, roles: string[]): Promise<object>;
/**
* Get Team
*
* Get team by its unique ID. All team members have read access for this
* resource.
*
* @param {string} teamId
* @throws {Error}
* @return {Promise}
*/
get(teamId: string): Promise<object>;
/**
* Update Team
*
* Update team by its unique ID. Only team owners have write access for this
* resource.
*
* @param {string} teamId
* @param {string} name
* @throws {Error}
* @return {Promise}
*/
update(teamId: string, name: string): Promise<object>;
/**
* Delete Team
*
* Delete team by its unique ID. Only team owners have write access for this
* resource.
*
* @param {string} teamId
* @throws {Error}
* @return {Promise}
*/
delete(teamId: string): Promise<object>;
/**
* Get Team Memberships
*
* Get team members by the team unique ID. All team members have read access
* for this list of resources.
*
* @param {string} teamId
* @throws {Error}
* @return {Promise}
*/
getMemberships(teamId: string): Promise<object>;
/**
* Create Team Membership
*
* Use this endpoint to invite a new member to join your team. An email with a
* link to join the team will be sent to the new member email address if the
* member doesn't exist in the project it will be created automatically.
*
* Use the 'URL' parameter to redirect the user from the invitation email back
* to your app. When the user is redirected, use the [Update Team Membership
* Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to
* accept the invitation to the team.
*
* Please note that in order to avoid a [Redirect
* Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
* the only valid redirect URL's are the once from domains you have set when
* added your platforms in the console interface.
*
* @param {string} teamId
* @param {string} email
* @param {string[]} roles
* @param {string} url
* @param {string} name
* @throws {Error}
* @return {Promise}
*/
createMembership(teamId: string, email: string, roles: string[], url: string, name: string): Promise<object>;
/**
* Delete Team Membership
*
* This endpoint allows a user to leave a team or for a team owner to delete
* the membership of any other team member. You can also use this endpoint to
* delete a user membership even if he didn't accept it.
*
* @param {string} teamId
* @param {string} inviteId
* @throws {Error}
* @return {Promise}
*/
deleteMembership(teamId: string, inviteId: string): Promise<object>;
/**
* Update Team Membership Status
*
* Use this endpoint to allow a user to accept an invitation to join a team
* after he is being redirected back to your app from the invitation email he
* was sent.
*
* @param {string} teamId
* @param {string} inviteId
* @param {string} userId
* @param {string} secret
* @throws {Error}
* @return {Promise}
*/
updateMembershipStatus(teamId: string, inviteId: string, userId: string, secret: string): Promise<object>;
}
}