appwrite-cli 12.0.1 → 13.0.0-rc.1

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 (283) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +2 -2
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +145 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/client.d.ts +89 -0
  8. package/dist/lib/client.d.ts.map +1 -0
  9. package/dist/lib/client.js +227 -0
  10. package/dist/lib/client.js.map +1 -0
  11. package/dist/lib/commands/account.d.ts +379 -0
  12. package/dist/lib/commands/account.d.ts.map +1 -0
  13. package/dist/lib/commands/account.js +1228 -0
  14. package/dist/lib/commands/account.js.map +1 -0
  15. package/dist/lib/commands/console.d.ts +20 -0
  16. package/dist/lib/commands/console.d.ts.map +1 -0
  17. package/dist/lib/commands/console.js +78 -0
  18. package/dist/lib/commands/console.js.map +1 -0
  19. package/dist/lib/commands/databases.d.ts +732 -0
  20. package/dist/lib/commands/databases.d.ts.map +1 -0
  21. package/dist/lib/commands/databases.js +2196 -0
  22. package/dist/lib/commands/databases.js.map +1 -0
  23. package/dist/lib/commands/functions.d.ts +310 -0
  24. package/dist/lib/commands/functions.d.ts.map +1 -0
  25. package/dist/lib/commands/functions.js +1100 -0
  26. package/dist/lib/commands/functions.js.map +1 -0
  27. package/dist/lib/commands/generic.d.ts +17 -0
  28. package/dist/lib/commands/generic.d.ts.map +1 -0
  29. package/dist/lib/commands/generic.js +279 -0
  30. package/dist/lib/commands/generic.js.map +1 -0
  31. package/dist/lib/commands/graphql.d.ts +19 -0
  32. package/dist/lib/commands/graphql.d.ts.map +1 -0
  33. package/dist/lib/commands/graphql.js +77 -0
  34. package/dist/lib/commands/graphql.js.map +1 -0
  35. package/dist/lib/commands/health.d.ts +153 -0
  36. package/dist/lib/commands/health.d.ts.map +1 -0
  37. package/dist/lib/commands/health.js +464 -0
  38. package/dist/lib/commands/health.js.map +1 -0
  39. package/dist/lib/commands/init.d.ts +3 -0
  40. package/dist/lib/commands/init.d.ts.map +1 -0
  41. package/dist/lib/commands/init.js +518 -0
  42. package/dist/lib/commands/init.js.map +1 -0
  43. package/dist/lib/commands/locale.d.ts +53 -0
  44. package/dist/lib/commands/locale.d.ts.map +1 -0
  45. package/dist/lib/commands/locale.js +165 -0
  46. package/dist/lib/commands/locale.js.map +1 -0
  47. package/dist/lib/commands/messaging.d.ts +588 -0
  48. package/dist/lib/commands/messaging.d.ts.map +1 -0
  49. package/dist/lib/commands/messaging.js +2042 -0
  50. package/dist/lib/commands/messaging.js.map +1 -0
  51. package/dist/lib/commands/migrations.d.ts +150 -0
  52. package/dist/lib/commands/migrations.d.ts.map +1 -0
  53. package/dist/lib/commands/migrations.js +524 -0
  54. package/dist/lib/commands/migrations.js.map +1 -0
  55. package/dist/lib/commands/organizations.d.ts +11 -0
  56. package/dist/lib/commands/organizations.d.ts.map +1 -0
  57. package/dist/lib/commands/organizations.js +31 -0
  58. package/dist/lib/commands/organizations.js.map +1 -0
  59. package/dist/lib/commands/project.d.ts +53 -0
  60. package/dist/lib/commands/project.d.ts.map +1 -0
  61. package/dist/lib/commands/project.js +176 -0
  62. package/dist/lib/commands/project.js.map +1 -0
  63. package/dist/lib/commands/projects.d.ts +516 -0
  64. package/dist/lib/commands/projects.d.ts.map +1 -0
  65. package/dist/lib/commands/projects.js +1590 -0
  66. package/dist/lib/commands/projects.js.map +1 -0
  67. package/dist/lib/commands/proxy.d.ts +71 -0
  68. package/dist/lib/commands/proxy.d.ts.map +1 -0
  69. package/dist/lib/commands/proxy.js +240 -0
  70. package/dist/lib/commands/proxy.js.map +1 -0
  71. package/dist/lib/commands/pull.d.ts +8 -0
  72. package/dist/lib/commands/pull.d.ts.map +1 -0
  73. package/dist/lib/commands/pull.js +455 -0
  74. package/dist/lib/commands/pull.js.map +1 -0
  75. package/dist/lib/commands/push.d.ts +4 -0
  76. package/dist/lib/commands/push.d.ts.map +1 -0
  77. package/dist/lib/commands/push.js +2154 -0
  78. package/dist/lib/commands/push.js.map +1 -0
  79. package/dist/lib/commands/run.d.ts +3 -0
  80. package/dist/lib/commands/run.d.ts.map +1 -0
  81. package/dist/lib/commands/run.js +287 -0
  82. package/dist/lib/commands/run.js.map +1 -0
  83. package/dist/lib/commands/sites.d.ts +296 -0
  84. package/dist/lib/commands/sites.d.ts.map +1 -0
  85. package/dist/lib/commands/sites.js +1046 -0
  86. package/dist/lib/commands/sites.js.map +1 -0
  87. package/dist/lib/commands/storage.d.ts +170 -0
  88. package/dist/lib/commands/storage.d.ts.map +1 -0
  89. package/dist/lib/commands/storage.js +651 -0
  90. package/dist/lib/commands/storage.js.map +1 -0
  91. package/dist/lib/commands/tables-db.d.ts +728 -0
  92. package/dist/lib/commands/tables-db.d.ts.map +1 -0
  93. package/dist/lib/commands/tables-db.js +2198 -0
  94. package/dist/lib/commands/tables-db.js.map +1 -0
  95. package/dist/lib/commands/teams.d.ts +129 -0
  96. package/dist/lib/commands/teams.d.ts.map +1 -0
  97. package/dist/lib/commands/teams.js +403 -0
  98. package/dist/lib/commands/teams.js.map +1 -0
  99. package/dist/lib/commands/tokens.d.ts +48 -0
  100. package/dist/lib/commands/tokens.d.ts.map +1 -0
  101. package/dist/lib/commands/tokens.js +156 -0
  102. package/dist/lib/commands/tokens.js.map +1 -0
  103. package/dist/lib/commands/types.d.ts +3 -0
  104. package/dist/lib/commands/types.d.ts.map +1 -0
  105. package/dist/lib/commands/types.js +155 -0
  106. package/dist/lib/commands/types.js.map +1 -0
  107. package/dist/lib/commands/update.d.ts +3 -0
  108. package/dist/lib/commands/update.d.ts.map +1 -0
  109. package/dist/lib/commands/update.js +202 -0
  110. package/dist/lib/commands/update.js.map +1 -0
  111. package/dist/lib/commands/users.d.ts +382 -0
  112. package/dist/lib/commands/users.d.ts.map +1 -0
  113. package/dist/lib/commands/users.js +1195 -0
  114. package/dist/lib/commands/users.js.map +1 -0
  115. package/dist/lib/commands/vcs.d.ts +92 -0
  116. package/dist/lib/commands/vcs.d.ts.map +1 -0
  117. package/dist/lib/commands/vcs.js +276 -0
  118. package/dist/lib/commands/vcs.js.map +1 -0
  119. package/dist/lib/config.d.ts +118 -0
  120. package/dist/lib/config.d.ts.map +1 -0
  121. package/{lib → dist/lib}/config.js +204 -325
  122. package/dist/lib/config.js.map +1 -0
  123. package/dist/lib/emulation/docker.d.ts +15 -0
  124. package/dist/lib/emulation/docker.d.ts.map +1 -0
  125. package/dist/lib/emulation/docker.js +220 -0
  126. package/dist/lib/emulation/docker.js.map +1 -0
  127. package/dist/lib/emulation/utils.d.ts +29 -0
  128. package/dist/lib/emulation/utils.d.ts.map +1 -0
  129. package/dist/lib/emulation/utils.js +168 -0
  130. package/dist/lib/emulation/utils.js.map +1 -0
  131. package/dist/lib/exception.d.ts +8 -0
  132. package/dist/lib/exception.d.ts.map +1 -0
  133. package/dist/lib/exception.js +16 -0
  134. package/dist/lib/exception.js.map +1 -0
  135. package/dist/lib/id.d.ts +7 -0
  136. package/dist/lib/id.d.ts.map +1 -0
  137. package/dist/lib/id.js +32 -0
  138. package/dist/lib/id.js.map +1 -0
  139. package/dist/lib/paginate.d.ts +10 -0
  140. package/dist/lib/paginate.d.ts.map +1 -0
  141. package/{lib → dist/lib}/paginate.js +9 -15
  142. package/dist/lib/paginate.js.map +1 -0
  143. package/dist/lib/parser.d.ts +18 -0
  144. package/dist/lib/parser.d.ts.map +1 -0
  145. package/dist/lib/parser.js +237 -0
  146. package/dist/lib/parser.js.map +1 -0
  147. package/dist/lib/questions.d.ts +59 -0
  148. package/dist/lib/questions.d.ts.map +1 -0
  149. package/dist/lib/questions.js +995 -0
  150. package/dist/lib/questions.js.map +1 -0
  151. package/dist/lib/sdks.d.ts +4 -0
  152. package/dist/lib/sdks.d.ts.map +1 -0
  153. package/dist/lib/sdks.js +51 -0
  154. package/dist/lib/sdks.js.map +1 -0
  155. package/dist/lib/spinner.d.ts +28 -0
  156. package/dist/lib/spinner.d.ts.map +1 -0
  157. package/{lib → dist/lib}/spinner.js +34 -45
  158. package/dist/lib/spinner.js.map +1 -0
  159. package/dist/lib/type-generation/attribute.d.ts +17 -0
  160. package/dist/lib/type-generation/attribute.d.ts.map +1 -0
  161. package/dist/lib/type-generation/attribute.js +19 -0
  162. package/dist/lib/type-generation/attribute.js.map +1 -0
  163. package/dist/lib/type-generation/languages/csharp.d.ts +7 -0
  164. package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -0
  165. package/dist/lib/type-generation/languages/csharp.js +180 -0
  166. package/dist/lib/type-generation/languages/csharp.js.map +1 -0
  167. package/dist/lib/type-generation/languages/dart.d.ts +8 -0
  168. package/dist/lib/type-generation/languages/dart.d.ts.map +1 -0
  169. package/dist/lib/type-generation/languages/dart.js +197 -0
  170. package/dist/lib/type-generation/languages/dart.js.map +1 -0
  171. package/dist/lib/type-generation/languages/java.d.ts +7 -0
  172. package/dist/lib/type-generation/languages/java.d.ts.map +1 -0
  173. package/dist/lib/type-generation/languages/java.js +140 -0
  174. package/dist/lib/type-generation/languages/java.js.map +1 -0
  175. package/dist/lib/type-generation/languages/javascript.d.ts +9 -0
  176. package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -0
  177. package/dist/lib/type-generation/languages/javascript.js +108 -0
  178. package/dist/lib/type-generation/languages/javascript.js.map +1 -0
  179. package/dist/lib/type-generation/languages/kotlin.d.ts +7 -0
  180. package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -0
  181. package/dist/lib/type-generation/languages/kotlin.js +95 -0
  182. package/dist/lib/type-generation/languages/kotlin.js.map +1 -0
  183. package/dist/lib/type-generation/languages/language.d.ts +43 -0
  184. package/dist/lib/type-generation/languages/language.d.ts.map +1 -0
  185. package/dist/lib/type-generation/languages/language.js +82 -0
  186. package/dist/lib/type-generation/languages/language.js.map +1 -0
  187. package/dist/lib/type-generation/languages/php.d.ts +7 -0
  188. package/dist/lib/type-generation/languages/php.d.ts.map +1 -0
  189. package/dist/lib/type-generation/languages/php.js +116 -0
  190. package/dist/lib/type-generation/languages/php.js.map +1 -0
  191. package/dist/lib/type-generation/languages/swift.d.ts +7 -0
  192. package/dist/lib/type-generation/languages/swift.d.ts.map +1 -0
  193. package/dist/lib/type-generation/languages/swift.js +179 -0
  194. package/dist/lib/type-generation/languages/swift.js.map +1 -0
  195. package/dist/lib/type-generation/languages/typescript.d.ts +9 -0
  196. package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -0
  197. package/dist/lib/type-generation/languages/typescript.js +112 -0
  198. package/dist/lib/type-generation/languages/typescript.js.map +1 -0
  199. package/dist/lib/types.d.ts +133 -0
  200. package/dist/lib/types.d.ts.map +1 -0
  201. package/dist/lib/types.js +3 -0
  202. package/dist/lib/types.js.map +1 -0
  203. package/dist/lib/utils.d.ts +15 -0
  204. package/dist/lib/utils.d.ts.map +1 -0
  205. package/{lib → dist/lib}/utils.js +74 -120
  206. package/dist/lib/utils.js.map +1 -0
  207. package/dist/lib/validations.d.ts +2 -0
  208. package/dist/lib/validations.d.ts.map +1 -0
  209. package/dist/lib/validations.js +20 -0
  210. package/dist/lib/validations.js.map +1 -0
  211. package/docs/examples/databases/upsert-document.md +1 -2
  212. package/index.ts +152 -0
  213. package/install.ps1 +2 -5
  214. package/install.sh +1 -2
  215. package/lib/client.ts +259 -0
  216. package/lib/commands/{account.js → account.ts} +408 -662
  217. package/lib/commands/console.ts +112 -0
  218. package/lib/commands/{databases.js → databases.ts} +818 -1136
  219. package/lib/commands/{functions.js → functions.ts} +381 -526
  220. package/lib/commands/{generic.js → generic.ts} +47 -39
  221. package/lib/commands/graphql.ts +110 -0
  222. package/lib/commands/{health.js → health.ts} +168 -284
  223. package/lib/commands/{init.js → init.ts} +68 -66
  224. package/lib/commands/{locale.js → locale.ts} +75 -121
  225. package/lib/commands/{messaging.js → messaging.ts} +699 -937
  226. package/lib/commands/{migrations.js → migrations.ts} +182 -258
  227. package/lib/commands/organizations.ts +46 -0
  228. package/lib/commands/{project.js → project.ts} +75 -111
  229. package/lib/commands/{projects.js → projects.ts} +587 -843
  230. package/lib/commands/{proxy.js → proxy.ts} +94 -140
  231. package/lib/commands/{pull.js → pull.ts} +54 -44
  232. package/lib/commands/{push.js → push.ts} +235 -191
  233. package/lib/commands/{run.js → run.ts} +61 -55
  234. package/lib/commands/{sites.js → sites.ts} +364 -504
  235. package/lib/commands/{storage.js → storage.ts} +216 -292
  236. package/lib/commands/{tables-db.js → tables-db.ts} +817 -1126
  237. package/lib/commands/{teams.js → teams.ts} +162 -236
  238. package/lib/commands/{tokens.js → tokens.ts} +70 -99
  239. package/lib/commands/{types.js → types.ts} +37 -35
  240. package/lib/commands/{update.js → update.ts} +25 -27
  241. package/lib/commands/{users.js → users.ts} +426 -644
  242. package/lib/commands/{vcs.js → vcs.ts} +118 -174
  243. package/lib/config.ts +854 -0
  244. package/lib/emulation/{docker.js → docker.ts} +39 -38
  245. package/lib/emulation/utils.ts +193 -0
  246. package/lib/exception.ts +20 -0
  247. package/lib/{id.js → id.ts} +5 -5
  248. package/lib/paginate.ts +63 -0
  249. package/lib/parser.ts +238 -0
  250. package/lib/{questions.js → questions.ts} +148 -156
  251. package/lib/sdks.ts +55 -0
  252. package/lib/spinner.ts +118 -0
  253. package/lib/type-generation/attribute.ts +17 -0
  254. package/lib/type-generation/languages/{csharp.js → csharp.ts} +59 -57
  255. package/lib/type-generation/languages/{dart.js → dart.ts} +91 -89
  256. package/lib/type-generation/languages/{java.js → java.ts} +58 -56
  257. package/lib/type-generation/languages/javascript.ts +111 -0
  258. package/lib/type-generation/languages/kotlin.ts +96 -0
  259. package/lib/type-generation/languages/language.ts +119 -0
  260. package/lib/type-generation/languages/{php.js → php.ts} +55 -53
  261. package/lib/type-generation/languages/{swift.js → swift.ts} +59 -57
  262. package/lib/type-generation/languages/typescript.ts +116 -0
  263. package/lib/types.ts +150 -0
  264. package/lib/utils.ts +322 -0
  265. package/lib/validations.ts +17 -0
  266. package/package.json +21 -12
  267. package/scoop/appwrite.config.json +3 -3
  268. package/tsconfig.json +30 -0
  269. package/index.js +0 -147
  270. package/lib/client.js +0 -254
  271. package/lib/commands/console.js +0 -127
  272. package/lib/commands/graphql.js +0 -126
  273. package/lib/commands/organizations.js +0 -48
  274. package/lib/emulation/utils.js +0 -186
  275. package/lib/exception.js +0 -9
  276. package/lib/parser.js +0 -250
  277. package/lib/sdks.js +0 -60
  278. package/lib/type-generation/attribute.js +0 -19
  279. package/lib/type-generation/languages/javascript.js +0 -111
  280. package/lib/type-generation/languages/kotlin.js +0 -94
  281. package/lib/type-generation/languages/language.js +0 -125
  282. package/lib/type-generation/languages/typescript.js +0 -116
  283. package/lib/validations.js +0 -17
@@ -0,0 +1,651 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.storageGetBucketUsage = exports.storageGetUsage = exports.storageGetFileView = exports.storageGetFilePreview = exports.storageGetFileDownload = exports.storageDeleteFile = exports.storageUpdateFile = exports.storageGetFile = exports.storageCreateFile = exports.storageListFiles = exports.storageDeleteBucket = exports.storageUpdateBucket = exports.storageGetBucket = exports.storageCreateBucket = exports.storageListBuckets = exports.storage = void 0;
4
+ const fs = require("fs");
5
+ const pathLib = require("path");
6
+ const utils_1 = require("../utils");
7
+ const commander_1 = require("commander");
8
+ const sdks_1 = require("../sdks");
9
+ const parser_1 = require("../parser");
10
+ const config_1 = require("../config");
11
+ const undici_1 = require("undici");
12
+ const web_1 = require("stream/web");
13
+ function convertReadStreamToReadableStream(readStream) {
14
+ return new web_1.ReadableStream({
15
+ start(controller) {
16
+ readStream.on("data", (chunk) => {
17
+ controller.enqueue(chunk);
18
+ });
19
+ readStream.on("end", () => {
20
+ controller.close();
21
+ });
22
+ readStream.on("error", (err) => {
23
+ controller.error(err);
24
+ });
25
+ },
26
+ cancel() {
27
+ readStream.destroy();
28
+ },
29
+ });
30
+ }
31
+ exports.storage = new commander_1.Command("storage").description(parser_1.commandDescriptions['storage'] ?? '').configureHelp({
32
+ helpWidth: process.stdout.columns || 80
33
+ });
34
+ const storageListBuckets = async ({ queries, search, total, parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole }) => {
35
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
36
+ sdk;
37
+ let apiPath = '/storage/buckets';
38
+ let payload = {};
39
+ if (typeof queries !== 'undefined') {
40
+ payload['queries'] = queries;
41
+ }
42
+ if (typeof search !== 'undefined') {
43
+ payload['search'] = search;
44
+ }
45
+ if (typeof total !== 'undefined') {
46
+ payload['total'] = total;
47
+ }
48
+ let response = undefined;
49
+ response = await client.call('get', apiPath, {}, payload);
50
+ if (parseOutput) {
51
+ if (showConsole) {
52
+ (0, utils_1.showConsoleLink)('storage', 'listBuckets');
53
+ }
54
+ else {
55
+ (0, parser_1.parse)(response);
56
+ }
57
+ }
58
+ return response;
59
+ };
60
+ exports.storageListBuckets = storageListBuckets;
61
+ const storageCreateBucket = async ({ bucketId, name, permissions, fileSecurity, enabled, maximumFileSize, allowedFileExtensions, compression, encryption, antivirus, transformations, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
62
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
63
+ sdk;
64
+ let apiPath = '/storage/buckets';
65
+ let payload = {};
66
+ if (typeof bucketId !== 'undefined') {
67
+ payload['bucketId'] = bucketId;
68
+ }
69
+ if (typeof name !== 'undefined') {
70
+ payload['name'] = name;
71
+ }
72
+ permissions = permissions === true ? [] : permissions;
73
+ if (typeof permissions !== 'undefined') {
74
+ payload['permissions'] = permissions;
75
+ }
76
+ if (typeof fileSecurity !== 'undefined') {
77
+ payload['fileSecurity'] = fileSecurity;
78
+ }
79
+ if (typeof enabled !== 'undefined') {
80
+ payload['enabled'] = enabled;
81
+ }
82
+ if (typeof maximumFileSize !== 'undefined') {
83
+ payload['maximumFileSize'] = maximumFileSize;
84
+ }
85
+ allowedFileExtensions = allowedFileExtensions === true ? [] : allowedFileExtensions;
86
+ if (typeof allowedFileExtensions !== 'undefined') {
87
+ payload['allowedFileExtensions'] = allowedFileExtensions;
88
+ }
89
+ if (typeof compression !== 'undefined') {
90
+ payload['compression'] = compression;
91
+ }
92
+ if (typeof encryption !== 'undefined') {
93
+ payload['encryption'] = encryption;
94
+ }
95
+ if (typeof antivirus !== 'undefined') {
96
+ payload['antivirus'] = antivirus;
97
+ }
98
+ if (typeof transformations !== 'undefined') {
99
+ payload['transformations'] = transformations;
100
+ }
101
+ let response = undefined;
102
+ response = await client.call('post', apiPath, {
103
+ 'content-type': 'application/json',
104
+ }, payload);
105
+ if (parseOutput) {
106
+ (0, parser_1.parse)(response);
107
+ }
108
+ return response;
109
+ };
110
+ exports.storageCreateBucket = storageCreateBucket;
111
+ const storageGetBucket = async ({ bucketId, parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole }) => {
112
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
113
+ sdk;
114
+ let apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
115
+ let payload = {};
116
+ let response = undefined;
117
+ response = await client.call('get', apiPath, {}, payload);
118
+ if (parseOutput) {
119
+ if (showConsole) {
120
+ (0, utils_1.showConsoleLink)('storage', 'getBucket', bucketId);
121
+ }
122
+ else {
123
+ (0, parser_1.parse)(response);
124
+ }
125
+ }
126
+ return response;
127
+ };
128
+ exports.storageGetBucket = storageGetBucket;
129
+ const storageUpdateBucket = async ({ bucketId, name, permissions, fileSecurity, enabled, maximumFileSize, allowedFileExtensions, compression, encryption, antivirus, transformations, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
130
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
131
+ sdk;
132
+ let apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
133
+ let payload = {};
134
+ if (typeof name !== 'undefined') {
135
+ payload['name'] = name;
136
+ }
137
+ permissions = permissions === true ? [] : permissions;
138
+ if (typeof permissions !== 'undefined') {
139
+ payload['permissions'] = permissions;
140
+ }
141
+ if (typeof fileSecurity !== 'undefined') {
142
+ payload['fileSecurity'] = fileSecurity;
143
+ }
144
+ if (typeof enabled !== 'undefined') {
145
+ payload['enabled'] = enabled;
146
+ }
147
+ if (typeof maximumFileSize !== 'undefined') {
148
+ payload['maximumFileSize'] = maximumFileSize;
149
+ }
150
+ allowedFileExtensions = allowedFileExtensions === true ? [] : allowedFileExtensions;
151
+ if (typeof allowedFileExtensions !== 'undefined') {
152
+ payload['allowedFileExtensions'] = allowedFileExtensions;
153
+ }
154
+ if (typeof compression !== 'undefined') {
155
+ payload['compression'] = compression;
156
+ }
157
+ if (typeof encryption !== 'undefined') {
158
+ payload['encryption'] = encryption;
159
+ }
160
+ if (typeof antivirus !== 'undefined') {
161
+ payload['antivirus'] = antivirus;
162
+ }
163
+ if (typeof transformations !== 'undefined') {
164
+ payload['transformations'] = transformations;
165
+ }
166
+ let response = undefined;
167
+ response = await client.call('put', apiPath, {
168
+ 'content-type': 'application/json',
169
+ }, payload);
170
+ if (parseOutput) {
171
+ (0, parser_1.parse)(response);
172
+ }
173
+ return response;
174
+ };
175
+ exports.storageUpdateBucket = storageUpdateBucket;
176
+ const storageDeleteBucket = async ({ bucketId, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
177
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
178
+ sdk;
179
+ let apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
180
+ let payload = {};
181
+ let response = undefined;
182
+ response = await client.call('delete', apiPath, {
183
+ 'content-type': 'application/json',
184
+ }, payload);
185
+ if (parseOutput) {
186
+ (0, parser_1.parse)(response);
187
+ }
188
+ return response;
189
+ };
190
+ exports.storageDeleteBucket = storageDeleteBucket;
191
+ const storageListFiles = async ({ bucketId, queries, search, total, parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole }) => {
192
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
193
+ sdk;
194
+ let apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
195
+ let payload = {};
196
+ if (typeof queries !== 'undefined') {
197
+ payload['queries'] = queries;
198
+ }
199
+ if (typeof search !== 'undefined') {
200
+ payload['search'] = search;
201
+ }
202
+ if (typeof total !== 'undefined') {
203
+ payload['total'] = total;
204
+ }
205
+ let response = undefined;
206
+ response = await client.call('get', apiPath, {}, payload);
207
+ if (parseOutput) {
208
+ if (showConsole) {
209
+ (0, utils_1.showConsoleLink)('storage', 'listFiles', bucketId);
210
+ }
211
+ else {
212
+ (0, parser_1.parse)(response);
213
+ }
214
+ }
215
+ return response;
216
+ };
217
+ exports.storageListFiles = storageListFiles;
218
+ const storageCreateFile = async ({ bucketId, fileId, file, permissions, parseOutput = true, overrideForCli = false, sdk = undefined, onProgress = () => { } }) => {
219
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
220
+ sdk;
221
+ let apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
222
+ let payload = {};
223
+ if (typeof fileId !== 'undefined') {
224
+ payload['fileId'] = fileId;
225
+ }
226
+ const filePath = fs.realpathSync(file);
227
+ const nodeStream = fs.createReadStream(filePath);
228
+ const stream = convertReadStreamToReadableStream(nodeStream);
229
+ if (typeof filePath !== 'undefined') {
230
+ file = { type: 'file', stream, filename: pathLib.basename(filePath), size: fs.statSync(filePath).size };
231
+ payload['file'] = file;
232
+ }
233
+ permissions = permissions === true ? [] : permissions;
234
+ if (typeof permissions !== 'undefined') {
235
+ payload['permissions'] = permissions;
236
+ }
237
+ const size = file.size;
238
+ const apiHeaders = {
239
+ 'content-type': 'multipart/form-data',
240
+ };
241
+ let id = undefined;
242
+ let response = undefined;
243
+ let chunksUploaded = 0;
244
+ if (fileId != 'unique()') {
245
+ try {
246
+ response = await client.call('get', apiPath + '/' + fileId, apiHeaders);
247
+ chunksUploaded = response.chunksUploaded;
248
+ }
249
+ catch (e) {
250
+ }
251
+ }
252
+ let currentChunk = 1;
253
+ let currentPosition = 0;
254
+ let uploadableChunk = new Uint8Array(client.CHUNK_SIZE);
255
+ const uploadChunk = async (lastUpload = false) => {
256
+ if (currentChunk <= chunksUploaded) {
257
+ return;
258
+ }
259
+ const start = ((currentChunk - 1) * client.CHUNK_SIZE);
260
+ let end = start + currentPosition - 1;
261
+ if (!lastUpload || currentChunk !== 1) {
262
+ apiHeaders['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
263
+ }
264
+ let uploadableChunkTrimmed;
265
+ if (currentPosition + 1 >= client.CHUNK_SIZE) {
266
+ uploadableChunkTrimmed = uploadableChunk;
267
+ }
268
+ else {
269
+ uploadableChunkTrimmed = new Uint8Array(currentPosition);
270
+ for (let i = 0; i <= currentPosition; i++) {
271
+ uploadableChunkTrimmed[i] = uploadableChunk[i];
272
+ }
273
+ }
274
+ if (id) {
275
+ apiHeaders['x-appwrite-id'] = id;
276
+ }
277
+ payload['file'] = { type: 'file', file: new undici_1.File([uploadableChunkTrimmed], file.filename), filename: file.filename };
278
+ response = await client.call('post', apiPath, apiHeaders, payload);
279
+ if (!id) {
280
+ id = response['$id'];
281
+ }
282
+ if (onProgress !== null) {
283
+ onProgress({
284
+ $id: response['$id'],
285
+ progress: Math.min((currentChunk) * client.CHUNK_SIZE, size) / size * 100,
286
+ sizeUploaded: end + 1,
287
+ chunksTotal: response['chunksTotal'],
288
+ chunksUploaded: response['chunksUploaded']
289
+ });
290
+ }
291
+ uploadableChunk = new Uint8Array(client.CHUNK_SIZE);
292
+ currentChunk++;
293
+ currentPosition = 0;
294
+ };
295
+ for await (const chunk of file.stream) {
296
+ for (const b of chunk) {
297
+ uploadableChunk[currentPosition] = b;
298
+ currentPosition++;
299
+ if (currentPosition >= client.CHUNK_SIZE) {
300
+ await uploadChunk();
301
+ currentPosition = 0;
302
+ }
303
+ }
304
+ }
305
+ if (currentPosition > 0) { // Check if there's any remaining data for the last chunk
306
+ await uploadChunk(true);
307
+ }
308
+ if (parseOutput) {
309
+ (0, parser_1.parse)(response);
310
+ }
311
+ return response;
312
+ };
313
+ exports.storageCreateFile = storageCreateFile;
314
+ const storageGetFile = async ({ bucketId, fileId, parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole }) => {
315
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
316
+ sdk;
317
+ let apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
318
+ let payload = {};
319
+ let response = undefined;
320
+ response = await client.call('get', apiPath, {}, payload);
321
+ if (parseOutput) {
322
+ if (showConsole) {
323
+ (0, utils_1.showConsoleLink)('storage', 'getFile', bucketId, fileId);
324
+ }
325
+ else {
326
+ (0, parser_1.parse)(response);
327
+ }
328
+ }
329
+ return response;
330
+ };
331
+ exports.storageGetFile = storageGetFile;
332
+ const storageUpdateFile = async ({ bucketId, fileId, name, permissions, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
333
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
334
+ sdk;
335
+ let apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
336
+ let payload = {};
337
+ if (typeof name !== 'undefined') {
338
+ payload['name'] = name;
339
+ }
340
+ permissions = permissions === true ? [] : permissions;
341
+ if (typeof permissions !== 'undefined') {
342
+ payload['permissions'] = permissions;
343
+ }
344
+ let response = undefined;
345
+ response = await client.call('put', apiPath, {
346
+ 'content-type': 'application/json',
347
+ }, payload);
348
+ if (parseOutput) {
349
+ (0, parser_1.parse)(response);
350
+ }
351
+ return response;
352
+ };
353
+ exports.storageUpdateFile = storageUpdateFile;
354
+ const storageDeleteFile = async ({ bucketId, fileId, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
355
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
356
+ sdk;
357
+ let apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
358
+ let payload = {};
359
+ let response = undefined;
360
+ response = await client.call('delete', apiPath, {
361
+ 'content-type': 'application/json',
362
+ }, payload);
363
+ if (parseOutput) {
364
+ (0, parser_1.parse)(response);
365
+ }
366
+ return response;
367
+ };
368
+ exports.storageDeleteFile = storageDeleteFile;
369
+ const storageGetFileDownload = async ({ bucketId, fileId, token, parseOutput = true, overrideForCli = false, sdk = undefined, destination }) => {
370
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
371
+ sdk;
372
+ let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
373
+ let payload = {};
374
+ if (typeof token !== 'undefined') {
375
+ payload['token'] = token;
376
+ }
377
+ if (!overrideForCli) {
378
+ payload['project'] = config_1.localConfig.getProject().projectId;
379
+ payload['key'] = config_1.globalConfig.getKey();
380
+ const queryParams = new URLSearchParams(payload);
381
+ apiPath = `${config_1.globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
382
+ }
383
+ let response = undefined;
384
+ response = await client.call('get', apiPath, {}, payload, 'arraybuffer');
385
+ if (overrideForCli) {
386
+ response = Buffer.from(response);
387
+ }
388
+ fs.writeFileSync(destination, response);
389
+ if (parseOutput) {
390
+ (0, parser_1.parse)(response);
391
+ }
392
+ return response;
393
+ };
394
+ exports.storageGetFileDownload = storageGetFileDownload;
395
+ const storageGetFilePreview = async ({ bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output, token, parseOutput = true, overrideForCli = false, sdk = undefined, destination }) => {
396
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
397
+ sdk;
398
+ let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
399
+ let payload = {};
400
+ if (typeof width !== 'undefined') {
401
+ payload['width'] = width;
402
+ }
403
+ if (typeof height !== 'undefined') {
404
+ payload['height'] = height;
405
+ }
406
+ if (typeof gravity !== 'undefined') {
407
+ payload['gravity'] = gravity;
408
+ }
409
+ if (typeof quality !== 'undefined') {
410
+ payload['quality'] = quality;
411
+ }
412
+ if (typeof borderWidth !== 'undefined') {
413
+ payload['borderWidth'] = borderWidth;
414
+ }
415
+ if (typeof borderColor !== 'undefined') {
416
+ payload['borderColor'] = borderColor;
417
+ }
418
+ if (typeof borderRadius !== 'undefined') {
419
+ payload['borderRadius'] = borderRadius;
420
+ }
421
+ if (typeof opacity !== 'undefined') {
422
+ payload['opacity'] = opacity;
423
+ }
424
+ if (typeof rotation !== 'undefined') {
425
+ payload['rotation'] = rotation;
426
+ }
427
+ if (typeof background !== 'undefined') {
428
+ payload['background'] = background;
429
+ }
430
+ if (typeof output !== 'undefined') {
431
+ payload['output'] = output;
432
+ }
433
+ if (typeof token !== 'undefined') {
434
+ payload['token'] = token;
435
+ }
436
+ if (!overrideForCli) {
437
+ payload['project'] = config_1.localConfig.getProject().projectId;
438
+ payload['key'] = config_1.globalConfig.getKey();
439
+ const queryParams = new URLSearchParams(payload);
440
+ apiPath = `${config_1.globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
441
+ }
442
+ let response = undefined;
443
+ response = await client.call('get', apiPath, {}, payload, 'arraybuffer');
444
+ if (overrideForCli) {
445
+ response = Buffer.from(response);
446
+ }
447
+ fs.writeFileSync(destination, response);
448
+ if (parseOutput) {
449
+ (0, parser_1.parse)(response);
450
+ }
451
+ return response;
452
+ };
453
+ exports.storageGetFilePreview = storageGetFilePreview;
454
+ const storageGetFileView = async ({ bucketId, fileId, token, parseOutput = true, overrideForCli = false, sdk = undefined, destination }) => {
455
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
456
+ sdk;
457
+ let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
458
+ let payload = {};
459
+ if (typeof token !== 'undefined') {
460
+ payload['token'] = token;
461
+ }
462
+ if (!overrideForCli) {
463
+ payload['project'] = config_1.localConfig.getProject().projectId;
464
+ payload['key'] = config_1.globalConfig.getKey();
465
+ const queryParams = new URLSearchParams(payload);
466
+ apiPath = `${config_1.globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
467
+ }
468
+ let response = undefined;
469
+ response = await client.call('get', apiPath, {}, payload, 'arraybuffer');
470
+ if (overrideForCli) {
471
+ response = Buffer.from(response);
472
+ }
473
+ fs.writeFileSync(destination, response);
474
+ if (parseOutput) {
475
+ (0, parser_1.parse)(response);
476
+ }
477
+ return response;
478
+ };
479
+ exports.storageGetFileView = storageGetFileView;
480
+ const storageGetUsage = async ({ range, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
481
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
482
+ sdk;
483
+ let apiPath = '/storage/usage';
484
+ let payload = {};
485
+ if (typeof range !== 'undefined') {
486
+ payload['range'] = range;
487
+ }
488
+ let response = undefined;
489
+ response = await client.call('get', apiPath, {}, payload);
490
+ if (parseOutput) {
491
+ (0, parser_1.parse)(response);
492
+ }
493
+ return response;
494
+ };
495
+ exports.storageGetUsage = storageGetUsage;
496
+ const storageGetBucketUsage = async ({ bucketId, range, parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole }) => {
497
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
498
+ sdk;
499
+ let apiPath = '/storage/{bucketId}/usage'.replace('{bucketId}', bucketId);
500
+ let payload = {};
501
+ if (typeof range !== 'undefined') {
502
+ payload['range'] = range;
503
+ }
504
+ let response = undefined;
505
+ response = await client.call('get', apiPath, {}, payload);
506
+ if (parseOutput) {
507
+ if (showConsole) {
508
+ (0, utils_1.showConsoleLink)('storage', 'getBucketUsage', bucketId);
509
+ }
510
+ else {
511
+ (0, parser_1.parse)(response);
512
+ }
513
+ }
514
+ return response;
515
+ };
516
+ exports.storageGetBucketUsage = storageGetBucketUsage;
517
+ exports.storage
518
+ .command(`list-buckets`)
519
+ .description(`Get a list of all the storage buckets. You can use the query params to filter your results.`)
520
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus, transformations`)
521
+ .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
522
+ .option(`--total [value]`, `When set to false, the total count returned will be 0 and will not be calculated.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
523
+ .option(`--console`, `Get the resource console url`)
524
+ .action((0, parser_1.actionRunner)(exports.storageListBuckets));
525
+ exports.storage
526
+ .command(`create-bucket`)
527
+ .description(`Create a new storage bucket.`)
528
+ .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.`)
529
+ .requiredOption(`--name <name>`, `Bucket name`)
530
+ .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).`)
531
+ .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 : (0, parser_1.parseBool)(value))
532
+ .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 : (0, parser_1.parseBool)(value))
533
+ .option(`--maximum-file-size <maximum-file-size>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB.`, parser_1.parseInteger)
534
+ .option(`--allowed-file-extensions [allowed-file-extensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
535
+ .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`)
536
+ .option(`--encryption [value]`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
537
+ .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 : (0, parser_1.parseBool)(value))
538
+ .option(`--transformations [value]`, `Are image transformations enabled?`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
539
+ .action((0, parser_1.actionRunner)(exports.storageCreateBucket));
540
+ exports.storage
541
+ .command(`get-bucket`)
542
+ .description(`Get a storage bucket by its unique ID. This endpoint response returns a JSON object with the storage bucket metadata.`)
543
+ .requiredOption(`--bucket-id <bucket-id>`, `Bucket unique ID.`)
544
+ .option(`--console`, `Get the resource console url`)
545
+ .action((0, parser_1.actionRunner)(exports.storageGetBucket));
546
+ exports.storage
547
+ .command(`update-bucket`)
548
+ .description(`Update a storage bucket by its unique ID.`)
549
+ .requiredOption(`--bucket-id <bucket-id>`, `Bucket unique ID.`)
550
+ .requiredOption(`--name <name>`, `Bucket name`)
551
+ .option(`--permissions [permissions...]`, `An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).`)
552
+ .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 : (0, parser_1.parseBool)(value))
553
+ .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 : (0, parser_1.parseBool)(value))
554
+ .option(`--maximum-file-size <maximum-file-size>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB.`, parser_1.parseInteger)
555
+ .option(`--allowed-file-extensions [allowed-file-extensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
556
+ .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`)
557
+ .option(`--encryption [value]`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
558
+ .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 : (0, parser_1.parseBool)(value))
559
+ .option(`--transformations [value]`, `Are image transformations enabled?`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
560
+ .action((0, parser_1.actionRunner)(exports.storageUpdateBucket));
561
+ exports.storage
562
+ .command(`delete-bucket`)
563
+ .description(`Delete a storage bucket by its unique ID.`)
564
+ .requiredOption(`--bucket-id <bucket-id>`, `Bucket unique ID.`)
565
+ .action((0, parser_1.actionRunner)(exports.storageDeleteBucket));
566
+ exports.storage
567
+ .command(`list-files`)
568
+ .description(`Get a list of all the user files. You can use the query params to filter your results.`)
569
+ .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).`)
570
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded`)
571
+ .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
572
+ .option(`--total [value]`, `When set to false, the total count returned will be 0 and will not be calculated.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
573
+ .option(`--console`, `Get the resource console url`)
574
+ .action((0, parser_1.actionRunner)(exports.storageListFiles));
575
+ exports.storage
576
+ .command(`create-file`)
577
+ .description(`Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of '5MB'. The 'content-range' header values should always be in bytes. When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in 'x-appwrite-id' header to allow the server to know that the partial upload is for the existing file and not for a new one. If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally. `)
578
+ .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).`)
579
+ .requiredOption(`--file-id <file-id>`, `File ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
580
+ .requiredOption(`--file <file>`, `Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file).`)
581
+ .option(`--permissions [permissions...]`, `An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).`)
582
+ .action((0, parser_1.actionRunner)(exports.storageCreateFile));
583
+ exports.storage
584
+ .command(`get-file`)
585
+ .description(`Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata.`)
586
+ .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).`)
587
+ .requiredOption(`--file-id <file-id>`, `File ID.`)
588
+ .option(`--console`, `Get the resource console url`)
589
+ .action((0, parser_1.actionRunner)(exports.storageGetFile));
590
+ exports.storage
591
+ .command(`update-file`)
592
+ .description(`Update a file by its unique ID. Only users with write permissions have access to update this resource.`)
593
+ .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).`)
594
+ .requiredOption(`--file-id <file-id>`, `File unique ID.`)
595
+ .option(`--name <name>`, `Name of the file`)
596
+ .option(`--permissions [permissions...]`, `An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).`)
597
+ .action((0, parser_1.actionRunner)(exports.storageUpdateFile));
598
+ exports.storage
599
+ .command(`delete-file`)
600
+ .description(`Delete a file by its unique ID. Only users with write permissions have access to delete this resource.`)
601
+ .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).`)
602
+ .requiredOption(`--file-id <file-id>`, `File ID.`)
603
+ .action((0, parser_1.actionRunner)(exports.storageDeleteFile));
604
+ exports.storage
605
+ .command(`get-file-download`)
606
+ .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.`)
607
+ .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).`)
608
+ .requiredOption(`--file-id <file-id>`, `File ID.`)
609
+ .option(`--token <token>`, `File token for accessing this file.`)
610
+ .requiredOption(`--destination <path>`, `output file path.`)
611
+ .action((0, parser_1.actionRunner)(exports.storageGetFileDownload));
612
+ exports.storage
613
+ .command(`get-file-preview`)
614
+ .description(`Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB.`)
615
+ .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).`)
616
+ .requiredOption(`--file-id <file-id>`, `File ID`)
617
+ .option(`--width <width>`, `Resize preview image width, Pass an integer between 0 to 4000.`, parser_1.parseInteger)
618
+ .option(`--height <height>`, `Resize preview image height, Pass an integer between 0 to 4000.`, parser_1.parseInteger)
619
+ .option(`--gravity <gravity>`, `Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right`)
620
+ .option(`--quality <quality>`, `Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.`, parser_1.parseInteger)
621
+ .option(`--border-width <border-width>`, `Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.`, parser_1.parseInteger)
622
+ .option(`--border-color <border-color>`, `Preview image border color. Use a valid HEX color, no # is needed for prefix.`)
623
+ .option(`--border-radius <border-radius>`, `Preview image border radius in pixels. Pass an integer between 0 to 4000.`, parser_1.parseInteger)
624
+ .option(`--opacity <opacity>`, `Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.`, parser_1.parseInteger)
625
+ .option(`--rotation <rotation>`, `Preview image rotation in degrees. Pass an integer between -360 and 360.`, parser_1.parseInteger)
626
+ .option(`--background <background>`, `Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.`)
627
+ .option(`--output <output>`, `Output format type (jpeg, jpg, png, gif and webp).`)
628
+ .option(`--token <token>`, `File token for accessing this file.`)
629
+ .requiredOption(`--destination <path>`, `output file path.`)
630
+ .action((0, parser_1.actionRunner)(exports.storageGetFilePreview));
631
+ exports.storage
632
+ .command(`get-file-view`)
633
+ .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.`)
634
+ .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).`)
635
+ .requiredOption(`--file-id <file-id>`, `File ID.`)
636
+ .option(`--token <token>`, `File token for accessing this file.`)
637
+ .requiredOption(`--destination <path>`, `output file path.`)
638
+ .action((0, parser_1.actionRunner)(exports.storageGetFileView));
639
+ exports.storage
640
+ .command(`get-usage`)
641
+ .description(`Get usage metrics and statistics for all buckets in the project. You can view the total number of buckets, files, storage usage. The response includes both current totals and historical data over time. 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, range defaults to 30 days. `)
642
+ .option(`--range <range>`, `Date range.`)
643
+ .action((0, parser_1.actionRunner)(exports.storageGetUsage));
644
+ exports.storage
645
+ .command(`get-bucket-usage`)
646
+ .description(`Get usage metrics and statistics a specific bucket in the project. You can view the total number of files, storage usage. The response includes both current totals and historical data over time. 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, range defaults to 30 days. `)
647
+ .requiredOption(`--bucket-id <bucket-id>`, `Bucket ID.`)
648
+ .option(`--range <range>`, `Date range.`)
649
+ .option(`--console`, `Get the resource console url`)
650
+ .action((0, parser_1.actionRunner)(exports.storageGetBucketUsage));
651
+ //# sourceMappingURL=storage.js.map