appwrite-cli 0.18.5 → 1.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 (79) hide show
  1. package/.github/workflows/npm-publish.yml +8 -1
  2. package/LICENSE.md +1 -1
  3. package/README.md +4 -4
  4. package/appwrite.json +4 -0
  5. package/docs/examples/account/create-phone-session.md +1 -1
  6. package/docs/examples/account/get-logs.md +0 -1
  7. package/docs/examples/account/list-logs.md +2 -0
  8. package/docs/examples/account/list-sessions.md +1 -0
  9. package/docs/examples/account/update-phone.md +1 -1
  10. package/docs/examples/avatars/get-initials.md +0 -1
  11. package/docs/examples/databases/create-collection.md +2 -3
  12. package/docs/examples/databases/create-datetime-attribute.md +7 -0
  13. package/docs/examples/databases/create-document.md +0 -1
  14. package/docs/examples/databases/list-collection-logs.md +0 -1
  15. package/docs/examples/databases/list-collections.md +0 -4
  16. package/docs/examples/databases/list-document-logs.md +0 -1
  17. package/docs/examples/databases/list-documents.md +0 -6
  18. package/docs/examples/databases/list-logs.md +0 -1
  19. package/docs/examples/databases/list.md +0 -4
  20. package/docs/examples/databases/update-collection.md +0 -1
  21. package/docs/examples/databases/update-document.md +0 -1
  22. package/docs/examples/functions/create-variable.md +4 -0
  23. package/docs/examples/functions/create.md +1 -1
  24. package/docs/examples/functions/delete-variable.md +3 -0
  25. package/docs/examples/functions/get-function-usage.md +3 -0
  26. package/docs/examples/functions/get-usage.md +0 -1
  27. package/docs/examples/functions/get-variable.md +3 -0
  28. package/docs/examples/functions/list-deployments.md +0 -4
  29. package/docs/examples/functions/list-executions.md +0 -3
  30. package/docs/examples/functions/list-variables.md +2 -0
  31. package/docs/examples/functions/list.md +0 -4
  32. package/docs/examples/functions/update-variable.md +5 -0
  33. package/docs/examples/functions/update.md +1 -1
  34. package/docs/examples/locale/list-continents.md +1 -0
  35. package/docs/examples/locale/list-countries-e-u.md +1 -0
  36. package/docs/examples/locale/list-countries-phones.md +1 -0
  37. package/docs/examples/locale/list-countries.md +1 -0
  38. package/docs/examples/locale/list-currencies.md +1 -0
  39. package/docs/examples/locale/list-languages.md +1 -0
  40. package/docs/examples/projects/list.md +0 -4
  41. package/docs/examples/storage/create-bucket.md +1 -1
  42. package/docs/examples/storage/create-file.md +0 -1
  43. package/docs/examples/storage/list-buckets.md +0 -4
  44. package/docs/examples/storage/list-files.md +0 -4
  45. package/docs/examples/storage/update-bucket.md +1 -1
  46. package/docs/examples/storage/update-file.md +0 -1
  47. package/docs/examples/teams/get-memberships.md +0 -4
  48. package/docs/examples/teams/list-logs.md +0 -1
  49. package/docs/examples/teams/list-memberships.md +4 -0
  50. package/docs/examples/teams/list.md +0 -4
  51. package/docs/examples/users/create-argon2user.md +5 -0
  52. package/docs/examples/users/create-bcrypt-user.md +5 -0
  53. package/docs/examples/users/create-m-d5user.md +5 -0
  54. package/docs/examples/users/create-p-h-pass-user.md +5 -0
  55. package/docs/examples/users/create-s-h-a-user.md +6 -0
  56. package/docs/examples/users/create-scrypt-modified-user.md +8 -0
  57. package/docs/examples/users/create-scrypt-user.md +10 -0
  58. package/docs/examples/users/create.md +3 -2
  59. package/docs/examples/users/get-logs.md +0 -1
  60. package/docs/examples/users/list-logs.md +3 -0
  61. package/docs/examples/users/list-memberships.md +2 -0
  62. package/docs/examples/users/list-sessions.md +2 -0
  63. package/docs/examples/users/list.md +0 -4
  64. package/install.ps1 +2 -2
  65. package/install.sh +1 -1
  66. package/lib/client.js +7 -3
  67. package/lib/commands/account.js +24 -29
  68. package/lib/commands/avatars.js +2 -7
  69. package/lib/commands/databases.js +154 -210
  70. package/lib/commands/deploy.js +12 -3
  71. package/lib/commands/functions.js +227 -93
  72. package/lib/commands/generic.js +3 -3
  73. package/lib/commands/locale.js +24 -24
  74. package/lib/commands/projects.js +10 -30
  75. package/lib/commands/storage.js +53 -105
  76. package/lib/commands/teams.js +20 -65
  77. package/lib/commands/users.js +425 -47
  78. package/lib/questions.js +1 -1
  79. package/package.json +1 -1
@@ -15,6 +15,7 @@ const {
15
15
  databasesCreateIntegerAttribute,
16
16
  databasesCreateFloatAttribute,
17
17
  databasesCreateEmailAttribute,
18
+ databasesCreateDatetimeAttribute,
18
19
  databasesCreateIndex,
19
20
  databasesCreateUrlAttribute,
20
21
  databasesCreateIpAttribute,
@@ -338,6 +339,15 @@ const createAttribute = async (databaseId, collectionId, attribute) => {
338
339
  case 'boolean':
339
340
  return databasesCreateBooleanAttribute({
340
341
  databaseId,
342
+ collectionId,
343
+ key: attribute.key,
344
+ required: attribute.required,
345
+ xdefault: attribute.default,
346
+ array: attribute.array,
347
+ parseOutput: false
348
+ })
349
+ case 'datetime':
350
+ return databasesCreateDatetimeAttribute({
341
351
  databaseId,
342
352
  collectionId,
343
353
  key: attribute.key,
@@ -494,9 +504,8 @@ const deployCollection = async ({ all } = {}) => {
494
504
  databaseId,
495
505
  collectionId: collection['$id'],
496
506
  name: collection.name,
497
- permission: collection.permission,
498
- read: collection['$read'],
499
- write: collection['$write'],
507
+ documentSecurity: collection.documentSecurity,
508
+ '$permissions': collection['$permissions'],
500
509
  parseOutput: false
501
510
  })
502
511
 
@@ -12,37 +12,21 @@ const { localConfig, globalConfig } = require("../config");
12
12
 
13
13
  const functions = new Command("functions").description(commandDescriptions['functions'])
14
14
 
15
- const functionsList = async ({ search, limit, offset, cursor, cursorDirection, orderType, parseOutput = true, sdk = undefined}) => {
15
+ const functionsList = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
16
+ /* @param {string[]} queries */
16
17
  /* @param {string} search */
17
- /* @param {number} limit */
18
- /* @param {number} offset */
19
- /* @param {string} cursor */
20
- /* @param {string} cursorDirection */
21
- /* @param {string} orderType */
22
18
 
23
19
  let client = !sdk ? await sdkForProject() : sdk;
24
20
  let path = '/functions';
25
21
  let payload = {};
26
22
 
27
23
  /** Query Params */
24
+ if (typeof queries !== 'undefined') {
25
+ payload['queries'] = queries;
26
+ }
28
27
  if (typeof search !== 'undefined') {
29
28
  payload['search'] = search;
30
29
  }
31
- if (typeof limit !== 'undefined') {
32
- payload['limit'] = limit;
33
- }
34
- if (typeof offset !== 'undefined') {
35
- payload['offset'] = offset;
36
- }
37
- if (typeof cursor !== 'undefined') {
38
- payload['cursor'] = cursor;
39
- }
40
- if (typeof cursorDirection !== 'undefined') {
41
- payload['cursorDirection'] = cursorDirection;
42
- }
43
- if (typeof orderType !== 'undefined') {
44
- payload['orderType'] = orderType;
45
- }
46
30
  let response = undefined;
47
31
  response = await client.call('get', path, {
48
32
  'content-type': 'application/json',
@@ -55,15 +39,15 @@ const functionsList = async ({ search, limit, offset, cursor, cursorDirection, o
55
39
  return response;
56
40
  }
57
41
 
58
- const functionsCreate = async ({ functionId, name, execute, runtime, vars, events, schedule, timeout, parseOutput = true, sdk = undefined}) => {
42
+ const functionsCreate = async ({ functionId, name, execute, runtime, events, schedule, timeout, enabled, parseOutput = true, sdk = undefined}) => {
59
43
  /* @param {string} functionId */
60
44
  /* @param {string} name */
61
45
  /* @param {string[]} execute */
62
46
  /* @param {string} runtime */
63
- /* @param {object} vars */
64
47
  /* @param {string[]} events */
65
48
  /* @param {string} schedule */
66
49
  /* @param {number} timeout */
50
+ /* @param {boolean} enabled */
67
51
 
68
52
  let client = !sdk ? await sdkForProject() : sdk;
69
53
  let path = '/functions';
@@ -86,10 +70,6 @@ const functionsCreate = async ({ functionId, name, execute, runtime, vars, event
86
70
  payload['runtime'] = runtime;
87
71
  }
88
72
 
89
- if (typeof vars !== 'undefined') {
90
- payload['vars'] = JSON.parse(vars);
91
- }
92
-
93
73
  if (typeof events !== 'undefined') {
94
74
  payload['events'] = events;
95
75
  }
@@ -102,6 +82,10 @@ const functionsCreate = async ({ functionId, name, execute, runtime, vars, event
102
82
  payload['timeout'] = timeout;
103
83
  }
104
84
 
85
+ if (typeof enabled !== 'undefined') {
86
+ payload['enabled'] = enabled;
87
+ }
88
+
105
89
  let response = undefined;
106
90
  response = await client.call('post', path, {
107
91
  'content-type': 'application/json',
@@ -131,6 +115,29 @@ const functionsListRuntimes = async ({ parseOutput = true, sdk = undefined}) =>
131
115
  return response;
132
116
  }
133
117
 
118
+ const functionsGetUsage = async ({ range, parseOutput = true, sdk = undefined}) => {
119
+ /* @param {string} range */
120
+
121
+ let client = !sdk ? await sdkForProject() : sdk;
122
+ let path = '/functions/usage';
123
+ let payload = {};
124
+
125
+ /** Query Params */
126
+ if (typeof range !== 'undefined') {
127
+ payload['range'] = range;
128
+ }
129
+ let response = undefined;
130
+ response = await client.call('get', path, {
131
+ 'content-type': 'application/json',
132
+ }, payload);
133
+
134
+ if (parseOutput) {
135
+ parse(response)
136
+ success()
137
+ }
138
+ return response;
139
+ }
140
+
134
141
  const functionsGet = async ({ functionId, parseOutput = true, sdk = undefined}) => {
135
142
  /* @param {string} functionId */
136
143
 
@@ -149,14 +156,14 @@ const functionsGet = async ({ functionId, parseOutput = true, sdk = undefined})
149
156
  return response;
150
157
  }
151
158
 
152
- const functionsUpdate = async ({ functionId, name, execute, vars, events, schedule, timeout, parseOutput = true, sdk = undefined}) => {
159
+ const functionsUpdate = async ({ functionId, name, execute, events, schedule, timeout, enabled, parseOutput = true, sdk = undefined}) => {
153
160
  /* @param {string} functionId */
154
161
  /* @param {string} name */
155
162
  /* @param {string[]} execute */
156
- /* @param {object} vars */
157
163
  /* @param {string[]} events */
158
164
  /* @param {string} schedule */
159
165
  /* @param {number} timeout */
166
+ /* @param {boolean} enabled */
160
167
 
161
168
  let client = !sdk ? await sdkForProject() : sdk;
162
169
  let path = '/functions/{functionId}'.replace('{functionId}', functionId);
@@ -171,10 +178,6 @@ const functionsUpdate = async ({ functionId, name, execute, vars, events, schedu
171
178
  payload['execute'] = execute;
172
179
  }
173
180
 
174
- if (typeof vars !== 'undefined') {
175
- payload['vars'] = JSON.parse(vars);
176
- }
177
-
178
181
  if (typeof events !== 'undefined') {
179
182
  payload['events'] = events;
180
183
  }
@@ -187,6 +190,10 @@ const functionsUpdate = async ({ functionId, name, execute, vars, events, schedu
187
190
  payload['timeout'] = timeout;
188
191
  }
189
192
 
193
+ if (typeof enabled !== 'undefined') {
194
+ payload['enabled'] = enabled;
195
+ }
196
+
190
197
  let response = undefined;
191
198
  response = await client.call('put', path, {
192
199
  'content-type': 'application/json',
@@ -217,38 +224,22 @@ const functionsDelete = async ({ functionId, parseOutput = true, sdk = undefined
217
224
  return response;
218
225
  }
219
226
 
220
- const functionsListDeployments = async ({ functionId, search, limit, offset, cursor, cursorDirection, orderType, parseOutput = true, sdk = undefined}) => {
227
+ const functionsListDeployments = async ({ functionId, queries, search, parseOutput = true, sdk = undefined}) => {
221
228
  /* @param {string} functionId */
229
+ /* @param {string[]} queries */
222
230
  /* @param {string} search */
223
- /* @param {number} limit */
224
- /* @param {number} offset */
225
- /* @param {string} cursor */
226
- /* @param {string} cursorDirection */
227
- /* @param {string} orderType */
228
231
 
229
232
  let client = !sdk ? await sdkForProject() : sdk;
230
233
  let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
231
234
  let payload = {};
232
235
 
233
236
  /** Query Params */
237
+ if (typeof queries !== 'undefined') {
238
+ payload['queries'] = queries;
239
+ }
234
240
  if (typeof search !== 'undefined') {
235
241
  payload['search'] = search;
236
242
  }
237
- if (typeof limit !== 'undefined') {
238
- payload['limit'] = limit;
239
- }
240
- if (typeof offset !== 'undefined') {
241
- payload['offset'] = offset;
242
- }
243
- if (typeof cursor !== 'undefined') {
244
- payload['cursor'] = cursor;
245
- }
246
- if (typeof cursorDirection !== 'undefined') {
247
- payload['cursorDirection'] = cursorDirection;
248
- }
249
- if (typeof orderType !== 'undefined') {
250
- payload['orderType'] = orderType;
251
- }
252
243
  let response = undefined;
253
244
  response = await client.call('get', path, {
254
245
  'content-type': 'application/json',
@@ -455,34 +446,22 @@ const functionsRetryBuild = async ({ functionId, deploymentId, buildId, parseOut
455
446
  return response;
456
447
  }
457
448
 
458
- const functionsListExecutions = async ({ functionId, limit, offset, search, cursor, cursorDirection, parseOutput = true, sdk = undefined}) => {
449
+ const functionsListExecutions = async ({ functionId, queries, search, parseOutput = true, sdk = undefined}) => {
459
450
  /* @param {string} functionId */
460
- /* @param {number} limit */
461
- /* @param {number} offset */
451
+ /* @param {string[]} queries */
462
452
  /* @param {string} search */
463
- /* @param {string} cursor */
464
- /* @param {string} cursorDirection */
465
453
 
466
454
  let client = !sdk ? await sdkForProject() : sdk;
467
455
  let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
468
456
  let payload = {};
469
457
 
470
458
  /** Query Params */
471
- if (typeof limit !== 'undefined') {
472
- payload['limit'] = limit;
473
- }
474
- if (typeof offset !== 'undefined') {
475
- payload['offset'] = offset;
459
+ if (typeof queries !== 'undefined') {
460
+ payload['queries'] = queries;
476
461
  }
477
462
  if (typeof search !== 'undefined') {
478
463
  payload['search'] = search;
479
464
  }
480
- if (typeof cursor !== 'undefined') {
481
- payload['cursor'] = cursor;
482
- }
483
- if (typeof cursorDirection !== 'undefined') {
484
- payload['cursorDirection'] = cursorDirection;
485
- }
486
465
  let response = undefined;
487
466
  response = await client.call('get', path, {
488
467
  'content-type': 'application/json',
@@ -544,7 +523,7 @@ const functionsGetExecution = async ({ functionId, executionId, parseOutput = tr
544
523
  return response;
545
524
  }
546
525
 
547
- const functionsGetUsage = async ({ functionId, range, parseOutput = true, sdk = undefined}) => {
526
+ const functionsGetFunctionUsage = async ({ functionId, range, parseOutput = true, sdk = undefined}) => {
548
527
  /* @param {string} functionId */
549
528
  /* @param {string} range */
550
529
 
@@ -568,16 +547,129 @@ const functionsGetUsage = async ({ functionId, range, parseOutput = true, sdk =
568
547
  return response;
569
548
  }
570
549
 
550
+ const functionsListVariables = async ({ functionId, parseOutput = true, sdk = undefined}) => {
551
+ /* @param {string} functionId */
552
+
553
+ let client = !sdk ? await sdkForProject() : sdk;
554
+ let path = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
555
+ let payload = {};
556
+ let response = undefined;
557
+ response = await client.call('get', path, {
558
+ 'content-type': 'application/json',
559
+ }, payload);
560
+
561
+ if (parseOutput) {
562
+ parse(response)
563
+ success()
564
+ }
565
+ return response;
566
+ }
567
+
568
+ const functionsCreateVariable = async ({ functionId, key, value, parseOutput = true, sdk = undefined}) => {
569
+ /* @param {string} functionId */
570
+ /* @param {string} key */
571
+ /* @param {string} value */
572
+
573
+ let client = !sdk ? await sdkForProject() : sdk;
574
+ let path = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
575
+ let payload = {};
576
+
577
+ /** Body Params */
578
+ if (typeof key !== 'undefined') {
579
+ payload['key'] = key;
580
+ }
581
+
582
+ if (typeof value !== 'undefined') {
583
+ payload['value'] = value;
584
+ }
585
+
586
+ let response = undefined;
587
+ response = await client.call('post', path, {
588
+ 'content-type': 'application/json',
589
+ }, payload);
590
+
591
+ if (parseOutput) {
592
+ parse(response)
593
+ success()
594
+ }
595
+ return response;
596
+ }
597
+
598
+ const functionsGetVariable = async ({ functionId, variableId, parseOutput = true, sdk = undefined}) => {
599
+ /* @param {string} functionId */
600
+ /* @param {string} variableId */
601
+
602
+ let client = !sdk ? await sdkForProject() : sdk;
603
+ let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
604
+ let payload = {};
605
+ let response = undefined;
606
+ response = await client.call('get', path, {
607
+ 'content-type': 'application/json',
608
+ }, payload);
609
+
610
+ if (parseOutput) {
611
+ parse(response)
612
+ success()
613
+ }
614
+ return response;
615
+ }
616
+
617
+ const functionsUpdateVariable = async ({ functionId, variableId, key, value, parseOutput = true, sdk = undefined}) => {
618
+ /* @param {string} functionId */
619
+ /* @param {string} variableId */
620
+ /* @param {string} key */
621
+ /* @param {string} value */
622
+
623
+ let client = !sdk ? await sdkForProject() : sdk;
624
+ let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
625
+ let payload = {};
626
+
627
+ /** Body Params */
628
+ if (typeof key !== 'undefined') {
629
+ payload['key'] = key;
630
+ }
631
+
632
+ if (typeof value !== 'undefined') {
633
+ payload['value'] = value;
634
+ }
635
+
636
+ let response = undefined;
637
+ response = await client.call('put', path, {
638
+ 'content-type': 'application/json',
639
+ }, payload);
640
+
641
+ if (parseOutput) {
642
+ parse(response)
643
+ success()
644
+ }
645
+ return response;
646
+ }
647
+
648
+ const functionsDeleteVariable = async ({ functionId, variableId, parseOutput = true, sdk = undefined}) => {
649
+ /* @param {string} functionId */
650
+ /* @param {string} variableId */
651
+
652
+ let client = !sdk ? await sdkForProject() : sdk;
653
+ let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
654
+ let payload = {};
655
+ let response = undefined;
656
+ response = await client.call('delete', path, {
657
+ 'content-type': 'application/json',
658
+ }, payload);
659
+
660
+ if (parseOutput) {
661
+ parse(response)
662
+ success()
663
+ }
664
+ return response;
665
+ }
666
+
571
667
 
572
668
  functions
573
669
  .command(`list`)
574
670
  .description(`Get a list of all the project's functions. You can use the query params to filter your results.`)
671
+ .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, enabled, runtime, deployment, schedule, scheduleNext, schedulePrevious, timeout`)
575
672
  .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
576
- .option(`--limit <limit>`, `Maximum number of functions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.`, parseInteger)
577
- .option(`--offset <offset>`, `Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)`, parseInteger)
578
- .option(`--cursor <cursor>`, `ID of the function used as the starting point for the query, excluding the function itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)`)
579
- .option(`--cursorDirection <cursorDirection>`, `Direction of the cursor, can be either 'before' or 'after'.`)
580
- .option(`--orderType <orderType>`, `Order result by ASC or DESC order.`)
581
673
  .action(actionRunner(functionsList))
582
674
 
583
675
  functions
@@ -585,12 +677,12 @@ functions
585
677
  .description(`Create a new function. You can pass a list of [permissions](/docs/permissions) to allow different project users or team with access to execute the function using the client API.`)
586
678
  .requiredOption(`--functionId <functionId>`, `Function 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.`)
587
679
  .requiredOption(`--name <name>`, `Function name. Max length: 128 chars.`)
588
- .requiredOption(`--execute <execute...>`, `An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. Maximum of 100 scopes are allowed, each 64 characters long.`)
680
+ .requiredOption(`--execute <execute...>`, `An array of strings with execution roles. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 64 characters long.`)
589
681
  .requiredOption(`--runtime <runtime>`, `Execution runtime.`)
590
- .option(`--vars <vars>`, `Key-value JSON object that will be passed to the function as environment variables.`)
591
682
  .option(`--events <events...>`, `Events list. Maximum of 100 events are allowed.`)
592
683
  .option(`--schedule <schedule>`, `Schedule CRON syntax.`)
593
684
  .option(`--timeout <timeout>`, `Function maximum execution time in seconds.`, parseInteger)
685
+ .option(`--enabled <enabled>`, `Is function enabled?`, parseBool)
594
686
  .action(actionRunner(functionsCreate))
595
687
 
596
688
  functions
@@ -598,6 +690,12 @@ functions
598
690
  .description(`Get a list of all runtimes that are currently active on your instance.`)
599
691
  .action(actionRunner(functionsListRuntimes))
600
692
 
693
+ functions
694
+ .command(`getUsage`)
695
+ .description(``)
696
+ .option(`--range <range>`, `Date range.`)
697
+ .action(actionRunner(functionsGetUsage))
698
+
601
699
  functions
602
700
  .command(`get`)
603
701
  .description(`Get a function by its unique ID.`)
@@ -609,11 +707,11 @@ functions
609
707
  .description(`Update function by its unique ID.`)
610
708
  .requiredOption(`--functionId <functionId>`, `Function ID.`)
611
709
  .requiredOption(`--name <name>`, `Function name. Max length: 128 chars.`)
612
- .requiredOption(`--execute <execute...>`, `An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. Maximum of 100 scopes are allowed, each 64 characters long.`)
613
- .option(`--vars <vars>`, `Key-value JSON object that will be passed to the function as environment variables.`)
710
+ .requiredOption(`--execute <execute...>`, `An array of strings with execution roles. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 64 characters long.`)
614
711
  .option(`--events <events...>`, `Events list. Maximum of 100 events are allowed.`)
615
712
  .option(`--schedule <schedule>`, `Schedule CRON syntax.`)
616
713
  .option(`--timeout <timeout>`, `Maximum execution time in seconds.`, parseInteger)
714
+ .option(`--enabled <enabled>`, `Is function enabled?`, parseBool)
617
715
  .action(actionRunner(functionsUpdate))
618
716
 
619
717
  functions
@@ -626,12 +724,8 @@ functions
626
724
  .command(`listDeployments`)
627
725
  .description(`Get a list of all the project's code deployments. You can use the query params to filter your results.`)
628
726
  .requiredOption(`--functionId <functionId>`, `Function ID.`)
727
+ .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: entrypoint, size, buildId, activate`)
629
728
  .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
630
- .option(`--limit <limit>`, `Maximum number of deployments to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.`, parseInteger)
631
- .option(`--offset <offset>`, `Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)`, parseInteger)
632
- .option(`--cursor <cursor>`, `ID of the deployment used as the starting point for the query, excluding the deployment itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)`)
633
- .option(`--cursorDirection <cursorDirection>`, `Direction of the cursor, can be either 'before' or 'after'.`)
634
- .option(`--orderType <orderType>`, `Order result by ASC or DESC order.`)
635
729
  .action(actionRunner(functionsListDeployments))
636
730
 
637
731
  functions
@@ -676,11 +770,8 @@ functions
676
770
  .command(`listExecutions`)
677
771
  .description(`Get a list of all the current user function execution logs. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's executions. [Learn more about different API modes](/docs/admin).`)
678
772
  .requiredOption(`--functionId <functionId>`, `Function ID.`)
679
- .option(`--limit <limit>`, `Maximum number of executions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.`, parseInteger)
680
- .option(`--offset <offset>`, `Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)`, parseInteger)
773
+ .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: trigger, status, statusCode, duration`)
681
774
  .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
682
- .option(`--cursor <cursor>`, `ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)`)
683
- .option(`--cursorDirection <cursorDirection>`, `Direction of the cursor, can be either 'before' or 'after'.`)
684
775
  .action(actionRunner(functionsListExecutions))
685
776
 
686
777
  functions
@@ -688,7 +779,7 @@ functions
688
779
  .description(`Trigger a function execution. The returned object will return you the current execution status. You can ping the 'Get Execution' endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously.`)
689
780
  .requiredOption(`--functionId <functionId>`, `Function ID.`)
690
781
  .option(`--data <data>`, `String of custom data to send to function.`)
691
- .option(`--async <async>`, `Execute code asynchronously. Default value is true.`, parseBool)
782
+ .option(`--async <async>`, `Execute code in the background. Default value is false.`, parseBool)
692
783
  .action(actionRunner(functionsCreateExecution))
693
784
 
694
785
  functions
@@ -699,11 +790,48 @@ functions
699
790
  .action(actionRunner(functionsGetExecution))
700
791
 
701
792
  functions
702
- .command(`getUsage`)
793
+ .command(`getFunctionUsage`)
703
794
  .description(``)
704
795
  .requiredOption(`--functionId <functionId>`, `Function ID.`)
705
796
  .option(`--range <range>`, `Date range.`)
706
- .action(actionRunner(functionsGetUsage))
797
+ .action(actionRunner(functionsGetFunctionUsage))
798
+
799
+ functions
800
+ .command(`listVariables`)
801
+ .description(`Get a list of all variables of a specific function.`)
802
+ .requiredOption(`--functionId <functionId>`, `Function unique ID.`)
803
+ .action(actionRunner(functionsListVariables))
804
+
805
+ functions
806
+ .command(`createVariable`)
807
+ .description(`Create a new function variable. These variables can be accessed within function in the 'env' object under the request variable.`)
808
+ .requiredOption(`--functionId <functionId>`, `Function unique ID.`)
809
+ .requiredOption(`--key <key>`, `Variable key. Max length: 255 chars.`)
810
+ .requiredOption(`--value <value>`, `Variable value. Max length: 8192 chars.`)
811
+ .action(actionRunner(functionsCreateVariable))
812
+
813
+ functions
814
+ .command(`getVariable`)
815
+ .description(`Get a variable by its unique ID.`)
816
+ .requiredOption(`--functionId <functionId>`, `Function unique ID.`)
817
+ .requiredOption(`--variableId <variableId>`, `Variable unique ID.`)
818
+ .action(actionRunner(functionsGetVariable))
819
+
820
+ functions
821
+ .command(`updateVariable`)
822
+ .description(`Update variable by its unique ID.`)
823
+ .requiredOption(`--functionId <functionId>`, `Function unique ID.`)
824
+ .requiredOption(`--variableId <variableId>`, `Variable unique ID.`)
825
+ .requiredOption(`--key <key>`, `Variable key. Max length: 255 chars.`)
826
+ .option(`--value <value>`, `Variable value. Max length: 8192 chars.`)
827
+ .action(actionRunner(functionsUpdateVariable))
828
+
829
+ functions
830
+ .command(`deleteVariable`)
831
+ .description(`Delete a variable by its unique ID.`)
832
+ .requiredOption(`--functionId <functionId>`, `Function unique ID.`)
833
+ .requiredOption(`--variableId <variableId>`, `Variable unique ID.`)
834
+ .action(actionRunner(functionsDeleteVariable))
707
835
 
708
836
 
709
837
  module.exports = {
@@ -711,6 +839,7 @@ module.exports = {
711
839
  functionsList,
712
840
  functionsCreate,
713
841
  functionsListRuntimes,
842
+ functionsGetUsage,
714
843
  functionsGet,
715
844
  functionsUpdate,
716
845
  functionsDelete,
@@ -723,5 +852,10 @@ module.exports = {
723
852
  functionsListExecutions,
724
853
  functionsCreateExecution,
725
854
  functionsGetExecution,
726
- functionsGetUsage
855
+ functionsGetFunctionUsage,
856
+ functionsListVariables,
857
+ functionsCreateVariable,
858
+ functionsGetVariable,
859
+ functionsUpdateVariable,
860
+ functionsDeleteVariable
727
861
  };
@@ -42,9 +42,9 @@ const logout = new Command("logout")
42
42
  const client = new Command("client")
43
43
  .description(commandDescriptions['client'])
44
44
  .option("--selfSigned <value>", "Configure the CLI to use a self-signed certificate ( true or false )", parseBool)
45
- .option("--endpoint <endpoint>", "Set your Apwrite server endpoint")
46
- .option("--projectId <projectId>", "Set your Apwrite project ID")
47
- .option("--key <key>", "Set your Apwrite server's API key")
45
+ .option("--endpoint <endpoint>", "Set your Appwrite server endpoint")
46
+ .option("--projectId <projectId>", "Set your Appwrite project ID")
47
+ .option("--key <key>", "Set your Appwrite server's API key")
48
48
  .option("--debug", "Print CLI debug information")
49
49
  .option("--reset", "Reset the CLI configuration")
50
50
  .action(actionRunner(async ({ selfSigned, endpoint, projectId, key, debug, reset }, command) => {