appwrite-cli 1.2.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +4 -4
  2. package/docs/examples/account/create.md +1 -1
  3. package/docs/examples/account/update-password.md +1 -1
  4. package/docs/examples/console/variables.md +1 -0
  5. package/docs/examples/databases/create-relationship-attribute.md +9 -0
  6. package/docs/examples/databases/get-document.md +2 -1
  7. package/docs/examples/databases/update-boolean-attribute.md +6 -0
  8. package/docs/examples/databases/update-datetime-attribute.md +6 -0
  9. package/docs/examples/databases/update-email-attribute.md +6 -0
  10. package/docs/examples/databases/update-enum-attribute.md +7 -0
  11. package/docs/examples/databases/update-float-attribute.md +8 -0
  12. package/docs/examples/databases/update-integer-attribute.md +8 -0
  13. package/docs/examples/databases/update-ip-attribute.md +6 -0
  14. package/docs/examples/databases/update-relationship-attribute.md +5 -0
  15. package/docs/examples/databases/update-string-attribute.md +6 -0
  16. package/docs/examples/databases/update-url-attribute.md +6 -0
  17. package/docs/examples/functions/create.md +1 -1
  18. package/docs/examples/functions/update.md +1 -1
  19. package/docs/examples/projects/update-auth-password-dictionary.md +3 -0
  20. package/docs/examples/projects/update-auth-password-history.md +3 -0
  21. package/docs/examples/teams/create-membership.md +3 -1
  22. package/docs/examples/teams/get-prefs.md +2 -0
  23. package/docs/examples/teams/{update.md → update-name.md} +1 -1
  24. package/docs/examples/teams/update-prefs.md +3 -0
  25. package/docs/examples/users/update-password.md +1 -1
  26. package/index.js +2 -0
  27. package/install.ps1 +2 -2
  28. package/install.sh +1 -1
  29. package/lib/client.js +7 -7
  30. package/lib/commands/account.js +40 -7
  31. package/lib/commands/console.js +44 -0
  32. package/lib/commands/databases.js +727 -103
  33. package/lib/commands/deploy.js +270 -146
  34. package/lib/commands/functions.js +35 -9
  35. package/lib/commands/generic.js +6 -3
  36. package/lib/commands/init.js +215 -179
  37. package/lib/commands/projects.js +139 -5
  38. package/lib/commands/storage.js +37 -9
  39. package/lib/commands/teams.js +102 -16
  40. package/lib/commands/users.js +51 -2
  41. package/lib/config.js +84 -6
  42. package/lib/parser.js +6 -2
  43. package/lib/questions.js +307 -280
  44. package/package.json +1 -1
  45. package/docs/examples/account/get-logs.md +0 -2
  46. package/docs/examples/account/get-sessions.md +0 -1
  47. package/docs/examples/functions/retry-build.md +0 -4
  48. package/docs/examples/locale/get-continents.md +0 -1
  49. package/docs/examples/locale/get-countries-e-u.md +0 -1
  50. package/docs/examples/locale/get-countries-phones.md +0 -1
  51. package/docs/examples/locale/get-countries.md +0 -1
  52. package/docs/examples/locale/get-currencies.md +0 -1
  53. package/docs/examples/locale/get-languages.md +0 -1
  54. package/docs/examples/teams/get-memberships.md +0 -4
  55. package/docs/examples/users/get-logs.md +0 -3
  56. package/docs/examples/users/get-memberships.md +0 -2
  57. package/docs/examples/users/get-sessions.md +0 -2
@@ -61,54 +61,67 @@ const projectsCreate = async ({ projectId, name, teamId, region, description, lo
61
61
  let payload = {};
62
62
 
63
63
  /** Body Params */
64
+
64
65
  if (typeof projectId !== 'undefined') {
65
66
  payload['projectId'] = projectId;
66
67
  }
67
68
 
69
+
68
70
  if (typeof name !== 'undefined') {
69
71
  payload['name'] = name;
70
72
  }
71
73
 
74
+
72
75
  if (typeof teamId !== 'undefined') {
73
76
  payload['teamId'] = teamId;
74
77
  }
75
78
 
79
+
76
80
  if (typeof region !== 'undefined') {
77
81
  payload['region'] = region;
78
82
  }
79
83
 
84
+
80
85
  if (typeof description !== 'undefined') {
81
86
  payload['description'] = description;
82
87
  }
83
88
 
89
+
84
90
  if (typeof logo !== 'undefined') {
85
91
  payload['logo'] = logo;
86
92
  }
87
93
 
94
+
88
95
  if (typeof url !== 'undefined') {
89
96
  payload['url'] = url;
90
97
  }
91
98
 
99
+
92
100
  if (typeof legalName !== 'undefined') {
93
101
  payload['legalName'] = legalName;
94
102
  }
95
103
 
104
+
96
105
  if (typeof legalCountry !== 'undefined') {
97
106
  payload['legalCountry'] = legalCountry;
98
107
  }
99
108
 
109
+
100
110
  if (typeof legalState !== 'undefined') {
101
111
  payload['legalState'] = legalState;
102
112
  }
103
113
 
114
+
104
115
  if (typeof legalCity !== 'undefined') {
105
116
  payload['legalCity'] = legalCity;
106
117
  }
107
118
 
119
+
108
120
  if (typeof legalAddress !== 'undefined') {
109
121
  payload['legalAddress'] = legalAddress;
110
122
  }
111
123
 
124
+
112
125
  if (typeof legalTaxId !== 'undefined') {
113
126
  payload['legalTaxId'] = legalTaxId;
114
127
  }
@@ -161,42 +174,52 @@ const projectsUpdate = async ({ projectId, name, description, logo, url, legalNa
161
174
  let payload = {};
162
175
 
163
176
  /** Body Params */
177
+
164
178
  if (typeof name !== 'undefined') {
165
179
  payload['name'] = name;
166
180
  }
167
181
 
182
+
168
183
  if (typeof description !== 'undefined') {
169
184
  payload['description'] = description;
170
185
  }
171
186
 
187
+
172
188
  if (typeof logo !== 'undefined') {
173
189
  payload['logo'] = logo;
174
190
  }
175
191
 
192
+
176
193
  if (typeof url !== 'undefined') {
177
194
  payload['url'] = url;
178
195
  }
179
196
 
197
+
180
198
  if (typeof legalName !== 'undefined') {
181
199
  payload['legalName'] = legalName;
182
200
  }
183
201
 
202
+
184
203
  if (typeof legalCountry !== 'undefined') {
185
204
  payload['legalCountry'] = legalCountry;
186
205
  }
187
206
 
207
+
188
208
  if (typeof legalState !== 'undefined') {
189
209
  payload['legalState'] = legalState;
190
210
  }
191
211
 
212
+
192
213
  if (typeof legalCity !== 'undefined') {
193
214
  payload['legalCity'] = legalCity;
194
215
  }
195
216
 
217
+
196
218
  if (typeof legalAddress !== 'undefined') {
197
219
  payload['legalAddress'] = legalAddress;
198
220
  }
199
221
 
222
+
200
223
  if (typeof legalTaxId !== 'undefined') {
201
224
  payload['legalTaxId'] = legalTaxId;
202
225
  }
@@ -222,6 +245,7 @@ const projectsDelete = async ({ projectId, password, parseOutput = true, sdk = u
222
245
  let payload = {};
223
246
 
224
247
  /** Body Params */
248
+
225
249
  if (typeof password !== 'undefined') {
226
250
  payload['password'] = password;
227
251
  }
@@ -247,6 +271,7 @@ const projectsUpdateAuthDuration = async ({ projectId, duration, parseOutput = t
247
271
  let payload = {};
248
272
 
249
273
  /** Body Params */
274
+
250
275
  if (typeof duration !== 'undefined') {
251
276
  payload['duration'] = duration;
252
277
  }
@@ -272,6 +297,7 @@ const projectsUpdateAuthLimit = async ({ projectId, limit, parseOutput = true, s
272
297
  let payload = {};
273
298
 
274
299
  /** Body Params */
300
+
275
301
  if (typeof limit !== 'undefined') {
276
302
  payload['limit'] = limit;
277
303
  }
@@ -297,6 +323,59 @@ const projectsUpdateAuthSessionsLimit = async ({ projectId, limit, parseOutput =
297
323
  let payload = {};
298
324
 
299
325
  /** Body Params */
326
+
327
+ if (typeof limit !== 'undefined') {
328
+ payload['limit'] = limit;
329
+ }
330
+
331
+ let response = undefined;
332
+ response = await client.call('patch', path, {
333
+ 'content-type': 'application/json',
334
+ }, payload);
335
+
336
+ if (parseOutput) {
337
+ parse(response)
338
+ success()
339
+ }
340
+ return response;
341
+ }
342
+
343
+ const projectsUpdateAuthPasswordDictionary = async ({ projectId, enabled, parseOutput = true, sdk = undefined}) => {
344
+ /* @param {string} projectId */
345
+ /* @param {boolean} enabled */
346
+
347
+ let client = !sdk ? await sdkForConsole() : sdk;
348
+ let path = '/projects/{projectId}/auth/password-dictionary'.replace('{projectId}', projectId);
349
+ let payload = {};
350
+
351
+ /** Body Params */
352
+
353
+ if (typeof enabled !== 'undefined') {
354
+ payload['enabled'] = enabled;
355
+ }
356
+
357
+ let response = undefined;
358
+ response = await client.call('patch', path, {
359
+ 'content-type': 'application/json',
360
+ }, payload);
361
+
362
+ if (parseOutput) {
363
+ parse(response)
364
+ success()
365
+ }
366
+ return response;
367
+ }
368
+
369
+ const projectsUpdateAuthPasswordHistory = async ({ projectId, limit, parseOutput = true, sdk = undefined}) => {
370
+ /* @param {string} projectId */
371
+ /* @param {number} limit */
372
+
373
+ let client = !sdk ? await sdkForConsole() : sdk;
374
+ let path = '/projects/{projectId}/auth/password-history'.replace('{projectId}', projectId);
375
+ let payload = {};
376
+
377
+ /** Body Params */
378
+
300
379
  if (typeof limit !== 'undefined') {
301
380
  payload['limit'] = limit;
302
381
  }
@@ -323,6 +402,7 @@ const projectsUpdateAuthStatus = async ({ projectId, method, status, parseOutput
323
402
  let payload = {};
324
403
 
325
404
  /** Body Params */
405
+
326
406
  if (typeof status !== 'undefined') {
327
407
  payload['status'] = status;
328
408
  }
@@ -366,6 +446,7 @@ const projectsCreateDomain = async ({ projectId, domain, parseOutput = true, sdk
366
446
  let payload = {};
367
447
 
368
448
  /** Body Params */
449
+
369
450
  if (typeof domain !== 'undefined') {
370
451
  payload['domain'] = domain;
371
452
  }
@@ -468,14 +549,18 @@ const projectsCreateKey = async ({ projectId, name, scopes, expire, parseOutput
468
549
  let payload = {};
469
550
 
470
551
  /** Body Params */
552
+
471
553
  if (typeof name !== 'undefined') {
472
554
  payload['name'] = name;
473
555
  }
474
556
 
557
+ scopes = scopes === true ? [] : scopes;
558
+
475
559
  if (typeof scopes !== 'undefined') {
476
560
  payload['scopes'] = scopes;
477
561
  }
478
562
 
563
+
479
564
  if (typeof expire !== 'undefined') {
480
565
  payload['expire'] = expire;
481
566
  }
@@ -523,14 +608,18 @@ const projectsUpdateKey = async ({ projectId, keyId, name, scopes, expire, parse
523
608
  let payload = {};
524
609
 
525
610
  /** Body Params */
611
+
526
612
  if (typeof name !== 'undefined') {
527
613
  payload['name'] = name;
528
614
  }
529
615
 
616
+ scopes = scopes === true ? [] : scopes;
617
+
530
618
  if (typeof scopes !== 'undefined') {
531
619
  payload['scopes'] = scopes;
532
620
  }
533
621
 
622
+
534
623
  if (typeof expire !== 'undefined') {
535
624
  payload['expire'] = expire;
536
625
  }
@@ -578,18 +667,22 @@ const projectsUpdateOAuth2 = async ({ projectId, provider, appId, secret, enable
578
667
  let payload = {};
579
668
 
580
669
  /** Body Params */
670
+
581
671
  if (typeof provider !== 'undefined') {
582
672
  payload['provider'] = provider;
583
673
  }
584
674
 
675
+
585
676
  if (typeof appId !== 'undefined') {
586
677
  payload['appId'] = appId;
587
678
  }
588
679
 
680
+
589
681
  if (typeof secret !== 'undefined') {
590
682
  payload['secret'] = secret;
591
683
  }
592
684
 
685
+
593
686
  if (typeof enabled !== 'undefined') {
594
687
  payload['enabled'] = enabled;
595
688
  }
@@ -637,22 +730,27 @@ const projectsCreatePlatform = async ({ projectId, type, name, key, store, hostn
637
730
  let payload = {};
638
731
 
639
732
  /** Body Params */
733
+
640
734
  if (typeof type !== 'undefined') {
641
735
  payload['type'] = type;
642
736
  }
643
737
 
738
+
644
739
  if (typeof name !== 'undefined') {
645
740
  payload['name'] = name;
646
741
  }
647
742
 
743
+
648
744
  if (typeof key !== 'undefined') {
649
745
  payload['key'] = key;
650
746
  }
651
747
 
748
+
652
749
  if (typeof store !== 'undefined') {
653
750
  payload['store'] = store;
654
751
  }
655
752
 
753
+
656
754
  if (typeof hostname !== 'undefined') {
657
755
  payload['hostname'] = hostname;
658
756
  }
@@ -701,18 +799,22 @@ const projectsUpdatePlatform = async ({ projectId, platformId, name, key, store,
701
799
  let payload = {};
702
800
 
703
801
  /** Body Params */
802
+
704
803
  if (typeof name !== 'undefined') {
705
804
  payload['name'] = name;
706
805
  }
707
806
 
807
+
708
808
  if (typeof key !== 'undefined') {
709
809
  payload['key'] = key;
710
810
  }
711
811
 
812
+
712
813
  if (typeof store !== 'undefined') {
713
814
  payload['store'] = store;
714
815
  }
715
816
 
817
+
716
818
  if (typeof hostname !== 'undefined') {
717
819
  payload['hostname'] = hostname;
718
820
  }
@@ -758,10 +860,12 @@ const projectsUpdateServiceStatus = async ({ projectId, service, status, parseOu
758
860
  let payload = {};
759
861
 
760
862
  /** Body Params */
863
+
761
864
  if (typeof service !== 'undefined') {
762
865
  payload['service'] = service;
763
866
  }
764
867
 
868
+
765
869
  if (typeof status !== 'undefined') {
766
870
  payload['status'] = status;
767
871
  }
@@ -834,26 +938,33 @@ const projectsCreateWebhook = async ({ projectId, name, events, url, security, h
834
938
  let payload = {};
835
939
 
836
940
  /** Body Params */
941
+
837
942
  if (typeof name !== 'undefined') {
838
943
  payload['name'] = name;
839
944
  }
840
945
 
946
+ events = events === true ? [] : events;
947
+
841
948
  if (typeof events !== 'undefined') {
842
949
  payload['events'] = events;
843
950
  }
844
951
 
952
+
845
953
  if (typeof url !== 'undefined') {
846
954
  payload['url'] = url;
847
955
  }
848
956
 
957
+
849
958
  if (typeof security !== 'undefined') {
850
959
  payload['security'] = security;
851
960
  }
852
961
 
962
+
853
963
  if (typeof httpUser !== 'undefined') {
854
964
  payload['httpUser'] = httpUser;
855
965
  }
856
966
 
967
+
857
968
  if (typeof httpPass !== 'undefined') {
858
969
  payload['httpPass'] = httpPass;
859
970
  }
@@ -904,26 +1015,33 @@ const projectsUpdateWebhook = async ({ projectId, webhookId, name, events, url,
904
1015
  let payload = {};
905
1016
 
906
1017
  /** Body Params */
1018
+
907
1019
  if (typeof name !== 'undefined') {
908
1020
  payload['name'] = name;
909
1021
  }
910
1022
 
1023
+ events = events === true ? [] : events;
1024
+
911
1025
  if (typeof events !== 'undefined') {
912
1026
  payload['events'] = events;
913
1027
  }
914
1028
 
1029
+
915
1030
  if (typeof url !== 'undefined') {
916
1031
  payload['url'] = url;
917
1032
  }
918
1033
 
1034
+
919
1035
  if (typeof security !== 'undefined') {
920
1036
  payload['security'] = security;
921
1037
  }
922
1038
 
1039
+
923
1040
  if (typeof httpUser !== 'undefined') {
924
1041
  payload['httpUser'] = httpUser;
925
1042
  }
926
1043
 
1044
+
927
1045
  if (typeof httpPass !== 'undefined') {
928
1046
  payload['httpPass'] = httpPass;
929
1047
  }
@@ -982,7 +1100,7 @@ const projectsUpdateWebhookSignature = async ({ projectId, webhookId, parseOutpu
982
1100
  projects
983
1101
  .command(`list`)
984
1102
  .description(``)
985
- .option(`--queries <queries...>`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId`)
1103
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId`)
986
1104
  .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
987
1105
  .action(actionRunner(projectsList))
988
1106
 
@@ -1054,6 +1172,20 @@ projects
1054
1172
  .requiredOption(`--limit <limit>`, `Set the max number of users allowed in this project. Value allowed is between 1-100. Default is 10`, parseInteger)
1055
1173
  .action(actionRunner(projectsUpdateAuthSessionsLimit))
1056
1174
 
1175
+ projects
1176
+ .command(`updateAuthPasswordDictionary`)
1177
+ .description(``)
1178
+ .requiredOption(`--projectId <projectId>`, `Project unique ID.`)
1179
+ .requiredOption(`--enabled <enabled>`, `Set whether or not to enable checking user's password against most commonly used passwords. Default is false.`, parseBool)
1180
+ .action(actionRunner(projectsUpdateAuthPasswordDictionary))
1181
+
1182
+ projects
1183
+ .command(`updateAuthPasswordHistory`)
1184
+ .description(``)
1185
+ .requiredOption(`--projectId <projectId>`, `Project unique ID.`)
1186
+ .requiredOption(`--limit <limit>`, `Set the max number of passwords to store in user history. User can't choose a new password that is already stored in the password history list. Max number of passwords allowed in history is20. Default value is 0`, parseInteger)
1187
+ .action(actionRunner(projectsUpdateAuthPasswordHistory))
1188
+
1057
1189
  projects
1058
1190
  .command(`updateAuthStatus`)
1059
1191
  .description(``)
@@ -1107,7 +1239,7 @@ projects
1107
1239
  .description(``)
1108
1240
  .requiredOption(`--projectId <projectId>`, `Project unique ID.`)
1109
1241
  .requiredOption(`--name <name>`, `Key name. Max length: 128 chars.`)
1110
- .requiredOption(`--scopes <scopes...>`, `Key scopes list. Maximum of 100 scopes are allowed.`)
1242
+ .requiredOption(`--scopes [scopes...]`, `Key scopes list. Maximum of 100 scopes are allowed.`)
1111
1243
  .option(`--expire <expire>`, `Expiration time in ISO 8601 format. Use null for unlimited expiration.`)
1112
1244
  .action(actionRunner(projectsCreateKey))
1113
1245
 
@@ -1124,7 +1256,7 @@ projects
1124
1256
  .requiredOption(`--projectId <projectId>`, `Project unique ID.`)
1125
1257
  .requiredOption(`--keyId <keyId>`, `Key unique ID.`)
1126
1258
  .requiredOption(`--name <name>`, `Key name. Max length: 128 chars.`)
1127
- .requiredOption(`--scopes <scopes...>`, `Key scopes list. Maximum of 100 events are allowed.`)
1259
+ .requiredOption(`--scopes [scopes...]`, `Key scopes list. Maximum of 100 events are allowed.`)
1128
1260
  .option(`--expire <expire>`, `Expiration time in ISO 8601 format. Use null for unlimited expiration.`)
1129
1261
  .action(actionRunner(projectsUpdateKey))
1130
1262
 
@@ -1213,7 +1345,7 @@ projects
1213
1345
  .description(``)
1214
1346
  .requiredOption(`--projectId <projectId>`, `Project unique ID.`)
1215
1347
  .requiredOption(`--name <name>`, `Webhook name. Max length: 128 chars.`)
1216
- .requiredOption(`--events <events...>`, `Events list. Maximum of 100 events are allowed.`)
1348
+ .requiredOption(`--events [events...]`, `Events list. Maximum of 100 events are allowed.`)
1217
1349
  .requiredOption(`--url <url>`, `Webhook URL.`)
1218
1350
  .requiredOption(`--security <security>`, `Certificate verification, false for disabled or true for enabled.`, parseBool)
1219
1351
  .option(`--httpUser <httpUser>`, `Webhook HTTP user. Max length: 256 chars.`)
@@ -1233,7 +1365,7 @@ projects
1233
1365
  .requiredOption(`--projectId <projectId>`, `Project unique ID.`)
1234
1366
  .requiredOption(`--webhookId <webhookId>`, `Webhook unique ID.`)
1235
1367
  .requiredOption(`--name <name>`, `Webhook name. Max length: 128 chars.`)
1236
- .requiredOption(`--events <events...>`, `Events list. Maximum of 100 events are allowed.`)
1368
+ .requiredOption(`--events [events...]`, `Events list. Maximum of 100 events are allowed.`)
1237
1369
  .requiredOption(`--url <url>`, `Webhook URL.`)
1238
1370
  .requiredOption(`--security <security>`, `Certificate verification, false for disabled or true for enabled.`, parseBool)
1239
1371
  .option(`--httpUser <httpUser>`, `Webhook HTTP user. Max length: 256 chars.`)
@@ -1265,6 +1397,8 @@ module.exports = {
1265
1397
  projectsUpdateAuthDuration,
1266
1398
  projectsUpdateAuthLimit,
1267
1399
  projectsUpdateAuthSessionsLimit,
1400
+ projectsUpdateAuthPasswordDictionary,
1401
+ projectsUpdateAuthPasswordHistory,
1268
1402
  projectsUpdateAuthStatus,
1269
1403
  projectsListDomains,
1270
1404
  projectsCreateDomain,
@@ -58,42 +58,54 @@ const storageCreateBucket = async ({ bucketId, name, permissions, fileSecurity,
58
58
  let payload = {};
59
59
 
60
60
  /** Body Params */
61
+
61
62
  if (typeof bucketId !== 'undefined') {
62
63
  payload['bucketId'] = bucketId;
63
64
  }
64
65
 
66
+
65
67
  if (typeof name !== 'undefined') {
66
68
  payload['name'] = name;
67
69
  }
68
70
 
71
+ permissions = permissions === true ? [] : permissions;
72
+
69
73
  if (typeof permissions !== 'undefined') {
70
74
  payload['permissions'] = permissions;
71
75
  }
72
76
 
77
+
73
78
  if (typeof fileSecurity !== 'undefined') {
74
79
  payload['fileSecurity'] = fileSecurity;
75
80
  }
76
81
 
82
+
77
83
  if (typeof enabled !== 'undefined') {
78
84
  payload['enabled'] = enabled;
79
85
  }
80
86
 
87
+
81
88
  if (typeof maximumFileSize !== 'undefined') {
82
89
  payload['maximumFileSize'] = maximumFileSize;
83
90
  }
84
91
 
92
+ allowedFileExtensions = allowedFileExtensions === true ? [] : allowedFileExtensions;
93
+
85
94
  if (typeof allowedFileExtensions !== 'undefined') {
86
95
  payload['allowedFileExtensions'] = allowedFileExtensions;
87
96
  }
88
97
 
98
+
89
99
  if (typeof compression !== 'undefined') {
90
100
  payload['compression'] = compression;
91
101
  }
92
102
 
103
+
93
104
  if (typeof encryption !== 'undefined') {
94
105
  payload['encryption'] = encryption;
95
106
  }
96
107
 
108
+
97
109
  if (typeof antivirus !== 'undefined') {
98
110
  payload['antivirus'] = antivirus;
99
111
  }
@@ -145,38 +157,49 @@ const storageUpdateBucket = async ({ bucketId, name, permissions, fileSecurity,
145
157
  let payload = {};
146
158
 
147
159
  /** Body Params */
160
+
148
161
  if (typeof name !== 'undefined') {
149
162
  payload['name'] = name;
150
163
  }
151
164
 
165
+ permissions = permissions === true ? [] : permissions;
166
+
152
167
  if (typeof permissions !== 'undefined') {
153
168
  payload['permissions'] = permissions;
154
169
  }
155
170
 
171
+
156
172
  if (typeof fileSecurity !== 'undefined') {
157
173
  payload['fileSecurity'] = fileSecurity;
158
174
  }
159
175
 
176
+
160
177
  if (typeof enabled !== 'undefined') {
161
178
  payload['enabled'] = enabled;
162
179
  }
163
180
 
181
+
164
182
  if (typeof maximumFileSize !== 'undefined') {
165
183
  payload['maximumFileSize'] = maximumFileSize;
166
184
  }
167
185
 
186
+ allowedFileExtensions = allowedFileExtensions === true ? [] : allowedFileExtensions;
187
+
168
188
  if (typeof allowedFileExtensions !== 'undefined') {
169
189
  payload['allowedFileExtensions'] = allowedFileExtensions;
170
190
  }
171
191
 
192
+
172
193
  if (typeof compression !== 'undefined') {
173
194
  payload['compression'] = compression;
174
195
  }
175
196
 
197
+
176
198
  if (typeof encryption !== 'undefined') {
177
199
  payload['encryption'] = encryption;
178
200
  }
179
201
 
202
+
180
203
  if (typeof antivirus !== 'undefined') {
181
204
  payload['antivirus'] = antivirus;
182
205
  }
@@ -250,6 +273,7 @@ const storageCreateFile = async ({ bucketId, fileId, file, permissions, parseOut
250
273
  let payload = {};
251
274
 
252
275
  /** Body Params */
276
+
253
277
  if (typeof fileId !== 'undefined') {
254
278
  payload['fileId'] = fileId;
255
279
  }
@@ -259,6 +283,8 @@ const storageCreateFile = async ({ bucketId, fileId, file, permissions, parseOut
259
283
  payload['file'] = filePath;
260
284
  }
261
285
 
286
+ permissions = permissions === true ? [] : permissions;
287
+
262
288
  if (typeof permissions !== 'undefined') {
263
289
  payload['permissions'] = permissions;
264
290
  }
@@ -361,6 +387,8 @@ const storageUpdateFile = async ({ bucketId, fileId, permissions, parseOutput =
361
387
  let payload = {};
362
388
 
363
389
  /** Body Params */
390
+ permissions = permissions === true ? [] : permissions;
391
+
364
392
  if (typeof permissions !== 'undefined') {
365
393
  payload['permissions'] = permissions;
366
394
  }
@@ -565,7 +593,7 @@ const storageGetBucketUsage = async ({ bucketId, range, parseOutput = true, sdk
565
593
  storage
566
594
  .command(`listBuckets`)
567
595
  .description(`Get a list of all the storage buckets. You can use the query params to filter your results.`)
568
- .option(`--queries <queries...>`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus`)
596
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus`)
569
597
  .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
570
598
  .action(actionRunner(storageListBuckets))
571
599
 
@@ -574,11 +602,11 @@ storage
574
602
  .description(`Create a new storage bucket.`)
575
603
  .requiredOption(`--bucketId <bucketId>`, `Unique Id. Choose a custom ID or generate a random ID with 'ID.unique()'. 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.`)
576
604
  .requiredOption(`--name <name>`, `Bucket name`)
577
- .option(`--permissions <permissions...>`, `An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](/docs/permissions).`)
605
+ .option(`--permissions [permissions...]`, `An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](/docs/permissions).`)
578
606
  .option(`--fileSecurity <fileSecurity>`, `Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions).`, parseBool)
579
607
  .option(`--enabled <enabled>`, `Is bucket enabled?`, parseBool)
580
608
  .option(`--maximumFileSize <maximumFileSize>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self-hosted setups you can change the max limit by changing the '_APP_STORAGE_LIMIT' environment variable. [Learn more about storage environment variables](docs/environment-variables#storage)`, parseInteger)
581
- .option(`--allowedFileExtensions <allowedFileExtensions...>`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
609
+ .option(`--allowedFileExtensions [allowedFileExtensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
582
610
  .option(`--compression <compression>`, `Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled`)
583
611
  .option(`--encryption <encryption>`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, parseBool)
584
612
  .option(`--antivirus <antivirus>`, `Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled`, parseBool)
@@ -595,11 +623,11 @@ storage
595
623
  .description(`Update a storage bucket by its unique ID.`)
596
624
  .requiredOption(`--bucketId <bucketId>`, `Bucket unique ID.`)
597
625
  .requiredOption(`--name <name>`, `Bucket name`)
598
- .option(`--permissions <permissions...>`, `An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
626
+ .option(`--permissions [permissions...]`, `An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
599
627
  .option(`--fileSecurity <fileSecurity>`, `Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions).`, parseBool)
600
628
  .option(`--enabled <enabled>`, `Is bucket enabled?`, parseBool)
601
629
  .option(`--maximumFileSize <maximumFileSize>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self hosted version you can change the limit by changing _APP_STORAGE_LIMIT environment variable. [Learn more about storage environment variables](docs/environment-variables#storage)`, parseInteger)
602
- .option(`--allowedFileExtensions <allowedFileExtensions...>`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
630
+ .option(`--allowedFileExtensions [allowedFileExtensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
603
631
  .option(`--compression <compression>`, `Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled`)
604
632
  .option(`--encryption <encryption>`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, parseBool)
605
633
  .option(`--antivirus <antivirus>`, `Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled`, parseBool)
@@ -615,7 +643,7 @@ storage
615
643
  .command(`listFiles`)
616
644
  .description(`Get a list of all the user files. You can use the query params to filter your results.`)
617
645
  .requiredOption(`--bucketId <bucketId>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).`)
618
- .option(`--queries <queries...>`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded`)
646
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded`)
619
647
  .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
620
648
  .action(actionRunner(storageListFiles))
621
649
 
@@ -624,8 +652,8 @@ storage
624
652
  .description(`Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of '5MB'. The 'content-range' header values should always be in bytes. When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in 'x-appwrite-id' header to allow the server to know that the partial upload is for the existing file and not for a new one. If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally. `)
625
653
  .requiredOption(`--bucketId <bucketId>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).`)
626
654
  .requiredOption(`--fileId <fileId>`, `File ID. Choose a custom ID or generate a random ID with 'ID.unique()'. 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.`)
627
- .requiredOption(`--file <file>`, `Binary file.`)
628
- .option(`--permissions <permissions...>`, `An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions).`)
655
+ .requiredOption(`--file <file>`, `Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](/docs/storage#file-input).`)
656
+ .option(`--permissions [permissions...]`, `An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions).`)
629
657
  .action(actionRunner(storageCreateFile))
630
658
 
631
659
  storage
@@ -640,7 +668,7 @@ storage
640
668
  .description(`Update a file by its unique ID. Only users with write permissions have access to update this resource.`)
641
669
  .requiredOption(`--bucketId <bucketId>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).`)
642
670
  .requiredOption(`--fileId <fileId>`, `File unique ID.`)
643
- .option(`--permissions <permissions...>`, `An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
671
+ .option(`--permissions [permissions...]`, `An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
644
672
  .action(actionRunner(storageUpdateFile))
645
673
 
646
674
  storage