-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathappwrite.ts
4681 lines (4679 loc) · 170 KB
/
appwrite.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
const icon =
"https://raw.githubusercontent.com/appwrite/appwrite/master/public/images/icon.svg";
const completionSpec: Fig.Spec = {
name: "index",
description: "Appwrite - Open-Source End-to-End Backend Server",
subcommands: [
{
name: "login",
description:
"The login command allows you to authenticate and manage a user account",
icon,
},
{
name: "init",
description:
"The init command helps you initialize your Appwrite project, functions and collections",
icon,
subcommands: [
{
name: "project",
description: "Initialise your Appwrite project",
icon,
},
{
name: "function",
description: "Initialise your Appwrite cloud function",
icon,
},
{
name: "collection",
description: "Initialise your Appwrite collections",
icon,
options: [
{
name: "--databaseId",
description: "Database ID",
args: { name: "databaseId" },
},
{
name: "--all",
description: "Flag to initialize all databases",
},
],
},
],
},
{
name: "deploy",
description:
"The deploy command provides a convenient wrapper for deploying your functions and collections",
subcommands: [
{
name: "function",
description: "Deploy functions in the current directory",
icon,
options: [
{
name: "--functionId",
description: "Function ID",
args: { name: "functionId" },
},
{ name: "--all", description: "Flag to deploy all functions" },
],
},
{
name: "collection",
description: "Deploy collections in the current project",
icon,
options: [
{ name: "--all", description: "Flag to deploy all functions" },
],
},
],
icon,
},
{
name: "logout",
description:
"The logout command allows you to logout of your Appwrite account",
icon,
},
{
name: "account",
description:
"The account command allows you to authenticate and manage a user account",
subcommands: [
{
name: "get",
description: "Get currently logged in user data as JSON object",
icon,
},
{
name: "create",
description:
"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/client/account#accountCreateVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](/docs/client/account#accountCreateSession)",
icon,
options: [
{
name: "--userId",
description:
'Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars',
isRequired: true,
args: { name: "userId" },
},
{
name: "--email",
description: "User email",
isRequired: true,
args: { name: "email" },
},
{
name: "--password",
description: "User password. Must be at least 8 chars",
isRequired: true,
args: { name: "password" },
},
{
name: "--name",
description: "User name. Max length: 128 chars",
args: { name: "name" },
},
],
},
{
name: "updateEmail",
description:
"Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password",
icon,
options: [
{
name: "--email",
description: "User email",
isRequired: true,
args: { name: "email" },
},
{
name: "--password",
description: "User password. Must be at least 8 chars",
isRequired: true,
args: { name: "password" },
},
],
},
{
name: "createJWT",
description:
"Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame",
icon,
},
{
name: "getLogs",
description:
"Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log",
icon,
options: [
{
name: "--limit",
description:
"Maximum number of logs to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request",
args: { name: "limit" },
},
{
name: "--offset",
description:
"Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)",
args: { name: "offset" },
},
],
},
{
name: "updateName",
description: "Update currently logged in user account name",
icon,
options: [
{
name: "--name",
description: "User name. Max length: 128 chars",
isRequired: true,
args: { name: "name" },
},
],
},
{
name: "updatePassword",
description:
"Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional",
icon,
options: [
{
name: "--password",
description: "New user password. Must be at least 8 chars",
isRequired: true,
args: { name: "password" },
},
{
name: "--oldPassword",
description: "Current user password. Must be at least 8 chars",
args: { name: "oldPassword" },
},
],
},
{
name: "updatePhone",
description:
"Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](/docs/client/account#accountCreatePhoneVerification) endpoint to send a confirmation SMS",
icon,
options: [
{
name: "--number",
description:
"Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212",
isRequired: true,
args: { name: "number" },
},
{
name: "--password",
description: "User password. Must be at least 8 chars",
isRequired: true,
args: { name: "password" },
},
],
},
{
name: "getPrefs",
description:
"Get currently logged in user preferences as a key-value object",
icon,
},
{
name: "updatePrefs",
description:
"Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded",
icon,
options: [
{
name: "--prefs",
description: "Prefs key-value JSON object",
isRequired: true,
args: { name: "prefs" },
},
],
},
{
name: "createRecovery",
description:
"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/client/account#accountUpdateRecovery) endpoint to complete the process. The verification link sent to the user's email address is valid for 1 hour",
icon,
options: [
{
name: "--email",
description: "User email",
isRequired: true,
args: { name: "email" },
},
{
name: "--url",
description:
"URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API",
isRequired: true,
args: { name: "url" },
},
],
},
{
name: "updateRecovery",
description:
"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/client/account#accountCreateRecovery) 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",
icon,
options: [
{
name: "--userId",
description: "User ID",
isRequired: true,
args: { name: "userId" },
},
{
name: "--secret",
description: "Valid reset token",
isRequired: true,
args: { name: "secret" },
},
{
name: "--password",
description: "New user password. Must be at least 8 chars",
isRequired: true,
args: { name: "password" },
},
{
name: "--passwordAgain",
description: "Repeat new user password. Must be at least 8 chars",
isRequired: true,
args: { name: "passwordAgain" },
},
],
},
{
name: "getSessions",
description:
"Get currently logged in user list of active sessions across different devices",
icon,
},
{
name: "deleteSessions",
description:
"Delete all sessions from the user account and remove any sessions cookies from the end client",
icon,
},
{
name: "createAnonymousSession",
description:
"Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](/docs/client/account#accountUpdateEmail) or create an [OAuth2 session](/docs/client/account#accountCreateOAuth2Session)",
icon,
},
{
name: "createEmailSession",
description:
"Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user",
icon,
options: [
{
name: "--email",
description: "User email",
isRequired: true,
args: { name: "email" },
},
{
name: "--password",
description: "User password. Must be at least 8 chars",
isRequired: true,
args: { name: "password" },
},
],
},
{
name: "createMagicURLSession",
description:
"Sends the user an email with a secret key for creating a session. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [PUT /account/sessions/magic-url](/docs/client/account#accountUpdateMagicURLSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default",
icon,
options: [
{
name: "--userId",
description:
'Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars',
isRequired: true,
args: { name: "userId" },
},
{
name: "--email",
description: "User email",
isRequired: true,
args: { name: "email" },
},
{
name: "--url",
description:
"URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API",
args: { name: "url" },
},
],
},
{
name: "updateMagicURLSession",
description:
"Use this endpoint to complete creating the session with the Magic URL. 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/sessions/magic-url](/docs/client/account#accountCreateMagicURLSession) 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",
icon,
options: [
{
name: "--userId",
description: "User ID",
isRequired: true,
args: { name: "userId" },
},
{
name: "--secret",
description: "Valid verification token",
isRequired: true,
args: { name: "secret" },
},
],
},
{
name: "createOAuth2Session",
description:
"Allow the user to login to their account using the OAuth2 provider of their 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. If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user",
icon,
options: [
{
name: "--provider",
description:
"OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, autodesk, bitbucket, bitly, box, dailymotion, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoom",
isRequired: true,
args: { name: "provider" },
},
{
name: "--success",
description:
"URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API",
args: { name: "success" },
},
{
name: "--failure",
description:
"URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API",
args: { name: "failure" },
},
{
name: "--scopes",
description:
"A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long",
args: { name: "scopes", isVariadic: true },
},
],
},
{
name: "createPhoneSession",
description:
"Sends the user an SMS with a secret key for creating a session. Use the returned user ID and secret and submit a request to the [PUT /account/sessions/phone](/docs/client/account#accountUpdatePhoneSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes",
icon,
options: [
{
name: "--userId",
description:
'Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars',
isRequired: true,
args: { name: "userId" },
},
{
name: "--number",
description:
"Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212",
isRequired: true,
args: { name: "number" },
},
],
},
{
name: "updatePhoneSession",
description:
"Use this endpoint to complete creating a session with SMS. Use the **userId** from the [createPhoneSession](/docs/client/account#accountCreatePhoneSession) endpoint and the **secret** received via SMS to successfully update and confirm the phone session",
icon,
options: [
{
name: "--userId",
description: "User ID",
isRequired: true,
args: { name: "userId" },
},
{
name: "--secret",
description: "Valid verification token",
isRequired: true,
args: { name: "secret" },
},
],
},
{
name: "getSession",
description:
"Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used",
icon,
options: [
{
name: "--sessionId",
description:
"Session ID. Use the string 'current' to get the current device session",
isRequired: true,
args: { name: "sessionId" },
},
],
},
{
name: "updateSession",
description:
'Access tokens have limited lifespan and expire to mitigate security risks. If session was created using an OAuth provider, this route can be used to "refresh" the access token',
icon,
options: [
{
name: "--sessionId",
description:
"Session ID. Use the string 'current' to update the current device session",
isRequired: true,
args: { name: "sessionId" },
},
],
},
{
name: "deleteSession",
description:
"Use this endpoint to log out the currently logged in user from all their account sessions across all of their different devices. When using the Session ID argument, only the unique session ID provided is deleted",
icon,
options: [
{
name: "--sessionId",
description:
"Session ID. Use the string 'current' to delete the current device session",
isRequired: true,
args: { name: "sessionId" },
},
],
},
{
name: "updateStatus",
description:
"Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead",
icon,
},
{
name: "createVerification",
description:
"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 provided to be attached to the verification email. The provided URL should redirect the user back to 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/client/account#accountUpdateEmailVerification). The verification link sent to the user's email address is valid for 7 days. 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",
icon,
options: [
{
name: "--url",
description:
"URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API",
isRequired: true,
args: { name: "url" },
},
],
},
{
name: "updateVerification",
description:
"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",
icon,
options: [
{
name: "--userId",
description: "User ID",
isRequired: true,
args: { name: "userId" },
},
{
name: "--secret",
description: "Valid verification token",
isRequired: true,
args: { name: "secret" },
},
],
},
{
name: "createPhoneVerification",
description:
"Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](/docs/client/account#accountUpdatePhone) endpoint. Learn more about how to [complete the verification process](/docs/client/account#accountUpdatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes",
icon,
},
{
name: "updatePhoneVerification",
description:
"Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code",
icon,
options: [
{
name: "--secret",
description: "Valid verification token",
isRequired: true,
args: { name: "secret" },
},
],
},
],
icon,
},
{
name: "avatars",
description:
"The avatars command aims to help you complete everyday tasks related to your app image, icons, and avatars",
subcommands: [
{
name: "getBrowser",
description:
"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 [GET /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use width, height and quality arguments to change the output settings. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px",
icon,
options: [
{
name: "--code",
description: "Browser Code",
isRequired: true,
args: { name: "code" },
},
{
name: "--width",
description:
"Image width. Pass an integer between 0 to 2000. Defaults to 100",
args: { name: "width" },
},
{
name: "--height",
description:
"Image height. Pass an integer between 0 to 2000. Defaults to 100",
args: { name: "height" },
},
{
name: "--quality",
description:
"Image quality. Pass an integer between 0 to 100. Defaults to 100",
args: { name: "quality" },
},
{
name: "--destination",
description: "Output file path",
isRequired: true,
args: { name: "path" },
},
],
},
{
name: "getCreditCard",
description:
"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. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px",
icon,
options: [
{
name: "--code",
description:
"Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro",
isRequired: true,
args: { name: "code" },
},
{
name: "--width",
description:
"Image width. Pass an integer between 0 to 2000. Defaults to 100",
args: { name: "width" },
},
{
name: "--height",
description:
"Image height. Pass an integer between 0 to 2000. Defaults to 100",
args: { name: "height" },
},
{
name: "--quality",
description:
"Image quality. Pass an integer between 0 to 100. Defaults to 100",
args: { name: "quality" },
},
{
name: "--destination",
description: "Output file path",
isRequired: true,
args: { name: "path" },
},
],
},
{
name: "getFavicon",
description:
"Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL",
icon,
options: [
{
name: "--url",
description:
"Website URL which you want to fetch the favicon from",
isRequired: true,
args: { name: "url" },
},
{
name: "--destination",
description: "Output file path",
isRequired: true,
args: { name: "path" },
},
],
},
{
name: "getFlag",
description:
"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. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px",
icon,
options: [
{
name: "--code",
description: "Country Code. ISO Alpha-2 country code format",
isRequired: true,
args: { name: "code" },
},
{
name: "--width",
description:
"Image width. Pass an integer between 0 to 2000. Defaults to 100",
args: { name: "width" },
},
{
name: "--height",
description:
"Image height. Pass an integer between 0 to 2000. Defaults to 100",
args: { name: "height" },
},
{
name: "--quality",
description:
"Image quality. Pass an integer between 0 to 100. Defaults to 100",
args: { name: "quality" },
},
{
name: "--destination",
description: "Output file path",
isRequired: true,
args: { name: "path" },
},
],
},
{
name: "getImage",
description:
"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. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 400x400px",
icon,
options: [
{
name: "--url",
description: "Image URL which you want to crop",
isRequired: true,
args: { name: "url" },
},
{
name: "--width",
description:
"Resize preview image width, Pass an integer between 0 to 2000. Defaults to 400",
args: { name: "width" },
},
{
name: "--height",
description:
"Resize preview image height, Pass an integer between 0 to 2000. Defaults to 400",
args: { name: "height" },
},
{
name: "--destination",
description: "Output file path",
isRequired: true,
args: { name: "path" },
},
],
},
{
name: "getInitials",
description:
"Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px",
icon,
options: [
{
name: "--name",
description:
"Full Name. When empty, current user name or email will be used. Max length: 128 chars",
args: { name: "name" },
},
{
name: "--width",
description:
"Image width. Pass an integer between 0 to 2000. Defaults to 100",
args: { name: "width" },
},
{
name: "--height",
description:
"Image height. Pass an integer between 0 to 2000. Defaults to 100",
args: { name: "height" },
},
{
name: "--color",
description:
"Changes text color. By default a random color will be picked and stay will persistent to the given name",
args: { name: "color" },
},
{
name: "--background",
description:
"Changes background color. By default a random color will be picked and stay will persistent to the given name",
args: { name: "background" },
},
{
name: "--destination",
description: "Output file path",
isRequired: true,
args: { name: "path" },
},
],
},
{
name: "getQR",
description:
"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",
icon,
options: [
{
name: "--text",
description: "Plain text to be converted to QR code image",
isRequired: true,
args: { name: "text" },
},
{
name: "--size",
description:
"QR code size. Pass an integer between 1 to 1000. Defaults to 400",
args: { name: "size" },
},
{
name: "--margin",
description:
"Margin from edge. Pass an integer between 0 to 10. Defaults to 1",
args: { name: "margin" },
},
{
name: "--download",
description:
"Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0",
args: { name: "download" },
},
{
name: "--destination",
description: "Output file path",
isRequired: true,
args: { name: "path" },
},
],
},
],
icon,
},
{
name: "databases",
description:
"The databases command allows you to create structured collections of documents, query and filter lists of documents",
subcommands: [
{
name: "list",
icon,
options: [
{
name: "--search",
description:
"Search term to filter your list results. Max length: 256 chars",
args: { name: "search" },
},
{
name: "--limit",
description:
"Maximum number of collection to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request",
args: { name: "limit" },
},
{
name: "--offset",
description:
"Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)",
args: { name: "offset" },
},
{
name: "--cursor",
description:
"ID of the collection used as the starting point for the query, excluding the collection itself. Should be used for efficient pagination when working with large sets of data",
args: { name: "cursor" },
},
{
name: "--cursorDirection",
description:
"Direction of the cursor, can be either 'before' or 'after'",
args: { name: "cursorDirection" },
},
{
name: "--orderType",
description: "Order result by ASC or DESC order",
args: { name: "orderType" },
},
],
},
{
name: "create",
icon,
options: [
{
name: "--databaseId",
description:
'Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars',
isRequired: true,
args: { name: "databaseId" },
},
{
name: "--name",
description: "Collection name. Max length: 128 chars",
isRequired: true,
args: { name: "name" },
},
],
},
{
name: "getUsage",
icon,
options: [
{
name: "--range",
description: "'Date range",
args: { name: "range" },
},
],
},
{
name: "get",
icon,
options: [
{
name: "--databaseId",
description: "Database ID",
isRequired: true,
args: { name: "databaseId" },
},
],
},
{
name: "update",
icon,
options: [
{
name: "--databaseId",
description: "Database ID",
isRequired: true,
args: { name: "databaseId" },
},
{
name: "--name",
description: "Collection name. Max length: 128 chars",
isRequired: true,
args: { name: "name" },
},
],
},
{
name: "delete",
icon,
options: [
{
name: "--databaseId",
description: "Database ID",
isRequired: true,
args: { name: "databaseId" },
},
],
},
{
name: "listCollections",
icon,
options: [
{
name: "--databaseId",
description: "Database ID",
isRequired: true,
args: { name: "databaseId" },
},
{
name: "--search",
description:
"Search term to filter your list results. Max length: 256 chars",
args: { name: "search" },
},
{
name: "--limit",
description:
"Maximum number of collection to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request",
args: { name: "limit" },
},
{
name: "--offset",
description:
"Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)",
args: { name: "offset" },
},
{
name: "--cursor",
description:
"ID of the collection used as the starting point for the query, excluding the collection itself. Should be used for efficient pagination when working with large sets of data",
args: { name: "cursor" },
},
{
name: "--cursorDirection",
description:
"Direction of the cursor, can be either 'before' or 'after'",
args: { name: "cursorDirection" },
},
{
name: "--orderType",
description: "Order result by ASC or DESC order",
args: { name: "orderType" },
},
],
},
{
name: "createCollection",
icon,
options: [
{
name: "--databaseId",
description: "Database ID",
isRequired: true,
args: { name: "databaseId" },
},
{
name: "--collectionId",
description: