appwrite-cli 6.2.3 → 8.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 (118) hide show
  1. package/README.md +4 -4
  2. package/docs/examples/console/get-resource.md +3 -0
  3. package/docs/examples/databases/create-documents.md +4 -0
  4. package/docs/examples/databases/create-index.md +1 -0
  5. package/docs/examples/databases/delete-documents.md +4 -0
  6. package/docs/examples/databases/update-documents.md +5 -0
  7. package/docs/examples/databases/upsert-document.md +6 -0
  8. package/docs/examples/databases/upsert-documents.md +4 -0
  9. package/docs/examples/functions/{create-build.md → create-duplicate-deployment.md} +1 -1
  10. package/docs/examples/functions/create-template-deployment.md +7 -0
  11. package/docs/examples/functions/create-variable.md +2 -1
  12. package/docs/examples/functions/create-vcs-deployment.md +5 -0
  13. package/docs/examples/functions/create.md +0 -4
  14. package/docs/examples/functions/get-deployment-download.md +2 -1
  15. package/docs/examples/functions/get-usage.md +1 -0
  16. package/docs/examples/functions/list-executions.md +0 -1
  17. package/docs/examples/functions/list-usage.md +2 -0
  18. package/docs/examples/functions/{update-deployment.md → update-deployment-status.md} +1 -1
  19. package/docs/examples/functions/{update-deployment-build.md → update-function-deployment.md} +1 -1
  20. package/docs/examples/functions/update-variable.md +1 -0
  21. package/docs/examples/migrations/create-csv-migration.md +4 -0
  22. package/docs/examples/project/create-variable.md +2 -1
  23. package/docs/examples/project/update-variable.md +1 -0
  24. package/docs/examples/projects/create-dev-key.md +4 -0
  25. package/docs/examples/projects/delete-dev-key.md +3 -0
  26. package/docs/examples/projects/get-dev-key.md +3 -0
  27. package/docs/examples/projects/list-dev-keys.md +3 -0
  28. package/docs/examples/projects/update-dev-key.md +5 -0
  29. package/docs/examples/proxy/create-a-p-i-rule.md +2 -0
  30. package/docs/examples/proxy/create-function-rule.md +4 -0
  31. package/docs/examples/proxy/create-redirect-rule.md +4 -0
  32. package/docs/examples/proxy/create-site-rule.md +4 -0
  33. package/docs/examples/sites/create-deployment.md +7 -0
  34. package/docs/examples/sites/create-duplicate-deployment.md +3 -0
  35. package/docs/examples/sites/create-template-deployment.md +7 -0
  36. package/docs/examples/sites/create-variable.md +5 -0
  37. package/docs/examples/sites/create-vcs-deployment.md +5 -0
  38. package/docs/examples/sites/create.md +19 -0
  39. package/docs/examples/sites/delete-deployment.md +3 -0
  40. package/docs/examples/sites/delete-log.md +3 -0
  41. package/docs/examples/sites/delete-variable.md +3 -0
  42. package/docs/examples/sites/delete.md +2 -0
  43. package/docs/examples/sites/get-deployment-download.md +4 -0
  44. package/docs/examples/sites/get-deployment.md +3 -0
  45. package/docs/examples/sites/get-log.md +3 -0
  46. package/docs/examples/sites/get-template.md +2 -0
  47. package/docs/examples/sites/get-usage.md +3 -0
  48. package/docs/examples/sites/get-variable.md +3 -0
  49. package/docs/examples/sites/get.md +2 -0
  50. package/docs/examples/sites/list-deployments.md +4 -0
  51. package/docs/examples/sites/list-frameworks.md +1 -0
  52. package/docs/examples/sites/list-logs.md +3 -0
  53. package/docs/examples/sites/list-specifications.md +1 -0
  54. package/docs/examples/sites/list-templates.md +5 -0
  55. package/docs/examples/sites/list-usage.md +2 -0
  56. package/docs/examples/sites/list-variables.md +2 -0
  57. package/docs/examples/sites/list.md +3 -0
  58. package/docs/examples/sites/update-deployment-status.md +3 -0
  59. package/docs/examples/sites/update-site-deployment.md +3 -0
  60. package/docs/examples/sites/update-variable.md +6 -0
  61. package/docs/examples/sites/update.md +19 -0
  62. package/docs/examples/storage/get-file-download.md +2 -1
  63. package/docs/examples/storage/get-file-preview.md +1 -0
  64. package/docs/examples/storage/get-file-view.md +2 -1
  65. package/docs/examples/tokens/create-file-token.md +4 -0
  66. package/docs/examples/tokens/delete.md +2 -0
  67. package/docs/examples/tokens/get.md +2 -0
  68. package/docs/examples/tokens/list.md +4 -0
  69. package/docs/examples/tokens/update.md +3 -0
  70. package/docs/examples/users/list-memberships.md +3 -1
  71. package/docs/examples/vcs/create-repository-detection.md +1 -0
  72. package/docs/examples/vcs/list-repositories.md +1 -0
  73. package/index.js +6 -2
  74. package/install.ps1 +2 -2
  75. package/install.sh +1 -1
  76. package/lib/client.js +8 -4
  77. package/lib/commands/account.js +7 -17
  78. package/lib/commands/avatars.js +7 -14
  79. package/lib/commands/console.js +50 -1
  80. package/lib/commands/databases.js +287 -55
  81. package/lib/commands/functions.js +244 -146
  82. package/lib/commands/generic.js +1 -1
  83. package/lib/commands/health.js +0 -63
  84. package/lib/commands/init.js +191 -0
  85. package/lib/commands/locale.js +0 -8
  86. package/lib/commands/messaging.js +38 -51
  87. package/lib/commands/migrations.js +50 -5
  88. package/lib/commands/project.js +12 -5
  89. package/lib/commands/projects.js +246 -27
  90. package/lib/commands/proxy.js +160 -19
  91. package/lib/commands/pull.js +124 -1
  92. package/lib/commands/push.js +338 -5
  93. package/lib/commands/sites.js +1663 -0
  94. package/lib/commands/storage.js +28 -22
  95. package/lib/commands/teams.js +2 -8
  96. package/lib/commands/tokens.js +261 -0
  97. package/lib/commands/types.js +126 -0
  98. package/lib/commands/users.js +15 -17
  99. package/lib/commands/vcs.js +60 -53
  100. package/lib/config.js +50 -0
  101. package/lib/parser.js +2 -2
  102. package/lib/questions.js +110 -1
  103. package/lib/type-generation/attribute.js +16 -0
  104. package/lib/type-generation/languages/dart.js +152 -0
  105. package/lib/type-generation/languages/java.js +121 -0
  106. package/lib/type-generation/languages/javascript.js +84 -0
  107. package/lib/type-generation/languages/kotlin.js +75 -0
  108. package/lib/type-generation/languages/language.js +125 -0
  109. package/lib/type-generation/languages/php.js +100 -0
  110. package/lib/type-generation/languages/swift.js +156 -0
  111. package/lib/type-generation/languages/typescript.js +95 -0
  112. package/package.json +2 -1
  113. package/scoop/appwrite.json +3 -3
  114. package/docs/examples/assistant/chat.md +0 -2
  115. package/docs/examples/functions/get-function-usage.md +0 -3
  116. package/docs/examples/health/get-queue-stats-usage-dump.md +0 -2
  117. package/docs/examples/proxy/create-rule.md +0 -4
  118. package/lib/commands/assistant.js +0 -85
@@ -41,7 +41,7 @@ const functions = new Command("functions").description(commandDescriptions['func
41
41
 
42
42
  /**
43
43
  * @typedef {Object} FunctionsListRequestParams
44
- * @property {string[]} 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, enabled, runtime, deployment, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId
44
+ * @property {string[]} 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, enabled, runtime, deploymentId, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId
45
45
  * @property {string} search Search term to filter your list results. Max length: 256 chars.
46
46
  * @property {boolean} overrideForCli
47
47
  * @property {boolean} parseOutput
@@ -66,7 +66,6 @@ const functionsList = async ({queries,search,parseOutput = true, overrideForCli
66
66
  let response = undefined;
67
67
 
68
68
  response = await client.call('get', apiPath, {
69
- 'content-type': 'application/json',
70
69
  }, payload);
71
70
 
72
71
  if (parseOutput) {
@@ -91,7 +90,7 @@ const functionsList = async ({queries,search,parseOutput = true, overrideForCli
91
90
  * @property {string} schedule Schedule CRON syntax.
92
91
  * @property {number} timeout Function maximum execution time in seconds.
93
92
  * @property {boolean} enabled Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.
94
- * @property {boolean} logging Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.
93
+ * @property {boolean} logging When disabled, executions will exclude logs and errors, and will be slightly faster.
95
94
  * @property {string} entrypoint Entrypoint File. This path is relative to the "providerRootDirectory".
96
95
  * @property {string} commands Build Commands.
97
96
  * @property {string[]} scopes List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed.
@@ -100,10 +99,6 @@ const functionsList = async ({queries,search,parseOutput = true, overrideForCli
100
99
  * @property {string} providerBranch Production branch for the repo linked to the function.
101
100
  * @property {boolean} providerSilentMode Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.
102
101
  * @property {string} providerRootDirectory Path to function code in the linked repo.
103
- * @property {string} templateRepository Repository name of the template.
104
- * @property {string} templateOwner The name of the owner of the template.
105
- * @property {string} templateRootDirectory Path to function code in the template repo.
106
- * @property {string} templateVersion Version (tag) for the repo linked to the function template.
107
102
  * @property {string} specification Runtime specification for the function and builds.
108
103
  * @property {boolean} overrideForCli
109
104
  * @property {boolean} parseOutput
@@ -113,7 +108,7 @@ const functionsList = async ({queries,search,parseOutput = true, overrideForCli
113
108
  /**
114
109
  * @param {FunctionsCreateRequestParams} params
115
110
  */
116
- const functionsCreate = async ({functionId,name,runtime,execute,events,schedule,timeout,enabled,logging,entrypoint,commands,scopes,installationId,providerRepositoryId,providerBranch,providerSilentMode,providerRootDirectory,templateRepository,templateOwner,templateRootDirectory,templateVersion,specification,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
111
+ const functionsCreate = async ({functionId,name,runtime,execute,events,schedule,timeout,enabled,logging,entrypoint,commands,scopes,installationId,providerRepositoryId,providerBranch,providerSilentMode,providerRootDirectory,specification,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
117
112
  let client = !sdk ? await sdkForProject() :
118
113
  sdk;
119
114
  let apiPath = '/functions';
@@ -172,18 +167,6 @@ const functionsCreate = async ({functionId,name,runtime,execute,events,schedule,
172
167
  if (typeof providerRootDirectory !== 'undefined') {
173
168
  payload['providerRootDirectory'] = providerRootDirectory;
174
169
  }
175
- if (typeof templateRepository !== 'undefined') {
176
- payload['templateRepository'] = templateRepository;
177
- }
178
- if (typeof templateOwner !== 'undefined') {
179
- payload['templateOwner'] = templateOwner;
180
- }
181
- if (typeof templateRootDirectory !== 'undefined') {
182
- payload['templateRootDirectory'] = templateRootDirectory;
183
- }
184
- if (typeof templateVersion !== 'undefined') {
185
- payload['templateVersion'] = templateVersion;
186
- }
187
170
  if (typeof specification !== 'undefined') {
188
171
  payload['specification'] = specification;
189
172
  }
@@ -221,7 +204,6 @@ const functionsListRuntimes = async ({parseOutput = true, overrideForCli = false
221
204
  let response = undefined;
222
205
 
223
206
  response = await client.call('get', apiPath, {
224
- 'content-type': 'application/json',
225
207
  }, payload);
226
208
 
227
209
  if (parseOutput) {
@@ -251,7 +233,6 @@ const functionsListSpecifications = async ({parseOutput = true, overrideForCli =
251
233
  let response = undefined;
252
234
 
253
235
  response = await client.call('get', apiPath, {
254
- 'content-type': 'application/json',
255
236
  }, payload);
256
237
 
257
238
  if (parseOutput) {
@@ -301,7 +282,6 @@ const functionsListTemplates = async ({runtimes,useCases,limit,offset,parseOutpu
301
282
  let response = undefined;
302
283
 
303
284
  response = await client.call('get', apiPath, {
304
- 'content-type': 'application/json',
305
285
  }, payload);
306
286
 
307
287
  if (parseOutput) {
@@ -336,7 +316,6 @@ const functionsGetTemplate = async ({templateId,parseOutput = true, overrideForC
336
316
  let response = undefined;
337
317
 
338
318
  response = await client.call('get', apiPath, {
339
- 'content-type': 'application/json',
340
319
  }, payload);
341
320
 
342
321
  if (parseOutput) {
@@ -352,7 +331,7 @@ const functionsGetTemplate = async ({templateId,parseOutput = true, overrideForC
352
331
  }
353
332
 
354
333
  /**
355
- * @typedef {Object} FunctionsGetUsageRequestParams
334
+ * @typedef {Object} FunctionsListUsageRequestParams
356
335
  * @property {FunctionUsageRange} range Date range.
357
336
  * @property {boolean} overrideForCli
358
337
  * @property {boolean} parseOutput
@@ -360,9 +339,9 @@ const functionsGetTemplate = async ({templateId,parseOutput = true, overrideForC
360
339
  */
361
340
 
362
341
  /**
363
- * @param {FunctionsGetUsageRequestParams} params
342
+ * @param {FunctionsListUsageRequestParams} params
364
343
  */
365
- const functionsGetUsage = async ({range,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
344
+ const functionsListUsage = async ({range,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
366
345
  let client = !sdk ? await sdkForProject() :
367
346
  sdk;
368
347
  let apiPath = '/functions/usage';
@@ -374,11 +353,14 @@ const functionsGetUsage = async ({range,parseOutput = true, overrideForCli = fal
374
353
  let response = undefined;
375
354
 
376
355
  response = await client.call('get', apiPath, {
377
- 'content-type': 'application/json',
378
356
  }, payload);
379
357
 
380
358
  if (parseOutput) {
381
- parse(response)
359
+ if(console) {
360
+ showConsoleLink('functions', 'listUsage');
361
+ } else {
362
+ parse(response)
363
+ }
382
364
  }
383
365
 
384
366
  return response;
@@ -405,7 +387,6 @@ const functionsGet = async ({functionId,parseOutput = true, overrideForCli = fal
405
387
  let response = undefined;
406
388
 
407
389
  response = await client.call('get', apiPath, {
408
- 'content-type': 'application/json',
409
390
  }, payload);
410
391
 
411
392
  if (parseOutput) {
@@ -430,7 +411,7 @@ const functionsGet = async ({functionId,parseOutput = true, overrideForCli = fal
430
411
  * @property {string} schedule Schedule CRON syntax.
431
412
  * @property {number} timeout Maximum execution time in seconds.
432
413
  * @property {boolean} enabled Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.
433
- * @property {boolean} logging Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.
414
+ * @property {boolean} logging When disabled, executions will exclude logs and errors, and will be slightly faster.
434
415
  * @property {string} entrypoint Entrypoint File. This path is relative to the "providerRootDirectory".
435
416
  * @property {string} commands Build Commands.
436
417
  * @property {string[]} scopes List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed.
@@ -553,10 +534,45 @@ const functionsDelete = async ({functionId,parseOutput = true, overrideForCli =
553
534
 
554
535
  }
555
536
 
537
+ /**
538
+ * @typedef {Object} FunctionsUpdateFunctionDeploymentRequestParams
539
+ * @property {string} functionId Function ID.
540
+ * @property {string} deploymentId Deployment ID.
541
+ * @property {boolean} overrideForCli
542
+ * @property {boolean} parseOutput
543
+ * @property {libClient | undefined} sdk
544
+ */
545
+
546
+ /**
547
+ * @param {FunctionsUpdateFunctionDeploymentRequestParams} params
548
+ */
549
+ const functionsUpdateFunctionDeployment = async ({functionId,deploymentId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
550
+ let client = !sdk ? await sdkForProject() :
551
+ sdk;
552
+ let apiPath = '/functions/{functionId}/deployment'.replace('{functionId}', functionId);
553
+ let payload = {};
554
+ if (typeof deploymentId !== 'undefined') {
555
+ payload['deploymentId'] = deploymentId;
556
+ }
557
+
558
+ let response = undefined;
559
+
560
+ response = await client.call('patch', apiPath, {
561
+ 'content-type': 'application/json',
562
+ }, payload);
563
+
564
+ if (parseOutput) {
565
+ parse(response)
566
+ }
567
+
568
+ return response;
569
+
570
+ }
571
+
556
572
  /**
557
573
  * @typedef {Object} FunctionsListDeploymentsRequestParams
558
574
  * @property {string} functionId Function ID.
559
- * @property {string[]} 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: size, buildId, activate, entrypoint, commands, type, size
575
+ * @property {string[]} 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: buildSize, sourceSize, totalSize, buildDuration, status, activate, type
560
576
  * @property {string} search Search term to filter your list results. Max length: 256 chars.
561
577
  * @property {boolean} overrideForCli
562
578
  * @property {boolean} parseOutput
@@ -581,7 +597,6 @@ const functionsListDeployments = async ({functionId,queries,search,parseOutput =
581
597
  let response = undefined;
582
598
 
583
599
  response = await client.call('get', apiPath, {
584
- 'content-type': 'application/json',
585
600
  }, payload);
586
601
 
587
602
  if (parseOutput) {
@@ -630,19 +645,20 @@ const functionsCreateDeployment = async ({functionId,code,activate,entrypoint,co
630
645
 
631
646
  const ignorer = ignore();
632
647
 
633
- const func = localConfig.getFunction(functionId);
648
+ const resourceId = functionId;
649
+ const resourceConfig = localConfig.getFunction(resourceId);
634
650
 
635
651
  ignorer.add('.appwrite');
636
652
 
637
- if (func.ignore) {
638
- ignorer.add(func.ignore);
653
+ if (resourceConfig.ignore) {
654
+ ignorer.add(resourceConfig.ignore);
639
655
  } else if (fs.existsSync(pathLib.join(code, '.gitignore'))) {
640
656
  ignorer.add(fs.readFileSync(pathLib.join(code, '.gitignore')).toString());
641
657
  }
642
658
 
643
659
  const files = getAllFiles(code).map((file) => pathLib.relative(code, file)).filter((file) => !ignorer.ignores(file));
644
660
 
645
- const archiveFileName = `${functionId}-code.tar.gz`;
661
+ const archiveFileName = `functions-${resourceId}-code.tar.gz`;
646
662
 
647
663
  await tar
648
664
  .create({
@@ -761,35 +777,38 @@ const functionsCreateDeployment = async ({functionId,code,activate,entrypoint,co
761
777
  }
762
778
 
763
779
  /**
764
- * @typedef {Object} FunctionsGetDeploymentRequestParams
780
+ * @typedef {Object} FunctionsCreateDuplicateDeploymentRequestParams
765
781
  * @property {string} functionId Function ID.
766
782
  * @property {string} deploymentId Deployment ID.
783
+ * @property {string} buildId Build unique ID.
767
784
  * @property {boolean} overrideForCli
768
785
  * @property {boolean} parseOutput
769
786
  * @property {libClient | undefined} sdk
770
787
  */
771
788
 
772
789
  /**
773
- * @param {FunctionsGetDeploymentRequestParams} params
790
+ * @param {FunctionsCreateDuplicateDeploymentRequestParams} params
774
791
  */
775
- const functionsGetDeployment = async ({functionId,deploymentId,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
792
+ const functionsCreateDuplicateDeployment = async ({functionId,deploymentId,buildId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
776
793
  let client = !sdk ? await sdkForProject() :
777
794
  sdk;
778
- let apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
795
+ let apiPath = '/functions/{functionId}/deployments/duplicate'.replace('{functionId}', functionId);
779
796
  let payload = {};
797
+ if (typeof deploymentId !== 'undefined') {
798
+ payload['deploymentId'] = deploymentId;
799
+ }
800
+ if (typeof buildId !== 'undefined') {
801
+ payload['buildId'] = buildId;
802
+ }
780
803
 
781
804
  let response = undefined;
782
805
 
783
- response = await client.call('get', apiPath, {
806
+ response = await client.call('post', apiPath, {
784
807
  'content-type': 'application/json',
785
808
  }, payload);
786
809
 
787
810
  if (parseOutput) {
788
- if(console) {
789
- showConsoleLink('functions', 'getDeployment', functionId, deploymentId);
790
- } else {
791
- parse(response)
792
- }
811
+ parse(response)
793
812
  }
794
813
 
795
814
  return response;
@@ -797,26 +816,45 @@ const functionsGetDeployment = async ({functionId,deploymentId,parseOutput = tru
797
816
  }
798
817
 
799
818
  /**
800
- * @typedef {Object} FunctionsUpdateDeploymentRequestParams
819
+ * @typedef {Object} FunctionsCreateTemplateDeploymentRequestParams
801
820
  * @property {string} functionId Function ID.
802
- * @property {string} deploymentId Deployment ID.
821
+ * @property {string} repository Repository name of the template.
822
+ * @property {string} owner The name of the owner of the template.
823
+ * @property {string} rootDirectory Path to function code in the template repo.
824
+ * @property {string} version Version (tag) for the repo linked to the function template.
825
+ * @property {boolean} activate Automatically activate the deployment when it is finished building.
803
826
  * @property {boolean} overrideForCli
804
827
  * @property {boolean} parseOutput
805
828
  * @property {libClient | undefined} sdk
806
829
  */
807
830
 
808
831
  /**
809
- * @param {FunctionsUpdateDeploymentRequestParams} params
832
+ * @param {FunctionsCreateTemplateDeploymentRequestParams} params
810
833
  */
811
- const functionsUpdateDeployment = async ({functionId,deploymentId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
834
+ const functionsCreateTemplateDeployment = async ({functionId,repository,owner,rootDirectory,version,activate,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
812
835
  let client = !sdk ? await sdkForProject() :
813
836
  sdk;
814
- let apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
837
+ let apiPath = '/functions/{functionId}/deployments/template'.replace('{functionId}', functionId);
815
838
  let payload = {};
839
+ if (typeof repository !== 'undefined') {
840
+ payload['repository'] = repository;
841
+ }
842
+ if (typeof owner !== 'undefined') {
843
+ payload['owner'] = owner;
844
+ }
845
+ if (typeof rootDirectory !== 'undefined') {
846
+ payload['rootDirectory'] = rootDirectory;
847
+ }
848
+ if (typeof version !== 'undefined') {
849
+ payload['version'] = version;
850
+ }
851
+ if (typeof activate !== 'undefined') {
852
+ payload['activate'] = activate;
853
+ }
816
854
 
817
855
  let response = undefined;
818
856
 
819
- response = await client.call('patch', apiPath, {
857
+ response = await client.call('post', apiPath, {
820
858
  'content-type': 'application/json',
821
859
  }, payload);
822
860
 
@@ -829,26 +867,37 @@ const functionsUpdateDeployment = async ({functionId,deploymentId,parseOutput =
829
867
  }
830
868
 
831
869
  /**
832
- * @typedef {Object} FunctionsDeleteDeploymentRequestParams
870
+ * @typedef {Object} FunctionsCreateVcsDeploymentRequestParams
833
871
  * @property {string} functionId Function ID.
834
- * @property {string} deploymentId Deployment ID.
872
+ * @property {VCSDeploymentType} type Type of reference passed. Allowed values are: branch, commit
873
+ * @property {string} reference VCS reference to create deployment from. Depending on type this can be: branch name, commit hash
874
+ * @property {boolean} activate Automatically activate the deployment when it is finished building.
835
875
  * @property {boolean} overrideForCli
836
876
  * @property {boolean} parseOutput
837
877
  * @property {libClient | undefined} sdk
838
878
  */
839
879
 
840
880
  /**
841
- * @param {FunctionsDeleteDeploymentRequestParams} params
881
+ * @param {FunctionsCreateVcsDeploymentRequestParams} params
842
882
  */
843
- const functionsDeleteDeployment = async ({functionId,deploymentId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
883
+ const functionsCreateVcsDeployment = async ({functionId,type,reference,activate,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
844
884
  let client = !sdk ? await sdkForProject() :
845
885
  sdk;
846
- let apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
886
+ let apiPath = '/functions/{functionId}/deployments/vcs'.replace('{functionId}', functionId);
847
887
  let payload = {};
888
+ if (typeof type !== 'undefined') {
889
+ payload['type'] = type;
890
+ }
891
+ if (typeof reference !== 'undefined') {
892
+ payload['reference'] = reference;
893
+ }
894
+ if (typeof activate !== 'undefined') {
895
+ payload['activate'] = activate;
896
+ }
848
897
 
849
898
  let response = undefined;
850
899
 
851
- response = await client.call('delete', apiPath, {
900
+ response = await client.call('post', apiPath, {
852
901
  'content-type': 'application/json',
853
902
  }, payload);
854
903
 
@@ -861,35 +910,34 @@ const functionsDeleteDeployment = async ({functionId,deploymentId,parseOutput =
861
910
  }
862
911
 
863
912
  /**
864
- * @typedef {Object} FunctionsCreateBuildRequestParams
913
+ * @typedef {Object} FunctionsGetDeploymentRequestParams
865
914
  * @property {string} functionId Function ID.
866
915
  * @property {string} deploymentId Deployment ID.
867
- * @property {string} buildId Build unique ID.
868
916
  * @property {boolean} overrideForCli
869
917
  * @property {boolean} parseOutput
870
918
  * @property {libClient | undefined} sdk
871
919
  */
872
920
 
873
921
  /**
874
- * @param {FunctionsCreateBuildRequestParams} params
922
+ * @param {FunctionsGetDeploymentRequestParams} params
875
923
  */
876
- const functionsCreateBuild = async ({functionId,deploymentId,buildId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
924
+ const functionsGetDeployment = async ({functionId,deploymentId,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
877
925
  let client = !sdk ? await sdkForProject() :
878
926
  sdk;
879
- let apiPath = '/functions/{functionId}/deployments/{deploymentId}/build'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
927
+ let apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
880
928
  let payload = {};
881
- if (typeof buildId !== 'undefined') {
882
- payload['buildId'] = buildId;
883
- }
884
929
 
885
930
  let response = undefined;
886
931
 
887
- response = await client.call('post', apiPath, {
888
- 'content-type': 'application/json',
932
+ response = await client.call('get', apiPath, {
889
933
  }, payload);
890
934
 
891
935
  if (parseOutput) {
892
- parse(response)
936
+ if(console) {
937
+ showConsoleLink('functions', 'getDeployment', functionId, deploymentId);
938
+ } else {
939
+ parse(response)
940
+ }
893
941
  }
894
942
 
895
943
  return response;
@@ -897,7 +945,7 @@ const functionsCreateBuild = async ({functionId,deploymentId,buildId,parseOutput
897
945
  }
898
946
 
899
947
  /**
900
- * @typedef {Object} FunctionsUpdateDeploymentBuildRequestParams
948
+ * @typedef {Object} FunctionsDeleteDeploymentRequestParams
901
949
  * @property {string} functionId Function ID.
902
950
  * @property {string} deploymentId Deployment ID.
903
951
  * @property {boolean} overrideForCli
@@ -906,17 +954,17 @@ const functionsCreateBuild = async ({functionId,deploymentId,buildId,parseOutput
906
954
  */
907
955
 
908
956
  /**
909
- * @param {FunctionsUpdateDeploymentBuildRequestParams} params
957
+ * @param {FunctionsDeleteDeploymentRequestParams} params
910
958
  */
911
- const functionsUpdateDeploymentBuild = async ({functionId,deploymentId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
959
+ const functionsDeleteDeployment = async ({functionId,deploymentId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
912
960
  let client = !sdk ? await sdkForProject() :
913
961
  sdk;
914
- let apiPath = '/functions/{functionId}/deployments/{deploymentId}/build'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
962
+ let apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
915
963
  let payload = {};
916
964
 
917
965
  let response = undefined;
918
966
 
919
- response = await client.call('patch', apiPath, {
967
+ response = await client.call('delete', apiPath, {
920
968
  'content-type': 'application/json',
921
969
  }, payload);
922
970
 
@@ -932,6 +980,7 @@ const functionsUpdateDeploymentBuild = async ({functionId,deploymentId,parseOutp
932
980
  * @typedef {Object} FunctionsGetDeploymentDownloadRequestParams
933
981
  * @property {string} functionId Function ID.
934
982
  * @property {string} deploymentId Deployment ID.
983
+ * @property {DeploymentDownloadType} type Deployment file to download. Can be: "source", "output".
935
984
  * @property {boolean} overrideForCli
936
985
  * @property {boolean} parseOutput
937
986
  * @property {libClient | undefined} sdk
@@ -941,11 +990,14 @@ const functionsUpdateDeploymentBuild = async ({functionId,deploymentId,parseOutp
941
990
  /**
942
991
  * @param {FunctionsGetDeploymentDownloadRequestParams} params
943
992
  */
944
- const functionsGetDeploymentDownload = async ({functionId,deploymentId,parseOutput = true, overrideForCli = false, sdk = undefined, destination, console}) => {
993
+ const functionsGetDeploymentDownload = async ({functionId,deploymentId,type,parseOutput = true, overrideForCli = false, sdk = undefined, destination, console}) => {
945
994
  let client = !sdk ? await sdkForProject() :
946
995
  sdk;
947
996
  let apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
948
997
  let payload = {};
998
+ if (typeof type !== 'undefined') {
999
+ payload['type'] = type;
1000
+ }
949
1001
  if (!overrideForCli) {
950
1002
  payload['project'] = localConfig.getProject().projectId
951
1003
  payload['key'] = globalConfig.getKey();
@@ -956,7 +1008,6 @@ const functionsGetDeploymentDownload = async ({functionId,deploymentId,parseOutp
956
1008
  let response = undefined;
957
1009
 
958
1010
  response = await client.call('get', apiPath, {
959
- 'content-type': 'application/json',
960
1011
  }, payload, 'arraybuffer');
961
1012
 
962
1013
  if (overrideForCli) {
@@ -976,11 +1027,42 @@ const functionsGetDeploymentDownload = async ({functionId,deploymentId,parseOutp
976
1027
 
977
1028
  }
978
1029
 
1030
+ /**
1031
+ * @typedef {Object} FunctionsUpdateDeploymentStatusRequestParams
1032
+ * @property {string} functionId Function ID.
1033
+ * @property {string} deploymentId Deployment ID.
1034
+ * @property {boolean} overrideForCli
1035
+ * @property {boolean} parseOutput
1036
+ * @property {libClient | undefined} sdk
1037
+ */
1038
+
1039
+ /**
1040
+ * @param {FunctionsUpdateDeploymentStatusRequestParams} params
1041
+ */
1042
+ const functionsUpdateDeploymentStatus = async ({functionId,deploymentId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
1043
+ let client = !sdk ? await sdkForProject() :
1044
+ sdk;
1045
+ let apiPath = '/functions/{functionId}/deployments/{deploymentId}/status'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
1046
+ let payload = {};
1047
+
1048
+ let response = undefined;
1049
+
1050
+ response = await client.call('patch', apiPath, {
1051
+ 'content-type': 'application/json',
1052
+ }, payload);
1053
+
1054
+ if (parseOutput) {
1055
+ parse(response)
1056
+ }
1057
+
1058
+ return response;
1059
+
1060
+ }
1061
+
979
1062
  /**
980
1063
  * @typedef {Object} FunctionsListExecutionsRequestParams
981
1064
  * @property {string} functionId Function ID.
982
1065
  * @property {string[]} 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: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId
983
- * @property {string} search Search term to filter your list results. Max length: 256 chars.
984
1066
  * @property {boolean} overrideForCli
985
1067
  * @property {boolean} parseOutput
986
1068
  * @property {libClient | undefined} sdk
@@ -989,7 +1071,7 @@ const functionsGetDeploymentDownload = async ({functionId,deploymentId,parseOutp
989
1071
  /**
990
1072
  * @param {FunctionsListExecutionsRequestParams} params
991
1073
  */
992
- const functionsListExecutions = async ({functionId,queries,search,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
1074
+ const functionsListExecutions = async ({functionId,queries,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
993
1075
  let client = !sdk ? await sdkForProject() :
994
1076
  sdk;
995
1077
  let apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
@@ -997,14 +1079,10 @@ const functionsListExecutions = async ({functionId,queries,search,parseOutput =
997
1079
  if (typeof queries !== 'undefined') {
998
1080
  payload['queries'] = queries;
999
1081
  }
1000
- if (typeof search !== 'undefined') {
1001
- payload['search'] = search;
1002
- }
1003
1082
 
1004
1083
  let response = undefined;
1005
1084
 
1006
1085
  response = await client.call('get', apiPath, {
1007
- 'content-type': 'application/json',
1008
1086
  }, payload);
1009
1087
 
1010
1088
  if (parseOutput) {
@@ -1095,7 +1173,6 @@ const functionsGetExecution = async ({functionId,executionId,parseOutput = true,
1095
1173
  let response = undefined;
1096
1174
 
1097
1175
  response = await client.call('get', apiPath, {
1098
- 'content-type': 'application/json',
1099
1176
  }, payload);
1100
1177
 
1101
1178
  if (parseOutput) {
@@ -1143,7 +1220,7 @@ const functionsDeleteExecution = async ({functionId,executionId,parseOutput = tr
1143
1220
  }
1144
1221
 
1145
1222
  /**
1146
- * @typedef {Object} FunctionsGetFunctionUsageRequestParams
1223
+ * @typedef {Object} FunctionsGetUsageRequestParams
1147
1224
  * @property {string} functionId Function ID.
1148
1225
  * @property {FunctionUsageRange} range Date range.
1149
1226
  * @property {boolean} overrideForCli
@@ -1152,9 +1229,9 @@ const functionsDeleteExecution = async ({functionId,executionId,parseOutput = tr
1152
1229
  */
1153
1230
 
1154
1231
  /**
1155
- * @param {FunctionsGetFunctionUsageRequestParams} params
1232
+ * @param {FunctionsGetUsageRequestParams} params
1156
1233
  */
1157
- const functionsGetFunctionUsage = async ({functionId,range,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
1234
+ const functionsGetUsage = async ({functionId,range,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
1158
1235
  let client = !sdk ? await sdkForProject() :
1159
1236
  sdk;
1160
1237
  let apiPath = '/functions/{functionId}/usage'.replace('{functionId}', functionId);
@@ -1166,15 +1243,10 @@ const functionsGetFunctionUsage = async ({functionId,range,parseOutput = true, o
1166
1243
  let response = undefined;
1167
1244
 
1168
1245
  response = await client.call('get', apiPath, {
1169
- 'content-type': 'application/json',
1170
1246
  }, payload);
1171
1247
 
1172
1248
  if (parseOutput) {
1173
- if(console) {
1174
- showConsoleLink('functions', 'getFunctionUsage', functionId);
1175
- } else {
1176
- parse(response)
1177
- }
1249
+ parse(response)
1178
1250
  }
1179
1251
 
1180
1252
  return response;
@@ -1201,7 +1273,6 @@ const functionsListVariables = async ({functionId,parseOutput = true, overrideFo
1201
1273
  let response = undefined;
1202
1274
 
1203
1275
  response = await client.call('get', apiPath, {
1204
- 'content-type': 'application/json',
1205
1276
  }, payload);
1206
1277
 
1207
1278
  if (parseOutput) {
@@ -1217,6 +1288,7 @@ const functionsListVariables = async ({functionId,parseOutput = true, overrideFo
1217
1288
  * @property {string} functionId Function unique ID.
1218
1289
  * @property {string} key Variable key. Max length: 255 chars.
1219
1290
  * @property {string} value Variable value. Max length: 8192 chars.
1291
+ * @property {boolean} secret Secret variables can be updated or deleted, but only functions can read them during build and runtime.
1220
1292
  * @property {boolean} overrideForCli
1221
1293
  * @property {boolean} parseOutput
1222
1294
  * @property {libClient | undefined} sdk
@@ -1225,7 +1297,7 @@ const functionsListVariables = async ({functionId,parseOutput = true, overrideFo
1225
1297
  /**
1226
1298
  * @param {FunctionsCreateVariableRequestParams} params
1227
1299
  */
1228
- const functionsCreateVariable = async ({functionId,key,value,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
1300
+ const functionsCreateVariable = async ({functionId,key,value,secret,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
1229
1301
  let client = !sdk ? await sdkForProject() :
1230
1302
  sdk;
1231
1303
  let apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
@@ -1236,6 +1308,9 @@ const functionsCreateVariable = async ({functionId,key,value,parseOutput = true,
1236
1308
  if (typeof value !== 'undefined') {
1237
1309
  payload['value'] = value;
1238
1310
  }
1311
+ if (typeof secret !== 'undefined') {
1312
+ payload['secret'] = secret;
1313
+ }
1239
1314
 
1240
1315
  let response = undefined;
1241
1316
 
@@ -1272,7 +1347,6 @@ const functionsGetVariable = async ({functionId,variableId,parseOutput = true, o
1272
1347
  let response = undefined;
1273
1348
 
1274
1349
  response = await client.call('get', apiPath, {
1275
- 'content-type': 'application/json',
1276
1350
  }, payload);
1277
1351
 
1278
1352
  if (parseOutput) {
@@ -1289,6 +1363,7 @@ const functionsGetVariable = async ({functionId,variableId,parseOutput = true, o
1289
1363
  * @property {string} variableId Variable unique ID.
1290
1364
  * @property {string} key Variable key. Max length: 255 chars.
1291
1365
  * @property {string} value Variable value. Max length: 8192 chars.
1366
+ * @property {boolean} secret Secret variables can be updated or deleted, but only functions can read them during build and runtime.
1292
1367
  * @property {boolean} overrideForCli
1293
1368
  * @property {boolean} parseOutput
1294
1369
  * @property {libClient | undefined} sdk
@@ -1297,7 +1372,7 @@ const functionsGetVariable = async ({functionId,variableId,parseOutput = true, o
1297
1372
  /**
1298
1373
  * @param {FunctionsUpdateVariableRequestParams} params
1299
1374
  */
1300
- const functionsUpdateVariable = async ({functionId,variableId,key,value,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
1375
+ const functionsUpdateVariable = async ({functionId,variableId,key,value,secret,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
1301
1376
  let client = !sdk ? await sdkForProject() :
1302
1377
  sdk;
1303
1378
  let apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
@@ -1308,6 +1383,9 @@ const functionsUpdateVariable = async ({functionId,variableId,key,value,parseOut
1308
1383
  if (typeof value !== 'undefined') {
1309
1384
  payload['value'] = value;
1310
1385
  }
1386
+ if (typeof secret !== 'undefined') {
1387
+ payload['secret'] = secret;
1388
+ }
1311
1389
 
1312
1390
  let response = undefined;
1313
1391
 
@@ -1358,7 +1436,7 @@ const functionsDeleteVariable = async ({functionId,variableId,parseOutput = true
1358
1436
  functions
1359
1437
  .command(`list`)
1360
1438
  .description(`Get a list of all the project's functions. You can use the query params to filter your results.`)
1361
- .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, enabled, runtime, deployment, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId`)
1439
+ .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, enabled, runtime, deploymentId, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId`)
1362
1440
  .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
1363
1441
  .option(`--console`, `Get the resource console url`)
1364
1442
  .action(actionRunner(functionsList))
@@ -1373,20 +1451,16 @@ functions
1373
1451
  .option(`--events [events...]`, `Events list. Maximum of 100 events are allowed.`)
1374
1452
  .option(`--schedule <schedule>`, `Schedule CRON syntax.`)
1375
1453
  .option(`--timeout <timeout>`, `Function maximum execution time in seconds.`, parseInteger)
1376
- .option(`--enabled <enabled>`, `Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.`, parseBool)
1377
- .option(`--logging <logging>`, `Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.`, parseBool)
1454
+ .option(`--enabled [value]`, `Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.`, (value) => value === undefined ? true : parseBool(value))
1455
+ .option(`--logging [value]`, `When disabled, executions will exclude logs and errors, and will be slightly faster.`, (value) => value === undefined ? true : parseBool(value))
1378
1456
  .option(`--entrypoint <entrypoint>`, `Entrypoint File. This path is relative to the "providerRootDirectory".`)
1379
1457
  .option(`--commands <commands>`, `Build Commands.`)
1380
1458
  .option(`--scopes [scopes...]`, `List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed.`)
1381
1459
  .option(`--installation-id <installation-id>`, `Appwrite Installation ID for VCS (Version Control System) deployment.`)
1382
1460
  .option(`--provider-repository-id <provider-repository-id>`, `Repository ID of the repo linked to the function.`)
1383
1461
  .option(`--provider-branch <provider-branch>`, `Production branch for the repo linked to the function.`)
1384
- .option(`--provider-silent-mode <provider-silent-mode>`, `Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.`, parseBool)
1462
+ .option(`--provider-silent-mode [value]`, `Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.`, (value) => value === undefined ? true : parseBool(value))
1385
1463
  .option(`--provider-root-directory <provider-root-directory>`, `Path to function code in the linked repo.`)
1386
- .option(`--template-repository <template-repository>`, `Repository name of the template.`)
1387
- .option(`--template-owner <template-owner>`, `The name of the owner of the template.`)
1388
- .option(`--template-root-directory <template-root-directory>`, `Path to function code in the template repo.`)
1389
- .option(`--template-version <template-version>`, `Version (tag) for the repo linked to the function template.`)
1390
1464
  .option(`--specification <specification>`, `Runtime specification for the function and builds.`)
1391
1465
  .action(actionRunner(functionsCreate))
1392
1466
 
@@ -1397,7 +1471,7 @@ functions
1397
1471
 
1398
1472
  functions
1399
1473
  .command(`list-specifications`)
1400
- .description(`List allowed function specifications for this instance. `)
1474
+ .description(`List allowed function specifications for this instance.`)
1401
1475
  .option(`--console`, `Get the resource console url`)
1402
1476
  .action(actionRunner(functionsListSpecifications))
1403
1477
 
@@ -1419,10 +1493,11 @@ functions
1419
1493
  .action(actionRunner(functionsGetTemplate))
1420
1494
 
1421
1495
  functions
1422
- .command(`get-usage`)
1423
- .description(`Get usage metrics and statistics for a for all functions. View statistics including total functions, deployments, builds, executions, storage usage, and compute time. The response includes both current totals and historical data for each metric. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, defaults to 30 days.`)
1496
+ .command(`list-usage`)
1497
+ .description(`Get usage metrics and statistics for all functions in the project. View statistics including total deployments, builds, logs, storage usage, and compute time. The response includes both current totals and historical data for each metric. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, defaults to 30 days.`)
1424
1498
  .option(`--range <range>`, `Date range.`)
1425
- .action(actionRunner(functionsGetUsage))
1499
+ .option(`--console`, `Get the resource console url`)
1500
+ .action(actionRunner(functionsListUsage))
1426
1501
 
1427
1502
  functions
1428
1503
  .command(`get`)
@@ -1441,15 +1516,15 @@ functions
1441
1516
  .option(`--events [events...]`, `Events list. Maximum of 100 events are allowed.`)
1442
1517
  .option(`--schedule <schedule>`, `Schedule CRON syntax.`)
1443
1518
  .option(`--timeout <timeout>`, `Maximum execution time in seconds.`, parseInteger)
1444
- .option(`--enabled <enabled>`, `Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.`, parseBool)
1445
- .option(`--logging <logging>`, `Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.`, parseBool)
1519
+ .option(`--enabled [value]`, `Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.`, (value) => value === undefined ? true : parseBool(value))
1520
+ .option(`--logging [value]`, `When disabled, executions will exclude logs and errors, and will be slightly faster.`, (value) => value === undefined ? true : parseBool(value))
1446
1521
  .option(`--entrypoint <entrypoint>`, `Entrypoint File. This path is relative to the "providerRootDirectory".`)
1447
1522
  .option(`--commands <commands>`, `Build Commands.`)
1448
1523
  .option(`--scopes [scopes...]`, `List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed.`)
1449
1524
  .option(`--installation-id <installation-id>`, `Appwrite Installation ID for VCS (Version Controle System) deployment.`)
1450
1525
  .option(`--provider-repository-id <provider-repository-id>`, `Repository ID of the repo linked to the function`)
1451
1526
  .option(`--provider-branch <provider-branch>`, `Production branch for the repo linked to the function`)
1452
- .option(`--provider-silent-mode <provider-silent-mode>`, `Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.`, parseBool)
1527
+ .option(`--provider-silent-mode [value]`, `Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.`, (value) => value === undefined ? true : parseBool(value))
1453
1528
  .option(`--provider-root-directory <provider-root-directory>`, `Path to function code in the linked repo.`)
1454
1529
  .option(`--specification <specification>`, `Runtime specification for the function and builds.`)
1455
1530
  .action(actionRunner(functionsUpdate))
@@ -1460,11 +1535,18 @@ functions
1460
1535
  .requiredOption(`--function-id <function-id>`, `Function ID.`)
1461
1536
  .action(actionRunner(functionsDelete))
1462
1537
 
1538
+ functions
1539
+ .command(`update-function-deployment`)
1540
+ .description(`Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function.`)
1541
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1542
+ .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1543
+ .action(actionRunner(functionsUpdateFunctionDeployment))
1544
+
1463
1545
  functions
1464
1546
  .command(`list-deployments`)
1465
- .description(`Get a list of all the project's code deployments. You can use the query params to filter your results.`)
1547
+ .description(`Get a list of all the function's code deployments. You can use the query params to filter your results.`)
1466
1548
  .requiredOption(`--function-id <function-id>`, `Function ID.`)
1467
- .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: size, buildId, activate, entrypoint, commands, type, size`)
1549
+ .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: buildSize, sourceSize, totalSize, buildDuration, status, activate, type`)
1468
1550
  .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
1469
1551
  .option(`--console`, `Get the resource console url`)
1470
1552
  .action(actionRunner(functionsListDeployments))
@@ -1474,63 +1556,76 @@ functions
1474
1556
  .description(`Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](https://appwrite.io/docs/functions). Use the "command" param to set the entrypoint used to execute your code.`)
1475
1557
  .requiredOption(`--function-id <function-id>`, `Function ID.`)
1476
1558
  .requiredOption(`--code <code>`, `Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.`)
1477
- .requiredOption(`--activate <activate>`, `Automatically activate the deployment when it is finished building.`, parseBool)
1559
+ .requiredOption(`--activate [value]`, `Automatically activate the deployment when it is finished building.`, (value) => value === undefined ? true : parseBool(value))
1478
1560
  .option(`--entrypoint <entrypoint>`, `Entrypoint File.`)
1479
1561
  .option(`--commands <commands>`, `Build Commands.`)
1480
1562
  .action(actionRunner(functionsCreateDeployment))
1481
1563
 
1482
1564
  functions
1483
- .command(`get-deployment`)
1484
- .description(`Get a code deployment by its unique ID.`)
1565
+ .command(`create-duplicate-deployment`)
1566
+ .description(`Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build.`)
1485
1567
  .requiredOption(`--function-id <function-id>`, `Function ID.`)
1486
1568
  .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1487
- .option(`--console`, `Get the resource console url`)
1488
- .action(actionRunner(functionsGetDeployment))
1569
+ .option(`--build-id <build-id>`, `Build unique ID.`)
1570
+ .action(actionRunner(functionsCreateDuplicateDeployment))
1489
1571
 
1490
1572
  functions
1491
- .command(`update-deployment`)
1492
- .description(`Update the function code deployment ID using the unique function ID. Use this endpoint to switch the code deployment that should be executed by the execution endpoint.`)
1573
+ .command(`create-template-deployment`)
1574
+ .description(`Create a deployment based on a template. Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to find the template details.`)
1493
1575
  .requiredOption(`--function-id <function-id>`, `Function ID.`)
1494
- .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1495
- .action(actionRunner(functionsUpdateDeployment))
1576
+ .requiredOption(`--repository <repository>`, `Repository name of the template.`)
1577
+ .requiredOption(`--owner <owner>`, `The name of the owner of the template.`)
1578
+ .requiredOption(`--root-directory <root-directory>`, `Path to function code in the template repo.`)
1579
+ .requiredOption(`--version <version>`, `Version (tag) for the repo linked to the function template.`)
1580
+ .option(`--activate [value]`, `Automatically activate the deployment when it is finished building.`, (value) => value === undefined ? true : parseBool(value))
1581
+ .action(actionRunner(functionsCreateTemplateDeployment))
1496
1582
 
1497
1583
  functions
1498
- .command(`delete-deployment`)
1499
- .description(`Delete a code deployment by its unique ID.`)
1584
+ .command(`create-vcs-deployment`)
1585
+ .description(`Create a deployment when a function is connected to VCS. This endpoint lets you create deployment from a branch, commit, or a tag.`)
1500
1586
  .requiredOption(`--function-id <function-id>`, `Function ID.`)
1501
- .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1502
- .action(actionRunner(functionsDeleteDeployment))
1587
+ .requiredOption(`--type <type>`, `Type of reference passed. Allowed values are: branch, commit`)
1588
+ .requiredOption(`--reference <reference>`, `VCS reference to create deployment from. Depending on type this can be: branch name, commit hash`)
1589
+ .option(`--activate [value]`, `Automatically activate the deployment when it is finished building.`, (value) => value === undefined ? true : parseBool(value))
1590
+ .action(actionRunner(functionsCreateVcsDeployment))
1503
1591
 
1504
1592
  functions
1505
- .command(`create-build`)
1506
- .description(`Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build.`)
1593
+ .command(`get-deployment`)
1594
+ .description(`Get a function deployment by its unique ID.`)
1507
1595
  .requiredOption(`--function-id <function-id>`, `Function ID.`)
1508
1596
  .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1509
- .option(`--build-id <build-id>`, `Build unique ID.`)
1510
- .action(actionRunner(functionsCreateBuild))
1597
+ .option(`--console`, `Get the resource console url`)
1598
+ .action(actionRunner(functionsGetDeployment))
1511
1599
 
1512
1600
  functions
1513
- .command(`update-deployment-build`)
1514
- .description(`Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details.`)
1601
+ .command(`delete-deployment`)
1602
+ .description(`Delete a code deployment by its unique ID.`)
1515
1603
  .requiredOption(`--function-id <function-id>`, `Function ID.`)
1516
1604
  .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1517
- .action(actionRunner(functionsUpdateDeploymentBuild))
1605
+ .action(actionRunner(functionsDeleteDeployment))
1518
1606
 
1519
1607
  functions
1520
1608
  .command(`get-deployment-download`)
1521
- .description(`Get a Deployment's contents by its unique ID. This endpoint supports range requests for partial or streaming file download.`)
1609
+ .description(`Get a function deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory.`)
1522
1610
  .requiredOption(`--function-id <function-id>`, `Function ID.`)
1523
1611
  .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1612
+ .option(`--type <type>`, `Deployment file to download. Can be: "source", "output".`)
1524
1613
  .requiredOption(`--destination <path>`, `output file path.`)
1525
1614
  .option(`--console`, `Get the resource console url`)
1526
1615
  .action(actionRunner(functionsGetDeploymentDownload))
1527
1616
 
1617
+ functions
1618
+ .command(`update-deployment-status`)
1619
+ .description(`Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details.`)
1620
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1621
+ .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1622
+ .action(actionRunner(functionsUpdateDeploymentStatus))
1623
+
1528
1624
  functions
1529
1625
  .command(`list-executions`)
1530
1626
  .description(`Get a list of all the current user function execution logs. You can use the query params to filter your results.`)
1531
1627
  .requiredOption(`--function-id <function-id>`, `Function ID.`)
1532
1628
  .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: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId`)
1533
- .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
1534
1629
  .option(`--console`, `Get the resource console url`)
1535
1630
  .action(actionRunner(functionsListExecutions))
1536
1631
 
@@ -1539,7 +1634,7 @@ functions
1539
1634
  .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.`)
1540
1635
  .requiredOption(`--function-id <function-id>`, `Function ID.`)
1541
1636
  .option(`--body <body>`, `HTTP body of execution. Default value is empty string.`)
1542
- .option(`--async <async>`, `Execute code in the background. Default value is false.`, parseBool)
1637
+ .option(`--async [value]`, `Execute code in the background. Default value is false.`, (value) => value === undefined ? true : parseBool(value))
1543
1638
  .option(`--xpath <xpath>`, `HTTP path of execution. Path can include query params. Default value is /`)
1544
1639
  .option(`--method <method>`, `HTTP method of execution. Default value is GET.`)
1545
1640
  .option(`--headers <headers>`, `HTTP headers of execution. Defaults to empty.`)
@@ -1556,18 +1651,17 @@ functions
1556
1651
 
1557
1652
  functions
1558
1653
  .command(`delete-execution`)
1559
- .description(`Delete a function execution by its unique ID. `)
1654
+ .description(`Delete a function execution by its unique ID.`)
1560
1655
  .requiredOption(`--function-id <function-id>`, `Function ID.`)
1561
1656
  .requiredOption(`--execution-id <execution-id>`, `Execution ID.`)
1562
1657
  .action(actionRunner(functionsDeleteExecution))
1563
1658
 
1564
1659
  functions
1565
- .command(`get-function-usage`)
1660
+ .command(`get-usage`)
1566
1661
  .description(`Get usage metrics and statistics for a for a specific function. View statistics including total deployments, builds, executions, storage usage, and compute time. The response includes both current totals and historical data for each metric. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, defaults to 30 days.`)
1567
1662
  .requiredOption(`--function-id <function-id>`, `Function ID.`)
1568
1663
  .option(`--range <range>`, `Date range.`)
1569
- .option(`--console`, `Get the resource console url`)
1570
- .action(actionRunner(functionsGetFunctionUsage))
1664
+ .action(actionRunner(functionsGetUsage))
1571
1665
 
1572
1666
  functions
1573
1667
  .command(`list-variables`)
@@ -1581,6 +1675,7 @@ functions
1581
1675
  .requiredOption(`--function-id <function-id>`, `Function unique ID.`)
1582
1676
  .requiredOption(`--key <key>`, `Variable key. Max length: 255 chars.`)
1583
1677
  .requiredOption(`--value <value>`, `Variable value. Max length: 8192 chars.`)
1678
+ .option(`--secret [value]`, `Secret variables can be updated or deleted, but only functions can read them during build and runtime.`, (value) => value === undefined ? true : parseBool(value))
1584
1679
  .action(actionRunner(functionsCreateVariable))
1585
1680
 
1586
1681
  functions
@@ -1597,6 +1692,7 @@ functions
1597
1692
  .requiredOption(`--variable-id <variable-id>`, `Variable unique ID.`)
1598
1693
  .requiredOption(`--key <key>`, `Variable key. Max length: 255 chars.`)
1599
1694
  .option(`--value <value>`, `Variable value. Max length: 8192 chars.`)
1695
+ .option(`--secret [value]`, `Secret variables can be updated or deleted, but only functions can read them during build and runtime.`, (value) => value === undefined ? true : parseBool(value))
1600
1696
  .action(actionRunner(functionsUpdateVariable))
1601
1697
 
1602
1698
  functions
@@ -1614,23 +1710,25 @@ module.exports = {
1614
1710
  functionsListSpecifications,
1615
1711
  functionsListTemplates,
1616
1712
  functionsGetTemplate,
1617
- functionsGetUsage,
1713
+ functionsListUsage,
1618
1714
  functionsGet,
1619
1715
  functionsUpdate,
1620
1716
  functionsDelete,
1717
+ functionsUpdateFunctionDeployment,
1621
1718
  functionsListDeployments,
1622
1719
  functionsCreateDeployment,
1720
+ functionsCreateDuplicateDeployment,
1721
+ functionsCreateTemplateDeployment,
1722
+ functionsCreateVcsDeployment,
1623
1723
  functionsGetDeployment,
1624
- functionsUpdateDeployment,
1625
1724
  functionsDeleteDeployment,
1626
- functionsCreateBuild,
1627
- functionsUpdateDeploymentBuild,
1628
1725
  functionsGetDeploymentDownload,
1726
+ functionsUpdateDeploymentStatus,
1629
1727
  functionsListExecutions,
1630
1728
  functionsCreateExecution,
1631
1729
  functionsGetExecution,
1632
1730
  functionsDeleteExecution,
1633
- functionsGetFunctionUsage,
1731
+ functionsGetUsage,
1634
1732
  functionsListVariables,
1635
1733
  functionsCreateVariable,
1636
1734
  functionsGetVariable,