appwrite-cli 6.2.3 → 7.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 (106) 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-build.md → update-deployment-status.md} +1 -1
  19. package/docs/examples/functions/{update-deployment.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 +4 -0
  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/users.js +15 -17
  98. package/lib/commands/vcs.js +60 -53
  99. package/lib/config.js +50 -0
  100. package/lib/parser.js +2 -1
  101. package/lib/questions.js +110 -1
  102. package/package.json +1 -1
  103. package/scoop/appwrite.json +3 -3
  104. package/docs/examples/functions/get-function-usage.md +0 -3
  105. package/docs/examples/health/get-queue-stats-usage-dump.md +0 -2
  106. package/docs/examples/proxy/create-rule.md +0 -4
@@ -66,7 +66,6 @@ const storageListBuckets = async ({queries,search,parseOutput = true, overrideFo
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) {
@@ -173,7 +172,6 @@ const storageGetBucket = async ({bucketId,parseOutput = true, overrideForCli = f
173
172
  let response = undefined;
174
173
 
175
174
  response = await client.call('get', apiPath, {
176
- 'content-type': 'application/json',
177
175
  }, payload);
178
176
 
179
177
  if (parseOutput) {
@@ -316,7 +314,6 @@ const storageListFiles = async ({bucketId,queries,search,parseOutput = true, ove
316
314
  let response = undefined;
317
315
 
318
316
  response = await client.call('get', apiPath, {
319
- 'content-type': 'application/json',
320
317
  }, payload);
321
318
 
322
319
  if (parseOutput) {
@@ -485,7 +482,6 @@ const storageGetFile = async ({bucketId,fileId,parseOutput = true, overrideForCl
485
482
  let response = undefined;
486
483
 
487
484
  response = await client.call('get', apiPath, {
488
- 'content-type': 'application/json',
489
485
  }, payload);
490
486
 
491
487
  if (parseOutput) {
@@ -577,6 +573,7 @@ const storageDeleteFile = async ({bucketId,fileId,parseOutput = true, overrideFo
577
573
  * @typedef {Object} StorageGetFileDownloadRequestParams
578
574
  * @property {string} bucketId Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
579
575
  * @property {string} fileId File ID.
576
+ * @property {string} token File token for accessing this file.
580
577
  * @property {boolean} overrideForCli
581
578
  * @property {boolean} parseOutput
582
579
  * @property {libClient | undefined} sdk
@@ -586,11 +583,14 @@ const storageDeleteFile = async ({bucketId,fileId,parseOutput = true, overrideFo
586
583
  /**
587
584
  * @param {StorageGetFileDownloadRequestParams} params
588
585
  */
589
- const storageGetFileDownload = async ({bucketId,fileId,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
586
+ const storageGetFileDownload = async ({bucketId,fileId,token,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
590
587
  let client = !sdk ? await sdkForProject() :
591
588
  sdk;
592
589
  let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
593
590
  let payload = {};
591
+ if (typeof token !== 'undefined') {
592
+ payload['token'] = token;
593
+ }
594
594
  if (!overrideForCli) {
595
595
  payload['project'] = localConfig.getProject().projectId
596
596
  payload['key'] = globalConfig.getKey();
@@ -601,7 +601,6 @@ const storageGetFileDownload = async ({bucketId,fileId,parseOutput = true, overr
601
601
  let response = undefined;
602
602
 
603
603
  response = await client.call('get', apiPath, {
604
- 'content-type': 'application/json',
605
604
  }, payload, 'arraybuffer');
606
605
 
607
606
  if (overrideForCli) {
@@ -624,7 +623,7 @@ const storageGetFileDownload = async ({bucketId,fileId,parseOutput = true, overr
624
623
  * @property {number} width Resize preview image width, Pass an integer between 0 to 4000.
625
624
  * @property {number} height Resize preview image height, Pass an integer between 0 to 4000.
626
625
  * @property {ImageGravity} gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right
627
- * @property {number} quality Preview image quality. Pass an integer between 0 to 100. Defaults to 100.
626
+ * @property {number} quality Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
628
627
  * @property {number} borderWidth Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.
629
628
  * @property {string} borderColor Preview image border color. Use a valid HEX color, no # is needed for prefix.
630
629
  * @property {number} borderRadius Preview image border radius in pixels. Pass an integer between 0 to 4000.
@@ -632,6 +631,7 @@ const storageGetFileDownload = async ({bucketId,fileId,parseOutput = true, overr
632
631
  * @property {number} rotation Preview image rotation in degrees. Pass an integer between -360 and 360.
633
632
  * @property {string} background Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.
634
633
  * @property {ImageFormat} output Output format type (jpeg, jpg, png, gif and webp).
634
+ * @property {string} token File token for accessing this file.
635
635
  * @property {boolean} overrideForCli
636
636
  * @property {boolean} parseOutput
637
637
  * @property {libClient | undefined} sdk
@@ -641,7 +641,7 @@ const storageGetFileDownload = async ({bucketId,fileId,parseOutput = true, overr
641
641
  /**
642
642
  * @param {StorageGetFilePreviewRequestParams} params
643
643
  */
644
- const storageGetFilePreview = async ({bucketId,fileId,width,height,gravity,quality,borderWidth,borderColor,borderRadius,opacity,rotation,background,output,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
644
+ const storageGetFilePreview = async ({bucketId,fileId,width,height,gravity,quality,borderWidth,borderColor,borderRadius,opacity,rotation,background,output,token,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
645
645
  let client = !sdk ? await sdkForProject() :
646
646
  sdk;
647
647
  let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
@@ -679,6 +679,9 @@ const storageGetFilePreview = async ({bucketId,fileId,width,height,gravity,quali
679
679
  if (typeof output !== 'undefined') {
680
680
  payload['output'] = output;
681
681
  }
682
+ if (typeof token !== 'undefined') {
683
+ payload['token'] = token;
684
+ }
682
685
  if (!overrideForCli) {
683
686
  payload['project'] = localConfig.getProject().projectId
684
687
  payload['key'] = globalConfig.getKey();
@@ -689,7 +692,6 @@ const storageGetFilePreview = async ({bucketId,fileId,width,height,gravity,quali
689
692
  let response = undefined;
690
693
 
691
694
  response = await client.call('get', apiPath, {
692
- 'content-type': 'application/json',
693
695
  }, payload, 'arraybuffer');
694
696
 
695
697
  if (overrideForCli) {
@@ -709,6 +711,7 @@ const storageGetFilePreview = async ({bucketId,fileId,width,height,gravity,quali
709
711
  * @typedef {Object} StorageGetFileViewRequestParams
710
712
  * @property {string} bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
711
713
  * @property {string} fileId File ID.
714
+ * @property {string} token File token for accessing this file.
712
715
  * @property {boolean} overrideForCli
713
716
  * @property {boolean} parseOutput
714
717
  * @property {libClient | undefined} sdk
@@ -718,11 +721,14 @@ const storageGetFilePreview = async ({bucketId,fileId,width,height,gravity,quali
718
721
  /**
719
722
  * @param {StorageGetFileViewRequestParams} params
720
723
  */
721
- const storageGetFileView = async ({bucketId,fileId,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
724
+ const storageGetFileView = async ({bucketId,fileId,token,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
722
725
  let client = !sdk ? await sdkForProject() :
723
726
  sdk;
724
727
  let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
725
728
  let payload = {};
729
+ if (typeof token !== 'undefined') {
730
+ payload['token'] = token;
731
+ }
726
732
  if (!overrideForCli) {
727
733
  payload['project'] = localConfig.getProject().projectId
728
734
  payload['key'] = globalConfig.getKey();
@@ -733,7 +739,6 @@ const storageGetFileView = async ({bucketId,fileId,parseOutput = true, overrideF
733
739
  let response = undefined;
734
740
 
735
741
  response = await client.call('get', apiPath, {
736
- 'content-type': 'application/json',
737
742
  }, payload, 'arraybuffer');
738
743
 
739
744
  if (overrideForCli) {
@@ -772,7 +777,6 @@ const storageGetUsage = async ({range,parseOutput = true, overrideForCli = false
772
777
  let response = undefined;
773
778
 
774
779
  response = await client.call('get', apiPath, {
775
- 'content-type': 'application/json',
776
780
  }, payload);
777
781
 
778
782
  if (parseOutput) {
@@ -807,7 +811,6 @@ const storageGetBucketUsage = async ({bucketId,range,parseOutput = true, overrid
807
811
  let response = undefined;
808
812
 
809
813
  response = await client.call('get', apiPath, {
810
- 'content-type': 'application/json',
811
814
  }, payload);
812
815
 
813
816
  if (parseOutput) {
@@ -836,13 +839,13 @@ storage
836
839
  .requiredOption(`--bucket-id <bucket-id>`, `Unique Id. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
837
840
  .requiredOption(`--name <name>`, `Bucket name`)
838
841
  .option(`--permissions [permissions...]`, `An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).`)
839
- .option(`--file-security <file-security>`, `Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions).`, parseBool)
840
- .option(`--enabled <enabled>`, `Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.`, parseBool)
842
+ .option(`--file-security [value]`, `Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions).`, (value) => value === undefined ? true : parseBool(value))
843
+ .option(`--enabled [value]`, `Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.`, (value) => value === undefined ? true : parseBool(value))
841
844
  .option(`--maximum-file-size <maximum-file-size>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB.`, parseInteger)
842
845
  .option(`--allowed-file-extensions [allowed-file-extensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
843
846
  .option(`--compression <compression>`, `Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled`)
844
- .option(`--encryption <encryption>`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, parseBool)
845
- .option(`--antivirus <antivirus>`, `Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled`, parseBool)
847
+ .option(`--encryption [value]`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, (value) => value === undefined ? true : parseBool(value))
848
+ .option(`--antivirus [value]`, `Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled`, (value) => value === undefined ? true : parseBool(value))
846
849
  .action(actionRunner(storageCreateBucket))
847
850
 
848
851
  storage
@@ -858,13 +861,13 @@ storage
858
861
  .requiredOption(`--bucket-id <bucket-id>`, `Bucket unique ID.`)
859
862
  .requiredOption(`--name <name>`, `Bucket name`)
860
863
  .option(`--permissions [permissions...]`, `An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).`)
861
- .option(`--file-security <file-security>`, `Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions).`, parseBool)
862
- .option(`--enabled <enabled>`, `Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.`, parseBool)
864
+ .option(`--file-security [value]`, `Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions).`, (value) => value === undefined ? true : parseBool(value))
865
+ .option(`--enabled [value]`, `Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.`, (value) => value === undefined ? true : parseBool(value))
863
866
  .option(`--maximum-file-size <maximum-file-size>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB.`, parseInteger)
864
867
  .option(`--allowed-file-extensions [allowed-file-extensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
865
868
  .option(`--compression <compression>`, `Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled`)
866
- .option(`--encryption <encryption>`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, parseBool)
867
- .option(`--antivirus <antivirus>`, `Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled`, parseBool)
869
+ .option(`--encryption [value]`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, (value) => value === undefined ? true : parseBool(value))
870
+ .option(`--antivirus [value]`, `Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled`, (value) => value === undefined ? true : parseBool(value))
868
871
  .action(actionRunner(storageUpdateBucket))
869
872
 
870
873
  storage
@@ -920,6 +923,7 @@ storage
920
923
  .description(`Get a file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory.`)
921
924
  .requiredOption(`--bucket-id <bucket-id>`, `Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).`)
922
925
  .requiredOption(`--file-id <file-id>`, `File ID.`)
926
+ .option(`--token <token>`, `File token for accessing this file.`)
923
927
  .requiredOption(`--destination <path>`, `output file path.`)
924
928
  .action(actionRunner(storageGetFileDownload))
925
929
 
@@ -931,7 +935,7 @@ storage
931
935
  .option(`--width <width>`, `Resize preview image width, Pass an integer between 0 to 4000.`, parseInteger)
932
936
  .option(`--height <height>`, `Resize preview image height, Pass an integer between 0 to 4000.`, parseInteger)
933
937
  .option(`--gravity <gravity>`, `Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right`)
934
- .option(`--quality <quality>`, `Preview image quality. Pass an integer between 0 to 100. Defaults to 100.`, parseInteger)
938
+ .option(`--quality <quality>`, `Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.`, parseInteger)
935
939
  .option(`--border-width <border-width>`, `Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.`, parseInteger)
936
940
  .option(`--border-color <border-color>`, `Preview image border color. Use a valid HEX color, no # is needed for prefix.`)
937
941
  .option(`--border-radius <border-radius>`, `Preview image border radius in pixels. Pass an integer between 0 to 4000.`, parseInteger)
@@ -939,6 +943,7 @@ storage
939
943
  .option(`--rotation <rotation>`, `Preview image rotation in degrees. Pass an integer between -360 and 360.`, parseInteger)
940
944
  .option(`--background <background>`, `Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.`)
941
945
  .option(`--output <output>`, `Output format type (jpeg, jpg, png, gif and webp).`)
946
+ .option(`--token <token>`, `File token for accessing this file.`)
942
947
  .requiredOption(`--destination <path>`, `output file path.`)
943
948
  .action(actionRunner(storageGetFilePreview))
944
949
 
@@ -947,6 +952,7 @@ storage
947
952
  .description(`Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header.`)
948
953
  .requiredOption(`--bucket-id <bucket-id>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).`)
949
954
  .requiredOption(`--file-id <file-id>`, `File ID.`)
955
+ .option(`--token <token>`, `File token for accessing this file.`)
950
956
  .requiredOption(`--destination <path>`, `output file path.`)
951
957
  .action(actionRunner(storageGetFileView))
952
958
 
@@ -66,7 +66,6 @@ const teamsList = async ({queries,search,parseOutput = true, overrideForCli = fa
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) {
@@ -144,7 +143,6 @@ const teamsGet = async ({teamId,parseOutput = true, overrideForCli = false, sdk
144
143
  let response = undefined;
145
144
 
146
145
  response = await client.call('get', apiPath, {
147
- 'content-type': 'application/json',
148
146
  }, payload);
149
147
 
150
148
  if (parseOutput) {
@@ -249,7 +247,6 @@ const teamsListLogs = async ({teamId,queries,parseOutput = true, overrideForCli
249
247
  let response = undefined;
250
248
 
251
249
  response = await client.call('get', apiPath, {
252
- 'content-type': 'application/json',
253
250
  }, payload);
254
251
 
255
252
  if (parseOutput) {
@@ -263,7 +260,7 @@ const teamsListLogs = async ({teamId,queries,parseOutput = true, overrideForCli
263
260
  /**
264
261
  * @typedef {Object} TeamsListMembershipsRequestParams
265
262
  * @property {string} teamId Team ID.
266
- * @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: userId, teamId, invited, joined, confirm
263
+ * @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: userId, teamId, invited, joined, confirm, roles
267
264
  * @property {string} search Search term to filter your list results. Max length: 256 chars.
268
265
  * @property {boolean} overrideForCli
269
266
  * @property {boolean} parseOutput
@@ -288,7 +285,6 @@ const teamsListMemberships = async ({teamId,queries,search,parseOutput = true, o
288
285
  let response = undefined;
289
286
 
290
287
  response = await client.call('get', apiPath, {
291
- 'content-type': 'application/json',
292
288
  }, payload);
293
289
 
294
290
  if (parseOutput) {
@@ -376,7 +372,6 @@ const teamsGetMembership = async ({teamId,membershipId,parseOutput = true, overr
376
372
  let response = undefined;
377
373
 
378
374
  response = await client.call('get', apiPath, {
379
- 'content-type': 'application/json',
380
375
  }, payload);
381
376
 
382
377
  if (parseOutput) {
@@ -516,7 +511,6 @@ const teamsGetPrefs = async ({teamId,parseOutput = true, overrideForCli = false,
516
511
  let response = undefined;
517
512
 
518
513
  response = await client.call('get', apiPath, {
519
- 'content-type': 'application/json',
520
514
  }, payload);
521
515
 
522
516
  if (parseOutput) {
@@ -609,7 +603,7 @@ teams
609
603
  .command(`list-memberships`)
610
604
  .description(`Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console.`)
611
605
  .requiredOption(`--team-id <team-id>`, `Team ID.`)
612
- .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: userId, teamId, invited, joined, confirm`)
606
+ .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: userId, teamId, invited, joined, confirm, roles`)
613
607
  .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
614
608
  .action(actionRunner(teamsListMemberships))
615
609
 
@@ -0,0 +1,261 @@
1
+ const fs = require('fs');
2
+ const pathLib = require('path');
3
+ const tar = require("tar");
4
+ const ignore = require("ignore");
5
+ const { promisify } = require('util');
6
+ const libClient = require('../client.js');
7
+ const { getAllFiles, showConsoleLink } = require('../utils.js');
8
+ const { Command } = require('commander');
9
+ const { sdkForProject, sdkForConsole } = require('../sdks')
10
+ const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
11
+ const { localConfig, globalConfig } = require("../config");
12
+ const { File } = require('undici');
13
+ const { ReadableStream } = require('stream/web');
14
+
15
+ /**
16
+ * @param {fs.ReadStream} readStream
17
+ * @returns {ReadableStream}
18
+ */
19
+ function convertReadStreamToReadableStream(readStream) {
20
+ return new ReadableStream({
21
+ start(controller) {
22
+ readStream.on("data", (chunk) => {
23
+ controller.enqueue(chunk);
24
+ });
25
+ readStream.on("end", () => {
26
+ controller.close();
27
+ });
28
+ readStream.on("error", (err) => {
29
+ controller.error(err);
30
+ });
31
+ },
32
+ cancel() {
33
+ readStream.destroy();
34
+ },
35
+ });
36
+ }
37
+
38
+ const tokens = new Command("tokens").description(commandDescriptions['tokens'] ?? '').configureHelp({
39
+ helpWidth: process.stdout.columns || 80
40
+ })
41
+
42
+ /**
43
+ * @typedef {Object} TokensListRequestParams
44
+ * @property {string} bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
45
+ * @property {string} fileId File unique ID.
46
+ * @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: expire
47
+ * @property {boolean} overrideForCli
48
+ * @property {boolean} parseOutput
49
+ * @property {libClient | undefined} sdk
50
+ */
51
+
52
+ /**
53
+ * @param {TokensListRequestParams} params
54
+ */
55
+ const tokensList = async ({bucketId,fileId,queries,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
56
+ let client = !sdk ? await sdkForProject() :
57
+ sdk;
58
+ let apiPath = '/tokens/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
59
+ let payload = {};
60
+ if (typeof queries !== 'undefined') {
61
+ payload['queries'] = queries;
62
+ }
63
+
64
+ let response = undefined;
65
+
66
+ response = await client.call('get', apiPath, {
67
+ }, payload);
68
+
69
+ if (parseOutput) {
70
+ if(console) {
71
+ showConsoleLink('tokens', 'list', bucketId, fileId);
72
+ } else {
73
+ parse(response)
74
+ }
75
+ }
76
+
77
+ return response;
78
+
79
+ }
80
+
81
+ /**
82
+ * @typedef {Object} TokensCreateFileTokenRequestParams
83
+ * @property {string} bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
84
+ * @property {string} fileId File unique ID.
85
+ * @property {string} expire Token expiry date
86
+ * @property {boolean} overrideForCli
87
+ * @property {boolean} parseOutput
88
+ * @property {libClient | undefined} sdk
89
+ */
90
+
91
+ /**
92
+ * @param {TokensCreateFileTokenRequestParams} params
93
+ */
94
+ const tokensCreateFileToken = async ({bucketId,fileId,expire,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
95
+ let client = !sdk ? await sdkForProject() :
96
+ sdk;
97
+ let apiPath = '/tokens/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
98
+ let payload = {};
99
+ if (typeof expire !== 'undefined') {
100
+ payload['expire'] = expire;
101
+ }
102
+
103
+ let response = undefined;
104
+
105
+ response = await client.call('post', apiPath, {
106
+ 'content-type': 'application/json',
107
+ }, payload);
108
+
109
+ if (parseOutput) {
110
+ parse(response)
111
+ }
112
+
113
+ return response;
114
+
115
+ }
116
+
117
+ /**
118
+ * @typedef {Object} TokensGetRequestParams
119
+ * @property {string} tokenId Token ID.
120
+ * @property {boolean} overrideForCli
121
+ * @property {boolean} parseOutput
122
+ * @property {libClient | undefined} sdk
123
+ */
124
+
125
+ /**
126
+ * @param {TokensGetRequestParams} params
127
+ */
128
+ const tokensGet = async ({tokenId,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
129
+ let client = !sdk ? await sdkForProject() :
130
+ sdk;
131
+ let apiPath = '/tokens/{tokenId}'.replace('{tokenId}', tokenId);
132
+ let payload = {};
133
+
134
+ let response = undefined;
135
+
136
+ response = await client.call('get', apiPath, {
137
+ }, payload);
138
+
139
+ if (parseOutput) {
140
+ if(console) {
141
+ showConsoleLink('tokens', 'get', tokenId);
142
+ } else {
143
+ parse(response)
144
+ }
145
+ }
146
+
147
+ return response;
148
+
149
+ }
150
+
151
+ /**
152
+ * @typedef {Object} TokensUpdateRequestParams
153
+ * @property {string} tokenId Token unique ID.
154
+ * @property {string} expire File token expiry date
155
+ * @property {boolean} overrideForCli
156
+ * @property {boolean} parseOutput
157
+ * @property {libClient | undefined} sdk
158
+ */
159
+
160
+ /**
161
+ * @param {TokensUpdateRequestParams} params
162
+ */
163
+ const tokensUpdate = async ({tokenId,expire,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
164
+ let client = !sdk ? await sdkForProject() :
165
+ sdk;
166
+ let apiPath = '/tokens/{tokenId}'.replace('{tokenId}', tokenId);
167
+ let payload = {};
168
+ if (typeof expire !== 'undefined') {
169
+ payload['expire'] = expire;
170
+ }
171
+
172
+ let response = undefined;
173
+
174
+ response = await client.call('patch', apiPath, {
175
+ 'content-type': 'application/json',
176
+ }, payload);
177
+
178
+ if (parseOutput) {
179
+ parse(response)
180
+ }
181
+
182
+ return response;
183
+
184
+ }
185
+
186
+ /**
187
+ * @typedef {Object} TokensDeleteRequestParams
188
+ * @property {string} tokenId Token ID.
189
+ * @property {boolean} overrideForCli
190
+ * @property {boolean} parseOutput
191
+ * @property {libClient | undefined} sdk
192
+ */
193
+
194
+ /**
195
+ * @param {TokensDeleteRequestParams} params
196
+ */
197
+ const tokensDelete = async ({tokenId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
198
+ let client = !sdk ? await sdkForProject() :
199
+ sdk;
200
+ let apiPath = '/tokens/{tokenId}'.replace('{tokenId}', tokenId);
201
+ let payload = {};
202
+
203
+ let response = undefined;
204
+
205
+ response = await client.call('delete', apiPath, {
206
+ 'content-type': 'application/json',
207
+ }, payload);
208
+
209
+ if (parseOutput) {
210
+ parse(response)
211
+ }
212
+
213
+ return response;
214
+
215
+ }
216
+
217
+ tokens
218
+ .command(`list`)
219
+ .description(`List all the tokens created for a specific file or bucket. You can use the query params to filter your results.`)
220
+ .requiredOption(`--bucket-id <bucket-id>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).`)
221
+ .requiredOption(`--file-id <file-id>`, `File unique ID.`)
222
+ .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: expire`)
223
+ .option(`--console`, `Get the resource console url`)
224
+ .action(actionRunner(tokensList))
225
+
226
+ tokens
227
+ .command(`create-file-token`)
228
+ .description(`Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter.`)
229
+ .requiredOption(`--bucket-id <bucket-id>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).`)
230
+ .requiredOption(`--file-id <file-id>`, `File unique ID.`)
231
+ .option(`--expire <expire>`, `Token expiry date`)
232
+ .action(actionRunner(tokensCreateFileToken))
233
+
234
+ tokens
235
+ .command(`get`)
236
+ .description(`Get a token by its unique ID.`)
237
+ .requiredOption(`--token-id <token-id>`, `Token ID.`)
238
+ .option(`--console`, `Get the resource console url`)
239
+ .action(actionRunner(tokensGet))
240
+
241
+ tokens
242
+ .command(`update`)
243
+ .description(`Update a token by its unique ID. Use this endpoint to update a token's expiry date.`)
244
+ .requiredOption(`--token-id <token-id>`, `Token unique ID.`)
245
+ .option(`--expire <expire>`, `File token expiry date`)
246
+ .action(actionRunner(tokensUpdate))
247
+
248
+ tokens
249
+ .command(`delete`)
250
+ .description(`Delete a token by its unique ID.`)
251
+ .requiredOption(`--token-id <token-id>`, `Token ID.`)
252
+ .action(actionRunner(tokensDelete))
253
+
254
+ module.exports = {
255
+ tokens,
256
+ tokensList,
257
+ tokensCreateFileToken,
258
+ tokensGet,
259
+ tokensUpdate,
260
+ tokensDelete
261
+ };