@appwrite.io/console 0.2.0 → 0.4.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 (322) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/sdk.js +3353 -1497
  3. package/dist/cjs/sdk.js.map +1 -1
  4. package/dist/esm/sdk.js +3350 -1498
  5. package/dist/esm/sdk.js.map +1 -1
  6. package/dist/iife/sdk.js +3353 -1497
  7. package/docs/examples/account/create-anonymous-session.md +1 -1
  8. package/docs/examples/account/create-email-session.md +1 -1
  9. package/docs/examples/account/create-j-w-t.md +1 -1
  10. package/docs/examples/account/create-magic-u-r-l-session.md +1 -1
  11. package/docs/examples/account/create-o-auth2session.md +1 -1
  12. package/docs/examples/account/create-phone-session.md +1 -1
  13. package/docs/examples/account/create-phone-verification.md +1 -1
  14. package/docs/examples/account/create-recovery.md +1 -1
  15. package/docs/examples/account/create-verification.md +1 -1
  16. package/docs/examples/account/create.md +1 -1
  17. package/docs/examples/account/{create-with-invite-code.md → delete-identity.md} +2 -2
  18. package/docs/examples/account/delete-session.md +1 -1
  19. package/docs/examples/account/delete-sessions.md +1 -1
  20. package/docs/examples/account/get-prefs.md +1 -1
  21. package/docs/examples/account/get-session.md +1 -1
  22. package/docs/examples/account/get.md +1 -1
  23. package/docs/examples/account/list-identities.md +18 -0
  24. package/docs/examples/account/list-logs.md +1 -1
  25. package/docs/examples/account/list-sessions.md +1 -1
  26. package/docs/examples/account/update-email.md +1 -1
  27. package/docs/examples/account/update-magic-u-r-l-session.md +1 -1
  28. package/docs/examples/account/update-name.md +1 -1
  29. package/docs/examples/account/update-password.md +1 -1
  30. package/docs/examples/account/update-phone-session.md +1 -1
  31. package/docs/examples/account/update-phone-verification.md +1 -1
  32. package/docs/examples/account/update-phone.md +1 -1
  33. package/docs/examples/account/update-prefs.md +1 -1
  34. package/docs/examples/account/update-recovery.md +1 -1
  35. package/docs/examples/account/update-session.md +1 -1
  36. package/docs/examples/account/update-status.md +1 -1
  37. package/docs/examples/account/update-verification.md +1 -1
  38. package/docs/examples/assistant/chat.md +18 -0
  39. package/docs/examples/avatars/get-browser.md +1 -1
  40. package/docs/examples/avatars/get-credit-card.md +1 -1
  41. package/docs/examples/avatars/get-favicon.md +1 -1
  42. package/docs/examples/avatars/get-flag.md +1 -1
  43. package/docs/examples/avatars/get-image.md +1 -1
  44. package/docs/examples/avatars/get-initials.md +1 -1
  45. package/docs/examples/avatars/get-q-r.md +1 -1
  46. package/docs/examples/console/variables.md +1 -1
  47. package/docs/examples/databases/create-boolean-attribute.md +1 -1
  48. package/docs/examples/databases/create-collection.md +1 -1
  49. package/docs/examples/databases/create-datetime-attribute.md +1 -1
  50. package/docs/examples/databases/create-document.md +1 -1
  51. package/docs/examples/databases/create-email-attribute.md +1 -1
  52. package/docs/examples/databases/create-enum-attribute.md +1 -1
  53. package/docs/examples/databases/create-float-attribute.md +1 -1
  54. package/docs/examples/databases/create-index.md +1 -1
  55. package/docs/examples/databases/create-integer-attribute.md +1 -1
  56. package/docs/examples/databases/create-ip-attribute.md +1 -1
  57. package/docs/examples/databases/create-relationship-attribute.md +1 -1
  58. package/docs/examples/databases/create-string-attribute.md +1 -1
  59. package/docs/examples/databases/create-url-attribute.md +1 -1
  60. package/docs/examples/databases/create.md +1 -1
  61. package/docs/examples/databases/delete-attribute.md +1 -1
  62. package/docs/examples/databases/delete-collection.md +1 -1
  63. package/docs/examples/databases/delete-document.md +1 -1
  64. package/docs/examples/databases/delete-index.md +1 -1
  65. package/docs/examples/databases/delete.md +1 -1
  66. package/docs/examples/databases/get-attribute.md +1 -1
  67. package/docs/examples/databases/get-collection-usage.md +1 -1
  68. package/docs/examples/databases/get-collection.md +1 -1
  69. package/docs/examples/databases/get-database-usage.md +1 -1
  70. package/docs/examples/databases/get-document.md +1 -1
  71. package/docs/examples/databases/get-index.md +1 -1
  72. package/docs/examples/databases/get-usage.md +1 -1
  73. package/docs/examples/databases/get.md +1 -1
  74. package/docs/examples/databases/list-attributes.md +1 -1
  75. package/docs/examples/databases/list-collection-logs.md +1 -1
  76. package/docs/examples/databases/list-collections.md +1 -1
  77. package/docs/examples/databases/list-document-logs.md +1 -1
  78. package/docs/examples/databases/list-documents.md +1 -1
  79. package/docs/examples/databases/list-indexes.md +1 -1
  80. package/docs/examples/databases/list-logs.md +1 -1
  81. package/docs/examples/databases/list.md +1 -1
  82. package/docs/examples/databases/update-boolean-attribute.md +1 -1
  83. package/docs/examples/databases/update-collection.md +1 -1
  84. package/docs/examples/databases/update-datetime-attribute.md +1 -1
  85. package/docs/examples/databases/update-document.md +1 -1
  86. package/docs/examples/databases/update-email-attribute.md +1 -1
  87. package/docs/examples/databases/update-enum-attribute.md +1 -1
  88. package/docs/examples/databases/update-float-attribute.md +1 -1
  89. package/docs/examples/databases/update-integer-attribute.md +1 -1
  90. package/docs/examples/databases/update-ip-attribute.md +1 -1
  91. package/docs/examples/databases/update-relationship-attribute.md +1 -1
  92. package/docs/examples/databases/update-string-attribute.md +1 -1
  93. package/docs/examples/databases/update-url-attribute.md +1 -1
  94. package/docs/examples/databases/update.md +1 -1
  95. package/docs/examples/functions/create-build.md +1 -1
  96. package/docs/examples/functions/create-deployment.md +2 -2
  97. package/docs/examples/functions/create-execution.md +1 -1
  98. package/docs/examples/functions/create-variable.md +1 -1
  99. package/docs/examples/functions/create.md +2 -2
  100. package/docs/examples/functions/delete-deployment.md +1 -1
  101. package/docs/examples/functions/delete-variable.md +1 -1
  102. package/docs/examples/functions/delete.md +1 -1
  103. package/docs/examples/functions/download-deployment.md +14 -0
  104. package/docs/examples/functions/get-deployment.md +1 -1
  105. package/docs/examples/functions/get-execution.md +1 -1
  106. package/docs/examples/functions/get-function-usage.md +1 -1
  107. package/docs/examples/functions/get-usage.md +1 -1
  108. package/docs/examples/functions/get-variable.md +1 -1
  109. package/docs/examples/functions/get.md +1 -1
  110. package/docs/examples/functions/list-deployments.md +1 -1
  111. package/docs/examples/functions/list-executions.md +1 -1
  112. package/docs/examples/functions/list-runtimes.md +1 -1
  113. package/docs/examples/functions/list-variables.md +1 -1
  114. package/docs/examples/functions/list.md +1 -1
  115. package/docs/examples/functions/update-deployment.md +1 -1
  116. package/docs/examples/functions/update-variable.md +1 -1
  117. package/docs/examples/functions/update.md +1 -1
  118. package/docs/examples/graphql/mutation.md +1 -1
  119. package/docs/examples/graphql/query.md +1 -1
  120. package/docs/examples/health/get-antivirus.md +1 -1
  121. package/docs/examples/health/get-cache.md +1 -1
  122. package/docs/examples/health/get-d-b.md +1 -1
  123. package/docs/examples/health/get-pub-sub.md +1 -1
  124. package/docs/examples/health/get-queue-builds.md +18 -0
  125. package/docs/examples/health/get-queue-certificates.md +1 -1
  126. package/docs/examples/health/get-queue-databases.md +18 -0
  127. package/docs/examples/health/get-queue-deletes.md +18 -0
  128. package/docs/examples/health/get-queue-functions.md +1 -1
  129. package/docs/examples/health/get-queue-logs.md +1 -1
  130. package/docs/examples/health/get-queue-mails.md +18 -0
  131. package/docs/examples/health/get-queue-messaging.md +18 -0
  132. package/docs/examples/health/get-queue-migrations.md +18 -0
  133. package/docs/examples/health/get-queue-webhooks.md +1 -1
  134. package/docs/examples/health/get-queue.md +1 -1
  135. package/docs/examples/health/get-storage-local.md +1 -1
  136. package/docs/examples/health/get-time.md +1 -1
  137. package/docs/examples/health/get.md +1 -1
  138. package/docs/examples/locale/get.md +1 -1
  139. package/docs/examples/locale/list-codes.md +18 -0
  140. package/docs/examples/locale/list-continents.md +1 -1
  141. package/docs/examples/locale/list-countries-e-u.md +1 -1
  142. package/docs/examples/locale/list-countries-phones.md +1 -1
  143. package/docs/examples/locale/list-countries.md +1 -1
  144. package/docs/examples/locale/list-currencies.md +1 -1
  145. package/docs/examples/locale/list-languages.md +1 -1
  146. package/docs/examples/migrations/create-appwrite-migration.md +18 -0
  147. package/docs/examples/migrations/create-firebase-migration.md +18 -0
  148. package/docs/examples/migrations/create-firebase-o-auth-migration.md +18 -0
  149. package/docs/examples/migrations/create-n-host-migration.md +18 -0
  150. package/docs/examples/migrations/create-supabase-migration.md +18 -0
  151. package/docs/examples/migrations/delete-firebase-auth.md +18 -0
  152. package/docs/examples/migrations/delete.md +18 -0
  153. package/docs/examples/migrations/get-appwrite-report.md +18 -0
  154. package/docs/examples/migrations/get-firebase-report-o-auth.md +18 -0
  155. package/docs/examples/migrations/get-firebase-report.md +18 -0
  156. package/docs/examples/migrations/get-n-host-report.md +18 -0
  157. package/docs/examples/migrations/get-supabase-report.md +18 -0
  158. package/docs/examples/migrations/get.md +18 -0
  159. package/docs/examples/migrations/list-firebase-projects.md +18 -0
  160. package/docs/examples/migrations/list.md +18 -0
  161. package/docs/examples/migrations/retry.md +18 -0
  162. package/docs/examples/project/create-variable.md +18 -0
  163. package/docs/examples/project/delete-variable.md +18 -0
  164. package/docs/examples/project/get-usage.md +2 -2
  165. package/docs/examples/project/get-variable.md +18 -0
  166. package/docs/examples/project/list-variables.md +18 -0
  167. package/docs/examples/project/update-variable.md +18 -0
  168. package/docs/examples/projects/create-key.md +1 -1
  169. package/docs/examples/projects/create-platform.md +1 -1
  170. package/docs/examples/projects/create-webhook.md +1 -1
  171. package/docs/examples/projects/create.md +2 -2
  172. package/docs/examples/projects/delete-email-template.md +18 -0
  173. package/docs/examples/projects/delete-key.md +1 -1
  174. package/docs/examples/projects/delete-platform.md +1 -1
  175. package/docs/examples/projects/delete-sms-template.md +18 -0
  176. package/docs/examples/projects/delete-webhook.md +1 -1
  177. package/docs/examples/projects/delete.md +2 -2
  178. package/docs/examples/projects/get-email-template.md +18 -0
  179. package/docs/examples/projects/get-key.md +1 -1
  180. package/docs/examples/projects/get-platform.md +1 -1
  181. package/docs/examples/projects/get-sms-template.md +18 -0
  182. package/docs/examples/projects/get-webhook.md +1 -1
  183. package/docs/examples/projects/get.md +1 -1
  184. package/docs/examples/projects/list-keys.md +1 -1
  185. package/docs/examples/projects/list-platforms.md +1 -1
  186. package/docs/examples/projects/list-webhooks.md +1 -1
  187. package/docs/examples/projects/list.md +1 -1
  188. package/docs/examples/projects/update-auth-duration.md +1 -1
  189. package/docs/examples/projects/update-auth-limit.md +1 -1
  190. package/docs/examples/projects/update-auth-password-dictionary.md +1 -1
  191. package/docs/examples/projects/update-auth-password-history.md +1 -1
  192. package/docs/examples/projects/update-auth-sessions-limit.md +1 -1
  193. package/docs/examples/projects/update-auth-status.md +1 -1
  194. package/docs/examples/projects/update-email-template.md +18 -0
  195. package/docs/examples/projects/update-key.md +1 -1
  196. package/docs/examples/projects/update-o-auth2.md +1 -1
  197. package/docs/examples/projects/{delete-domain.md → update-personal-data-check.md} +2 -2
  198. package/docs/examples/projects/update-platform.md +1 -1
  199. package/docs/examples/projects/{create-domain.md → update-service-status-all.md} +2 -2
  200. package/docs/examples/projects/update-service-status.md +1 -1
  201. package/docs/examples/projects/update-sms-template.md +18 -0
  202. package/docs/examples/projects/{get-domain.md → update-smtp-configuration.md} +2 -2
  203. package/docs/examples/projects/{list-domains.md → update-team.md} +2 -2
  204. package/docs/examples/projects/update-webhook-signature.md +1 -1
  205. package/docs/examples/projects/update-webhook.md +1 -1
  206. package/docs/examples/projects/update.md +1 -1
  207. package/docs/examples/proxy/create-rule.md +18 -0
  208. package/docs/examples/proxy/delete-rule.md +18 -0
  209. package/docs/examples/proxy/get-rule.md +18 -0
  210. package/docs/examples/proxy/list-rules.md +18 -0
  211. package/docs/examples/proxy/update-rule-verification.md +18 -0
  212. package/docs/examples/storage/create-bucket.md +1 -1
  213. package/docs/examples/storage/create-file.md +1 -1
  214. package/docs/examples/storage/delete-bucket.md +1 -1
  215. package/docs/examples/storage/delete-file.md +1 -1
  216. package/docs/examples/storage/get-bucket-usage.md +1 -1
  217. package/docs/examples/storage/get-bucket.md +1 -1
  218. package/docs/examples/storage/get-file-download.md +1 -1
  219. package/docs/examples/storage/get-file-preview.md +1 -1
  220. package/docs/examples/storage/get-file-view.md +1 -1
  221. package/docs/examples/storage/get-file.md +1 -1
  222. package/docs/examples/storage/get-usage.md +1 -1
  223. package/docs/examples/storage/list-buckets.md +1 -1
  224. package/docs/examples/storage/list-files.md +1 -1
  225. package/docs/examples/storage/update-bucket.md +1 -1
  226. package/docs/examples/storage/update-file.md +1 -1
  227. package/docs/examples/teams/create-membership.md +2 -2
  228. package/docs/examples/teams/create.md +1 -1
  229. package/docs/examples/teams/delete-membership.md +1 -1
  230. package/docs/examples/teams/delete.md +1 -1
  231. package/docs/examples/teams/get-membership.md +1 -1
  232. package/docs/examples/teams/get-prefs.md +1 -1
  233. package/docs/examples/teams/get.md +1 -1
  234. package/docs/examples/teams/list-logs.md +1 -1
  235. package/docs/examples/teams/list-memberships.md +1 -1
  236. package/docs/examples/teams/list.md +1 -1
  237. package/docs/examples/teams/update-membership-status.md +1 -1
  238. package/docs/examples/teams/{update-membership-roles.md → update-membership.md} +2 -2
  239. package/docs/examples/teams/update-name.md +1 -1
  240. package/docs/examples/teams/update-prefs.md +1 -1
  241. package/docs/examples/users/create-argon2user.md +1 -1
  242. package/docs/examples/users/create-bcrypt-user.md +1 -1
  243. package/docs/examples/users/create-m-d5user.md +1 -1
  244. package/docs/examples/users/create-p-h-pass-user.md +1 -1
  245. package/docs/examples/users/create-s-h-a-user.md +1 -1
  246. package/docs/examples/users/create-scrypt-modified-user.md +1 -1
  247. package/docs/examples/users/create-scrypt-user.md +1 -1
  248. package/docs/examples/users/create.md +1 -1
  249. package/docs/examples/users/delete-identity.md +18 -0
  250. package/docs/examples/users/delete-session.md +1 -1
  251. package/docs/examples/users/delete-sessions.md +1 -1
  252. package/docs/examples/users/delete.md +1 -1
  253. package/docs/examples/users/get-prefs.md +1 -1
  254. package/docs/examples/users/get-usage.md +1 -1
  255. package/docs/examples/users/get.md +1 -1
  256. package/docs/examples/users/list-identities.md +18 -0
  257. package/docs/examples/users/list-logs.md +1 -1
  258. package/docs/examples/users/list-memberships.md +1 -1
  259. package/docs/examples/users/list-sessions.md +1 -1
  260. package/docs/examples/users/list.md +1 -1
  261. package/docs/examples/users/update-email-verification.md +1 -1
  262. package/docs/examples/users/update-email.md +1 -1
  263. package/docs/examples/users/update-labels.md +18 -0
  264. package/docs/examples/users/update-name.md +1 -1
  265. package/docs/examples/users/update-password.md +1 -1
  266. package/docs/examples/users/update-phone-verification.md +1 -1
  267. package/docs/examples/users/update-phone.md +1 -1
  268. package/docs/examples/users/update-prefs.md +1 -1
  269. package/docs/examples/users/update-status.md +1 -1
  270. package/docs/examples/vcs/create-repository-detection.md +18 -0
  271. package/docs/examples/vcs/create-repository.md +18 -0
  272. package/docs/examples/vcs/delete-installation.md +18 -0
  273. package/docs/examples/vcs/get-installation.md +18 -0
  274. package/docs/examples/vcs/get-repository.md +18 -0
  275. package/docs/examples/vcs/list-installations.md +18 -0
  276. package/docs/examples/vcs/list-repositories.md +18 -0
  277. package/docs/examples/vcs/list-repository-branches.md +18 -0
  278. package/docs/examples/vcs/update-external-deployments.md +18 -0
  279. package/package.json +3 -2
  280. package/src/client.ts +2 -2
  281. package/src/index.ts +4 -0
  282. package/src/models.ts +863 -233
  283. package/src/query.ts +1 -1
  284. package/src/role.ts +72 -6
  285. package/src/services/account.ts +1052 -1055
  286. package/src/services/assistant.ts +38 -0
  287. package/src/services/avatars.ts +338 -337
  288. package/src/services/console.ts +16 -16
  289. package/src/services/databases.ts +2170 -2140
  290. package/src/services/functions.ts +804 -657
  291. package/src/services/graphql.ts +47 -47
  292. package/src/services/health.ts +373 -204
  293. package/src/services/locale.ts +156 -137
  294. package/src/services/migrations.ts +707 -0
  295. package/src/services/project.ts +178 -20
  296. package/src/services/projects.ts +1511 -1256
  297. package/src/services/proxy.ts +150 -0
  298. package/src/services/storage.ts +572 -577
  299. package/src/services/teams.ts +498 -501
  300. package/src/services/users.ts +1091 -1001
  301. package/src/services/vcs.ts +272 -0
  302. package/types/index.d.ts +4 -0
  303. package/types/models.d.ts +863 -233
  304. package/types/role.d.ts +62 -0
  305. package/types/services/account.d.ts +116 -104
  306. package/types/services/assistant.d.ts +14 -0
  307. package/types/services/avatars.d.ts +18 -17
  308. package/types/services/console.d.ts +2 -2
  309. package/types/services/databases.d.ts +111 -105
  310. package/types/services/functions.d.ts +95 -55
  311. package/types/services/graphql.d.ts +4 -4
  312. package/types/services/health.d.ts +97 -26
  313. package/types/services/locale.d.ts +24 -14
  314. package/types/services/migrations.d.ts +185 -0
  315. package/types/services/project.d.ts +60 -3
  316. package/types/services/projects.d.ts +174 -104
  317. package/types/services/proxy.d.ts +59 -0
  318. package/types/services/storage.d.ts +29 -28
  319. package/types/services/teams.d.ts +36 -35
  320. package/types/services/users.d.ts +105 -66
  321. package/types/services/vcs.d.ts +97 -0
  322. package/docs/examples/projects/update-domain-verification.md +0 -18
@@ -10,682 +10,677 @@ export class Storage extends Service {
10
10
  super(client);
11
11
  }
12
12
 
13
- /**
14
- * List buckets
15
- *
16
- * Get a list of all the storage buckets. You can use the query params to
17
- * filter your results.
18
- *
19
- * @param {string[]} queries
20
- * @param {string} search
21
- * @throws {AppwriteException}
22
- * @returns {Promise}
23
- */
24
- async listBuckets(queries?: string[], search?: string): Promise<Models.BucketList> {
25
- let path = '/storage/buckets';
26
- let payload: Payload = {};
27
-
28
- if (typeof queries !== 'undefined') {
29
- payload['queries'] = queries;
30
- }
31
-
32
- if (typeof search !== 'undefined') {
33
- payload['search'] = search;
34
- }
35
-
36
- const uri = new URL(this.client.config.endpoint + path);
37
- return await this.client.call('get', uri, {
38
- 'content-type': 'application/json',
39
- }, payload);
13
+ /**
14
+ * List buckets
15
+ *
16
+ * Get a list of all the storage buckets. You can use the query params to
17
+ * filter your results.
18
+ *
19
+ * @param {string[]} queries
20
+ * @param {string} search
21
+ * @throws {AppwriteException}
22
+ * @returns {Promise}
23
+ */
24
+ async listBuckets(queries?: string[], search?: string): Promise<Models.BucketList> {
25
+ const apiPath = '/storage/buckets';
26
+ const payload: Payload = {};
27
+
28
+ if (typeof queries !== 'undefined') {
29
+ payload['queries'] = queries;
40
30
  }
41
31
 
42
- /**
43
- * Create bucket
44
- *
45
- * Create a new storage bucket.
46
- *
47
- * @param {string} bucketId
48
- * @param {string} name
49
- * @param {string[]} permissions
50
- * @param {boolean} fileSecurity
51
- * @param {boolean} enabled
52
- * @param {number} maximumFileSize
53
- * @param {string[]} allowedFileExtensions
54
- * @param {string} compression
55
- * @param {boolean} encryption
56
- * @param {boolean} antivirus
57
- * @throws {AppwriteException}
58
- * @returns {Promise}
59
- */
60
- async createBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: string, encryption?: boolean, antivirus?: boolean): Promise<Models.Bucket> {
61
- if (typeof bucketId === 'undefined') {
62
- throw new AppwriteException('Missing required parameter: "bucketId"');
63
- }
64
-
65
- if (typeof name === 'undefined') {
66
- throw new AppwriteException('Missing required parameter: "name"');
67
- }
68
-
69
- let path = '/storage/buckets';
70
- let payload: Payload = {};
71
-
72
- if (typeof bucketId !== 'undefined') {
73
- payload['bucketId'] = bucketId;
74
- }
75
-
76
- if (typeof name !== 'undefined') {
77
- payload['name'] = name;
78
- }
79
-
80
- if (typeof permissions !== 'undefined') {
81
- payload['permissions'] = permissions;
82
- }
83
-
84
- if (typeof fileSecurity !== 'undefined') {
85
- payload['fileSecurity'] = fileSecurity;
86
- }
87
-
88
- if (typeof enabled !== 'undefined') {
89
- payload['enabled'] = enabled;
90
- }
32
+ if (typeof search !== 'undefined') {
33
+ payload['search'] = search;
34
+ }
91
35
 
92
- if (typeof maximumFileSize !== 'undefined') {
93
- payload['maximumFileSize'] = maximumFileSize;
94
- }
36
+ const uri = new URL(this.client.config.endpoint + apiPath);
37
+ return await this.client.call('get', uri, {
38
+ 'content-type': 'application/json',
39
+ }, payload);
40
+ }
41
+
42
+ /**
43
+ * Create bucket
44
+ *
45
+ * Create a new storage bucket.
46
+ *
47
+ * @param {string} bucketId
48
+ * @param {string} name
49
+ * @param {string[]} permissions
50
+ * @param {boolean} fileSecurity
51
+ * @param {boolean} enabled
52
+ * @param {number} maximumFileSize
53
+ * @param {string[]} allowedFileExtensions
54
+ * @param {string} compression
55
+ * @param {boolean} encryption
56
+ * @param {boolean} antivirus
57
+ * @throws {AppwriteException}
58
+ * @returns {Promise}
59
+ */
60
+ async createBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: string, encryption?: boolean, antivirus?: boolean): Promise<Models.Bucket> {
61
+ if (typeof bucketId === 'undefined') {
62
+ throw new AppwriteException('Missing required parameter: "bucketId"');
63
+ }
95
64
 
96
- if (typeof allowedFileExtensions !== 'undefined') {
97
- payload['allowedFileExtensions'] = allowedFileExtensions;
98
- }
65
+ if (typeof name === 'undefined') {
66
+ throw new AppwriteException('Missing required parameter: "name"');
67
+ }
99
68
 
100
- if (typeof compression !== 'undefined') {
101
- payload['compression'] = compression;
102
- }
69
+ const apiPath = '/storage/buckets';
70
+ const payload: Payload = {};
103
71
 
104
- if (typeof encryption !== 'undefined') {
105
- payload['encryption'] = encryption;
106
- }
72
+ if (typeof bucketId !== 'undefined') {
73
+ payload['bucketId'] = bucketId;
74
+ }
107
75
 
108
- if (typeof antivirus !== 'undefined') {
109
- payload['antivirus'] = antivirus;
110
- }
76
+ if (typeof name !== 'undefined') {
77
+ payload['name'] = name;
78
+ }
111
79
 
112
- const uri = new URL(this.client.config.endpoint + path);
113
- return await this.client.call('post', uri, {
114
- 'content-type': 'application/json',
115
- }, payload);
80
+ if (typeof permissions !== 'undefined') {
81
+ payload['permissions'] = permissions;
116
82
  }
117
83
 
118
- /**
119
- * Get Bucket
120
- *
121
- * Get a storage bucket by its unique ID. This endpoint response returns a
122
- * JSON object with the storage bucket metadata.
123
- *
124
- * @param {string} bucketId
125
- * @throws {AppwriteException}
126
- * @returns {Promise}
127
- */
128
- async getBucket(bucketId: string): Promise<Models.Bucket> {
129
- if (typeof bucketId === 'undefined') {
130
- throw new AppwriteException('Missing required parameter: "bucketId"');
131
- }
84
+ if (typeof fileSecurity !== 'undefined') {
85
+ payload['fileSecurity'] = fileSecurity;
86
+ }
132
87
 
133
- let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
134
- let payload: Payload = {};
88
+ if (typeof enabled !== 'undefined') {
89
+ payload['enabled'] = enabled;
90
+ }
135
91
 
136
- const uri = new URL(this.client.config.endpoint + path);
137
- return await this.client.call('get', uri, {
138
- 'content-type': 'application/json',
139
- }, payload);
92
+ if (typeof maximumFileSize !== 'undefined') {
93
+ payload['maximumFileSize'] = maximumFileSize;
140
94
  }
141
95
 
142
- /**
143
- * Update Bucket
144
- *
145
- * Update a storage bucket by its unique ID.
146
- *
147
- * @param {string} bucketId
148
- * @param {string} name
149
- * @param {string[]} permissions
150
- * @param {boolean} fileSecurity
151
- * @param {boolean} enabled
152
- * @param {number} maximumFileSize
153
- * @param {string[]} allowedFileExtensions
154
- * @param {string} compression
155
- * @param {boolean} encryption
156
- * @param {boolean} antivirus
157
- * @throws {AppwriteException}
158
- * @returns {Promise}
159
- */
160
- async updateBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: string, encryption?: boolean, antivirus?: boolean): Promise<Models.Bucket> {
161
- if (typeof bucketId === 'undefined') {
162
- throw new AppwriteException('Missing required parameter: "bucketId"');
163
- }
96
+ if (typeof allowedFileExtensions !== 'undefined') {
97
+ payload['allowedFileExtensions'] = allowedFileExtensions;
98
+ }
164
99
 
165
- if (typeof name === 'undefined') {
166
- throw new AppwriteException('Missing required parameter: "name"');
167
- }
100
+ if (typeof compression !== 'undefined') {
101
+ payload['compression'] = compression;
102
+ }
168
103
 
169
- let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
170
- let payload: Payload = {};
104
+ if (typeof encryption !== 'undefined') {
105
+ payload['encryption'] = encryption;
106
+ }
171
107
 
172
- if (typeof name !== 'undefined') {
173
- payload['name'] = name;
174
- }
108
+ if (typeof antivirus !== 'undefined') {
109
+ payload['antivirus'] = antivirus;
110
+ }
175
111
 
176
- if (typeof permissions !== 'undefined') {
177
- payload['permissions'] = permissions;
178
- }
112
+ const uri = new URL(this.client.config.endpoint + apiPath);
113
+ return await this.client.call('post', uri, {
114
+ 'content-type': 'application/json',
115
+ }, payload);
116
+ }
117
+
118
+ /**
119
+ * Get bucket
120
+ *
121
+ * Get a storage bucket by its unique ID. This endpoint response returns a
122
+ * JSON object with the storage bucket metadata.
123
+ *
124
+ * @param {string} bucketId
125
+ * @throws {AppwriteException}
126
+ * @returns {Promise}
127
+ */
128
+ async getBucket(bucketId: string): Promise<Models.Bucket> {
129
+ if (typeof bucketId === 'undefined') {
130
+ throw new AppwriteException('Missing required parameter: "bucketId"');
131
+ }
179
132
 
180
- if (typeof fileSecurity !== 'undefined') {
181
- payload['fileSecurity'] = fileSecurity;
182
- }
133
+ const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
134
+ const payload: Payload = {};
135
+
136
+ const uri = new URL(this.client.config.endpoint + apiPath);
137
+ return await this.client.call('get', uri, {
138
+ 'content-type': 'application/json',
139
+ }, payload);
140
+ }
141
+
142
+ /**
143
+ * Update bucket
144
+ *
145
+ * Update a storage bucket by its unique ID.
146
+ *
147
+ * @param {string} bucketId
148
+ * @param {string} name
149
+ * @param {string[]} permissions
150
+ * @param {boolean} fileSecurity
151
+ * @param {boolean} enabled
152
+ * @param {number} maximumFileSize
153
+ * @param {string[]} allowedFileExtensions
154
+ * @param {string} compression
155
+ * @param {boolean} encryption
156
+ * @param {boolean} antivirus
157
+ * @throws {AppwriteException}
158
+ * @returns {Promise}
159
+ */
160
+ async updateBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: string, encryption?: boolean, antivirus?: boolean): Promise<Models.Bucket> {
161
+ if (typeof bucketId === 'undefined') {
162
+ throw new AppwriteException('Missing required parameter: "bucketId"');
163
+ }
183
164
 
184
- if (typeof enabled !== 'undefined') {
185
- payload['enabled'] = enabled;
186
- }
165
+ if (typeof name === 'undefined') {
166
+ throw new AppwriteException('Missing required parameter: "name"');
167
+ }
187
168
 
188
- if (typeof maximumFileSize !== 'undefined') {
189
- payload['maximumFileSize'] = maximumFileSize;
190
- }
169
+ const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
170
+ const payload: Payload = {};
191
171
 
192
- if (typeof allowedFileExtensions !== 'undefined') {
193
- payload['allowedFileExtensions'] = allowedFileExtensions;
194
- }
172
+ if (typeof name !== 'undefined') {
173
+ payload['name'] = name;
174
+ }
195
175
 
196
- if (typeof compression !== 'undefined') {
197
- payload['compression'] = compression;
198
- }
176
+ if (typeof permissions !== 'undefined') {
177
+ payload['permissions'] = permissions;
178
+ }
199
179
 
200
- if (typeof encryption !== 'undefined') {
201
- payload['encryption'] = encryption;
202
- }
180
+ if (typeof fileSecurity !== 'undefined') {
181
+ payload['fileSecurity'] = fileSecurity;
182
+ }
203
183
 
204
- if (typeof antivirus !== 'undefined') {
205
- payload['antivirus'] = antivirus;
206
- }
184
+ if (typeof enabled !== 'undefined') {
185
+ payload['enabled'] = enabled;
186
+ }
207
187
 
208
- const uri = new URL(this.client.config.endpoint + path);
209
- return await this.client.call('put', uri, {
210
- 'content-type': 'application/json',
211
- }, payload);
188
+ if (typeof maximumFileSize !== 'undefined') {
189
+ payload['maximumFileSize'] = maximumFileSize;
212
190
  }
213
191
 
214
- /**
215
- * Delete Bucket
216
- *
217
- * Delete a storage bucket by its unique ID.
218
- *
219
- * @param {string} bucketId
220
- * @throws {AppwriteException}
221
- * @returns {Promise}
222
- */
223
- async deleteBucket(bucketId: string): Promise<{}> {
224
- if (typeof bucketId === 'undefined') {
225
- throw new AppwriteException('Missing required parameter: "bucketId"');
226
- }
192
+ if (typeof allowedFileExtensions !== 'undefined') {
193
+ payload['allowedFileExtensions'] = allowedFileExtensions;
194
+ }
227
195
 
228
- let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
229
- let payload: Payload = {};
196
+ if (typeof compression !== 'undefined') {
197
+ payload['compression'] = compression;
198
+ }
230
199
 
231
- const uri = new URL(this.client.config.endpoint + path);
232
- return await this.client.call('delete', uri, {
233
- 'content-type': 'application/json',
234
- }, payload);
200
+ if (typeof encryption !== 'undefined') {
201
+ payload['encryption'] = encryption;
235
202
  }
236
203
 
237
- /**
238
- * List Files
239
- *
240
- * Get a list of all the user files. You can use the query params to filter
241
- * your results.
242
- *
243
- * @param {string} bucketId
244
- * @param {string[]} queries
245
- * @param {string} search
246
- * @throws {AppwriteException}
247
- * @returns {Promise}
248
- */
249
- async listFiles(bucketId: string, queries?: string[], search?: string): Promise<Models.FileList> {
250
- if (typeof bucketId === 'undefined') {
251
- throw new AppwriteException('Missing required parameter: "bucketId"');
252
- }
204
+ if (typeof antivirus !== 'undefined') {
205
+ payload['antivirus'] = antivirus;
206
+ }
253
207
 
254
- let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
255
- let payload: Payload = {};
208
+ const uri = new URL(this.client.config.endpoint + apiPath);
209
+ return await this.client.call('put', uri, {
210
+ 'content-type': 'application/json',
211
+ }, payload);
212
+ }
213
+
214
+ /**
215
+ * Delete bucket
216
+ *
217
+ * Delete a storage bucket by its unique ID.
218
+ *
219
+ * @param {string} bucketId
220
+ * @throws {AppwriteException}
221
+ * @returns {Promise}
222
+ */
223
+ async deleteBucket(bucketId: string): Promise<{}> {
224
+ if (typeof bucketId === 'undefined') {
225
+ throw new AppwriteException('Missing required parameter: "bucketId"');
226
+ }
256
227
 
257
- if (typeof queries !== 'undefined') {
258
- payload['queries'] = queries;
259
- }
228
+ const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
229
+ const payload: Payload = {};
230
+
231
+ const uri = new URL(this.client.config.endpoint + apiPath);
232
+ return await this.client.call('delete', uri, {
233
+ 'content-type': 'application/json',
234
+ }, payload);
235
+ }
236
+
237
+ /**
238
+ * List files
239
+ *
240
+ * Get a list of all the user files. You can use the query params to filter
241
+ * your results.
242
+ *
243
+ * @param {string} bucketId
244
+ * @param {string[]} queries
245
+ * @param {string} search
246
+ * @throws {AppwriteException}
247
+ * @returns {Promise}
248
+ */
249
+ async listFiles(bucketId: string, queries?: string[], search?: string): Promise<Models.FileList> {
250
+ if (typeof bucketId === 'undefined') {
251
+ throw new AppwriteException('Missing required parameter: "bucketId"');
252
+ }
260
253
 
261
- if (typeof search !== 'undefined') {
262
- payload['search'] = search;
263
- }
254
+ const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
255
+ const payload: Payload = {};
264
256
 
265
- const uri = new URL(this.client.config.endpoint + path);
266
- return await this.client.call('get', uri, {
267
- 'content-type': 'application/json',
268
- }, payload);
257
+ if (typeof queries !== 'undefined') {
258
+ payload['queries'] = queries;
269
259
  }
270
260
 
271
- /**
272
- * Create File
273
- *
274
- * Create a new file. Before using this route, you should create a new bucket
275
- * resource using either a [server
276
- * integration](/docs/server/storage#storageCreateBucket) API or directly from
277
- * your Appwrite console.
278
- *
279
- * Larger files should be uploaded using multiple requests with the
280
- * [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range)
281
- * header to send a partial request with a maximum supported chunk of `5MB`.
282
- * The `content-range` header values should always be in bytes.
283
- *
284
- * When the first request is sent, the server will return the **File** object,
285
- * and the subsequent part request must include the file's **id** in
286
- * `x-appwrite-id` header to allow the server to know that the partial upload
287
- * is for the existing file and not for a new one.
288
- *
289
- * If you're creating a new file using one of the Appwrite SDKs, all the
290
- * chunking logic will be managed by the SDK internally.
291
- *
292
- *
293
- * @param {string} bucketId
294
- * @param {string} fileId
295
- * @param {File} file
296
- * @param {string[]} permissions
297
- * @throws {AppwriteException}
298
- * @returns {Promise}
299
- */
300
- async createFile(bucketId: string, fileId: string, file: File, permissions?: string[], onProgress = (progress: UploadProgress) => {}): Promise<Models.File> {
301
- if (typeof bucketId === 'undefined') {
302
- throw new AppwriteException('Missing required parameter: "bucketId"');
303
- }
304
-
305
- if (typeof fileId === 'undefined') {
306
- throw new AppwriteException('Missing required parameter: "fileId"');
307
- }
261
+ if (typeof search !== 'undefined') {
262
+ payload['search'] = search;
263
+ }
308
264
 
309
- if (typeof file === 'undefined') {
310
- throw new AppwriteException('Missing required parameter: "file"');
311
- }
265
+ const uri = new URL(this.client.config.endpoint + apiPath);
266
+ return await this.client.call('get', uri, {
267
+ 'content-type': 'application/json',
268
+ }, payload);
269
+ }
270
+
271
+ /**
272
+ * Create file
273
+ *
274
+ * Create a new file. Before using this route, you should create a new bucket
275
+ * resource using either a [server
276
+ * integration](https://appwrite.io/docs/server/storage#storageCreateBucket)
277
+ * API or directly from your Appwrite console.
278
+ *
279
+ * Larger files should be uploaded using multiple requests with the
280
+ * [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range)
281
+ * header to send a partial request with a maximum supported chunk of `5MB`.
282
+ * The `content-range` header values should always be in bytes.
283
+ *
284
+ * When the first request is sent, the server will return the **File** object,
285
+ * and the subsequent part request must include the file's **id** in
286
+ * `x-appwrite-id` header to allow the server to know that the partial upload
287
+ * is for the existing file and not for a new one.
288
+ *
289
+ * If you're creating a new file using one of the Appwrite SDKs, all the
290
+ * chunking logic will be managed by the SDK internally.
291
+ *
292
+ *
293
+ * @param {string} bucketId
294
+ * @param {string} fileId
295
+ * @param {File} file
296
+ * @param {string[]} permissions
297
+ * @throws {AppwriteException}
298
+ * @returns {Promise}
299
+ */
300
+ async createFile(bucketId: string, fileId: string, file: File, permissions?: string[], onProgress = (progress: UploadProgress) => {}): Promise<Models.File> {
301
+ if (typeof bucketId === 'undefined') {
302
+ throw new AppwriteException('Missing required parameter: "bucketId"');
303
+ }
312
304
 
313
- let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
314
- let payload: Payload = {};
305
+ if (typeof fileId === 'undefined') {
306
+ throw new AppwriteException('Missing required parameter: "fileId"');
307
+ }
315
308
 
316
- if (typeof fileId !== 'undefined') {
317
- payload['fileId'] = fileId;
318
- }
309
+ if (typeof file === 'undefined') {
310
+ throw new AppwriteException('Missing required parameter: "file"');
311
+ }
319
312
 
320
- if (typeof file !== 'undefined') {
321
- payload['file'] = file;
322
- }
313
+ const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
314
+ const payload: Payload = {};
323
315
 
324
- if (typeof permissions !== 'undefined') {
325
- payload['permissions'] = permissions;
326
- }
316
+ if (typeof fileId !== 'undefined') {
317
+ payload['fileId'] = fileId;
318
+ }
327
319
 
328
- const uri = new URL(this.client.config.endpoint + path);
320
+ if (typeof file !== 'undefined') {
321
+ payload['file'] = file;
322
+ }
329
323
 
330
- if(!(file instanceof File)) {
331
- throw new AppwriteException('Parameter "file" has to be a File.');
332
- }
324
+ if (typeof permissions !== 'undefined') {
325
+ payload['permissions'] = permissions;
326
+ }
333
327
 
334
- const size = file.size;
328
+ const uri = new URL(this.client.config.endpoint + apiPath);
335
329
 
336
- if (size <= Service.CHUNK_SIZE) {
337
- return await this.client.call('post', uri, {
330
+ if(!(file instanceof File)) {
331
+ throw new AppwriteException('Parameter "file" has to be a File.');
332
+ }
338
333
 
339
- 'content-type': 'multipart/form-data',
340
- }, payload);
341
- }
342
- let id = undefined;
343
- let response = undefined;
334
+ const size = file.size;
344
335
 
345
- const headers: { [header: string]: string } = {
336
+ if (size <= Service.CHUNK_SIZE) {
337
+ return await this.client.call('post', uri, {
346
338
  'content-type': 'multipart/form-data',
347
- }
348
-
349
- let counter = 0;
350
- const totalCounters = Math.ceil(size / Service.CHUNK_SIZE);
351
- if(fileId != 'unique()') {
352
- try {
353
- response = await this.client.call('GET', new URL(this.client.config.endpoint + path + '/' + fileId), headers);
354
- counter = response.chunksUploaded;
355
- } catch(e) {
356
- }
357
- }
358
-
359
- for (counter; counter < totalCounters; counter++) {
360
- const start = (counter * Service.CHUNK_SIZE);
361
- const end = Math.min((((counter * Service.CHUNK_SIZE) + Service.CHUNK_SIZE) - 1), size);
362
-
363
- headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size
364
-
365
- if (id) {
366
- headers['x-appwrite-id'] = id;
367
- }
368
-
369
- const stream = file.slice(start, end + 1);
370
- payload['file'] = new File([stream], file.name);
371
-
372
- response = await this.client.call('post', uri, headers, payload);
339
+ }, payload);
340
+ }
373
341
 
374
- if (!id) {
375
- id = response['$id'];
376
- }
342
+ const apiHeaders: { [header: string]: string } = {
343
+ 'content-type': 'multipart/form-data',
344
+ }
377
345
 
378
- if (onProgress) {
379
- onProgress({
380
- $id: response.$id,
381
- progress: Math.min((counter + 1) * Service.CHUNK_SIZE - 1, size) / size * 100,
382
- sizeUploaded: end,
383
- chunksTotal: response.chunksTotal,
384
- chunksUploaded: response.chunksUploaded
385
- });
386
- }
346
+ let offset = 0;
347
+ let response = undefined;
348
+ if(fileId != 'unique()') {
349
+ try {
350
+ response = await this.client.call('GET', new URL(this.client.config.endpoint + apiPath + '/' + fileId), apiHeaders);
351
+ offset = response.chunksUploaded * Service.CHUNK_SIZE;
352
+ } catch(e) {
387
353
  }
354
+ }
388
355
 
389
- return response;
390
- }
391
-
392
- /**
393
- * Get File
394
- *
395
- * Get a file by its unique ID. This endpoint response returns a JSON object
396
- * with the file metadata.
397
- *
398
- * @param {string} bucketId
399
- * @param {string} fileId
400
- * @throws {AppwriteException}
401
- * @returns {Promise}
402
- */
403
- async getFile(bucketId: string, fileId: string): Promise<Models.File> {
404
- if (typeof bucketId === 'undefined') {
405
- throw new AppwriteException('Missing required parameter: "bucketId"');
406
- }
356
+ while (offset < size) {
357
+ let end = Math.min(offset + Service.CHUNK_SIZE - 1, size - 1);
407
358
 
408
- if (typeof fileId === 'undefined') {
409
- throw new AppwriteException('Missing required parameter: "fileId"');
359
+ apiHeaders['content-range'] = 'bytes ' + offset + '-' + end + '/' + size;
360
+ if (response && response.$id) {
361
+ apiHeaders['x-appwrite-id'] = response.$id;
410
362
  }
411
363
 
412
- let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
413
- let payload: Payload = {};
364
+ const chunk = file.slice(offset, end + 1);
365
+ payload['file'] = new File([chunk], file.name);
366
+ response = await this.client.call('post', uri, apiHeaders, payload);
414
367
 
415
- const uri = new URL(this.client.config.endpoint + path);
416
- return await this.client.call('get', uri, {
417
- 'content-type': 'application/json',
418
- }, payload);
419
- }
420
-
421
- /**
422
- * Update File
423
- *
424
- * Update a file by its unique ID. Only users with write permissions have
425
- * access to update this resource.
426
- *
427
- * @param {string} bucketId
428
- * @param {string} fileId
429
- * @param {string[]} permissions
430
- * @throws {AppwriteException}
431
- * @returns {Promise}
432
- */
433
- async updateFile(bucketId: string, fileId: string, permissions?: string[]): Promise<Models.File> {
434
- if (typeof bucketId === 'undefined') {
435
- throw new AppwriteException('Missing required parameter: "bucketId"');
436
- }
437
-
438
- if (typeof fileId === 'undefined') {
439
- throw new AppwriteException('Missing required parameter: "fileId"');
368
+ if (onProgress) {
369
+ onProgress({
370
+ $id: response.$id,
371
+ progress: (offset / size) * 100,
372
+ sizeUploaded: offset,
373
+ chunksTotal: response.chunksTotal,
374
+ chunksUploaded: response.chunksUploaded
375
+ });
440
376
  }
377
+ offset += Service.CHUNK_SIZE;
378
+ }
379
+ return response;
380
+ }
381
+
382
+ /**
383
+ * Get file
384
+ *
385
+ * Get a file by its unique ID. This endpoint response returns a JSON object
386
+ * with the file metadata.
387
+ *
388
+ * @param {string} bucketId
389
+ * @param {string} fileId
390
+ * @throws {AppwriteException}
391
+ * @returns {Promise}
392
+ */
393
+ async getFile(bucketId: string, fileId: string): Promise<Models.File> {
394
+ if (typeof bucketId === 'undefined') {
395
+ throw new AppwriteException('Missing required parameter: "bucketId"');
396
+ }
441
397
 
442
- let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
443
- let payload: Payload = {};
398
+ if (typeof fileId === 'undefined') {
399
+ throw new AppwriteException('Missing required parameter: "fileId"');
400
+ }
444
401
 
445
- if (typeof permissions !== 'undefined') {
446
- payload['permissions'] = permissions;
447
- }
402
+ const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
403
+ const payload: Payload = {};
404
+
405
+ const uri = new URL(this.client.config.endpoint + apiPath);
406
+ return await this.client.call('get', uri, {
407
+ 'content-type': 'application/json',
408
+ }, payload);
409
+ }
410
+
411
+ /**
412
+ * Update file
413
+ *
414
+ * Update a file by its unique ID. Only users with write permissions have
415
+ * access to update this resource.
416
+ *
417
+ * @param {string} bucketId
418
+ * @param {string} fileId
419
+ * @param {string} name
420
+ * @param {string[]} permissions
421
+ * @throws {AppwriteException}
422
+ * @returns {Promise}
423
+ */
424
+ async updateFile(bucketId: string, fileId: string, name?: string, permissions?: string[]): Promise<Models.File> {
425
+ if (typeof bucketId === 'undefined') {
426
+ throw new AppwriteException('Missing required parameter: "bucketId"');
427
+ }
448
428
 
449
- const uri = new URL(this.client.config.endpoint + path);
450
- return await this.client.call('put', uri, {
451
- 'content-type': 'application/json',
452
- }, payload);
429
+ if (typeof fileId === 'undefined') {
430
+ throw new AppwriteException('Missing required parameter: "fileId"');
453
431
  }
454
432
 
455
- /**
456
- * Delete File
457
- *
458
- * Delete a file by its unique ID. Only users with write permissions have
459
- * access to delete this resource.
460
- *
461
- * @param {string} bucketId
462
- * @param {string} fileId
463
- * @throws {AppwriteException}
464
- * @returns {Promise}
465
- */
466
- async deleteFile(bucketId: string, fileId: string): Promise<{}> {
467
- if (typeof bucketId === 'undefined') {
468
- throw new AppwriteException('Missing required parameter: "bucketId"');
469
- }
433
+ const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
434
+ const payload: Payload = {};
470
435
 
471
- if (typeof fileId === 'undefined') {
472
- throw new AppwriteException('Missing required parameter: "fileId"');
473
- }
436
+ if (typeof name !== 'undefined') {
437
+ payload['name'] = name;
438
+ }
474
439
 
475
- let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
476
- let payload: Payload = {};
440
+ if (typeof permissions !== 'undefined') {
441
+ payload['permissions'] = permissions;
442
+ }
477
443
 
478
- const uri = new URL(this.client.config.endpoint + path);
479
- return await this.client.call('delete', uri, {
480
- 'content-type': 'application/json',
481
- }, payload);
444
+ const uri = new URL(this.client.config.endpoint + apiPath);
445
+ return await this.client.call('put', uri, {
446
+ 'content-type': 'application/json',
447
+ }, payload);
448
+ }
449
+
450
+ /**
451
+ * Delete File
452
+ *
453
+ * Delete a file by its unique ID. Only users with write permissions have
454
+ * access to delete this resource.
455
+ *
456
+ * @param {string} bucketId
457
+ * @param {string} fileId
458
+ * @throws {AppwriteException}
459
+ * @returns {Promise}
460
+ */
461
+ async deleteFile(bucketId: string, fileId: string): Promise<{}> {
462
+ if (typeof bucketId === 'undefined') {
463
+ throw new AppwriteException('Missing required parameter: "bucketId"');
482
464
  }
483
465
 
484
- /**
485
- * Get File for Download
486
- *
487
- * Get a file content by its unique ID. The endpoint response return with a
488
- * 'Content-Disposition: attachment' header that tells the browser to start
489
- * downloading the file to user downloads directory.
490
- *
491
- * @param {string} bucketId
492
- * @param {string} fileId
493
- * @throws {AppwriteException}
494
- * @returns {URL}
495
- */
496
- getFileDownload(bucketId: string, fileId: string): URL {
497
- if (typeof bucketId === 'undefined') {
498
- throw new AppwriteException('Missing required parameter: "bucketId"');
499
- }
466
+ if (typeof fileId === 'undefined') {
467
+ throw new AppwriteException('Missing required parameter: "fileId"');
468
+ }
500
469
 
501
- if (typeof fileId === 'undefined') {
502
- throw new AppwriteException('Missing required parameter: "fileId"');
503
- }
470
+ const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
471
+ const payload: Payload = {};
472
+
473
+ const uri = new URL(this.client.config.endpoint + apiPath);
474
+ return await this.client.call('delete', uri, {
475
+ 'content-type': 'application/json',
476
+ }, payload);
477
+ }
478
+
479
+ /**
480
+ * Get file for download
481
+ *
482
+ * Get a file content by its unique ID. The endpoint response return with a
483
+ * 'Content-Disposition: attachment' header that tells the browser to start
484
+ * downloading the file to user downloads directory.
485
+ *
486
+ * @param {string} bucketId
487
+ * @param {string} fileId
488
+ * @throws {AppwriteException}
489
+ * @returns {URL}
490
+ */
491
+ getFileDownload(bucketId: string, fileId: string): URL {
492
+ if (typeof bucketId === 'undefined') {
493
+ throw new AppwriteException('Missing required parameter: "bucketId"');
494
+ }
504
495
 
505
- let path = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
506
- let payload: Payload = {};
496
+ if (typeof fileId === 'undefined') {
497
+ throw new AppwriteException('Missing required parameter: "fileId"');
498
+ }
507
499
 
508
- const uri = new URL(this.client.config.endpoint + path);
509
- payload['project'] = this.client.config.project;
500
+ const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
501
+ const payload: Payload = {};
510
502
 
503
+ const uri = new URL(this.client.config.endpoint + apiPath);
504
+ payload['project'] = this.client.config.project;
511
505
 
512
- for (const [key, value] of Object.entries(Service.flatten(payload))) {
513
- uri.searchParams.append(key, value);
514
- }
515
- return uri;
516
- }
517
-
518
- /**
519
- * Get File Preview
520
- *
521
- * Get a file preview image. Currently, this method supports preview for image
522
- * files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
523
- * and spreadsheets, will return the file icon image. You can also pass query
524
- * string arguments for cutting and resizing your preview image. Preview is
525
- * supported only for image files smaller than 10MB.
526
- *
527
- * @param {string} bucketId
528
- * @param {string} fileId
529
- * @param {number} width
530
- * @param {number} height
531
- * @param {string} gravity
532
- * @param {number} quality
533
- * @param {number} borderWidth
534
- * @param {string} borderColor
535
- * @param {number} borderRadius
536
- * @param {number} opacity
537
- * @param {number} rotation
538
- * @param {string} background
539
- * @param {string} output
540
- * @throws {AppwriteException}
541
- * @returns {URL}
542
- */
543
- getFilePreview(bucketId: string, fileId: string, width?: number, height?: number, gravity?: string, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: string): URL {
544
- if (typeof bucketId === 'undefined') {
545
- throw new AppwriteException('Missing required parameter: "bucketId"');
546
- }
547
506
 
548
- if (typeof fileId === 'undefined') {
549
- throw new AppwriteException('Missing required parameter: "fileId"');
550
- }
507
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
508
+ uri.searchParams.append(key, value);
509
+ }
510
+ return uri;
511
+ }
512
+
513
+ /**
514
+ * Get file preview
515
+ *
516
+ * Get a file preview image. Currently, this method supports preview for image
517
+ * files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
518
+ * and spreadsheets, will return the file icon image. You can also pass query
519
+ * string arguments for cutting and resizing your preview image. Preview is
520
+ * supported only for image files smaller than 10MB.
521
+ *
522
+ * @param {string} bucketId
523
+ * @param {string} fileId
524
+ * @param {number} width
525
+ * @param {number} height
526
+ * @param {string} gravity
527
+ * @param {number} quality
528
+ * @param {number} borderWidth
529
+ * @param {string} borderColor
530
+ * @param {number} borderRadius
531
+ * @param {number} opacity
532
+ * @param {number} rotation
533
+ * @param {string} background
534
+ * @param {string} output
535
+ * @throws {AppwriteException}
536
+ * @returns {URL}
537
+ */
538
+ getFilePreview(bucketId: string, fileId: string, width?: number, height?: number, gravity?: string, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: string): URL {
539
+ if (typeof bucketId === 'undefined') {
540
+ throw new AppwriteException('Missing required parameter: "bucketId"');
541
+ }
551
542
 
552
- let path = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
553
- let payload: Payload = {};
543
+ if (typeof fileId === 'undefined') {
544
+ throw new AppwriteException('Missing required parameter: "fileId"');
545
+ }
554
546
 
555
- if (typeof width !== 'undefined') {
556
- payload['width'] = width;
557
- }
547
+ const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
548
+ const payload: Payload = {};
558
549
 
559
- if (typeof height !== 'undefined') {
560
- payload['height'] = height;
561
- }
550
+ if (typeof width !== 'undefined') {
551
+ payload['width'] = width;
552
+ }
562
553
 
563
- if (typeof gravity !== 'undefined') {
564
- payload['gravity'] = gravity;
565
- }
554
+ if (typeof height !== 'undefined') {
555
+ payload['height'] = height;
556
+ }
566
557
 
567
- if (typeof quality !== 'undefined') {
568
- payload['quality'] = quality;
569
- }
558
+ if (typeof gravity !== 'undefined') {
559
+ payload['gravity'] = gravity;
560
+ }
570
561
 
571
- if (typeof borderWidth !== 'undefined') {
572
- payload['borderWidth'] = borderWidth;
573
- }
562
+ if (typeof quality !== 'undefined') {
563
+ payload['quality'] = quality;
564
+ }
574
565
 
575
- if (typeof borderColor !== 'undefined') {
576
- payload['borderColor'] = borderColor;
577
- }
566
+ if (typeof borderWidth !== 'undefined') {
567
+ payload['borderWidth'] = borderWidth;
568
+ }
578
569
 
579
- if (typeof borderRadius !== 'undefined') {
580
- payload['borderRadius'] = borderRadius;
581
- }
570
+ if (typeof borderColor !== 'undefined') {
571
+ payload['borderColor'] = borderColor;
572
+ }
582
573
 
583
- if (typeof opacity !== 'undefined') {
584
- payload['opacity'] = opacity;
585
- }
574
+ if (typeof borderRadius !== 'undefined') {
575
+ payload['borderRadius'] = borderRadius;
576
+ }
586
577
 
587
- if (typeof rotation !== 'undefined') {
588
- payload['rotation'] = rotation;
589
- }
578
+ if (typeof opacity !== 'undefined') {
579
+ payload['opacity'] = opacity;
580
+ }
590
581
 
591
- if (typeof background !== 'undefined') {
592
- payload['background'] = background;
593
- }
582
+ if (typeof rotation !== 'undefined') {
583
+ payload['rotation'] = rotation;
584
+ }
594
585
 
595
- if (typeof output !== 'undefined') {
596
- payload['output'] = output;
597
- }
586
+ if (typeof background !== 'undefined') {
587
+ payload['background'] = background;
588
+ }
598
589
 
599
- const uri = new URL(this.client.config.endpoint + path);
600
- payload['project'] = this.client.config.project;
590
+ if (typeof output !== 'undefined') {
591
+ payload['output'] = output;
592
+ }
601
593
 
594
+ const uri = new URL(this.client.config.endpoint + apiPath);
595
+ payload['project'] = this.client.config.project;
602
596
 
603
- for (const [key, value] of Object.entries(Service.flatten(payload))) {
604
- uri.searchParams.append(key, value);
605
- }
606
- return uri;
607
- }
608
-
609
- /**
610
- * Get File for View
611
- *
612
- * Get a file content by its unique ID. This endpoint is similar to the
613
- * download method but returns with no 'Content-Disposition: attachment'
614
- * header.
615
- *
616
- * @param {string} bucketId
617
- * @param {string} fileId
618
- * @throws {AppwriteException}
619
- * @returns {URL}
620
- */
621
- getFileView(bucketId: string, fileId: string): URL {
622
- if (typeof bucketId === 'undefined') {
623
- throw new AppwriteException('Missing required parameter: "bucketId"');
624
- }
625
597
 
626
- if (typeof fileId === 'undefined') {
627
- throw new AppwriteException('Missing required parameter: "fileId"');
628
- }
598
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
599
+ uri.searchParams.append(key, value);
600
+ }
601
+ return uri;
602
+ }
603
+
604
+ /**
605
+ * Get file for view
606
+ *
607
+ * Get a file content by its unique ID. This endpoint is similar to the
608
+ * download method but returns with no 'Content-Disposition: attachment'
609
+ * header.
610
+ *
611
+ * @param {string} bucketId
612
+ * @param {string} fileId
613
+ * @throws {AppwriteException}
614
+ * @returns {URL}
615
+ */
616
+ getFileView(bucketId: string, fileId: string): URL {
617
+ if (typeof bucketId === 'undefined') {
618
+ throw new AppwriteException('Missing required parameter: "bucketId"');
619
+ }
629
620
 
630
- let path = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
631
- let payload: Payload = {};
621
+ if (typeof fileId === 'undefined') {
622
+ throw new AppwriteException('Missing required parameter: "fileId"');
623
+ }
632
624
 
633
- const uri = new URL(this.client.config.endpoint + path);
634
- payload['project'] = this.client.config.project;
625
+ const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
626
+ const payload: Payload = {};
635
627
 
628
+ const uri = new URL(this.client.config.endpoint + apiPath);
629
+ payload['project'] = this.client.config.project;
636
630
 
637
- for (const [key, value] of Object.entries(Service.flatten(payload))) {
638
- uri.searchParams.append(key, value);
639
- }
640
- return uri;
641
- }
642
-
643
- /**
644
- * Get usage stats for storage
645
- *
646
- *
647
- * @param {string} range
648
- * @throws {AppwriteException}
649
- * @returns {Promise}
650
- */
651
- async getUsage(range?: string): Promise<Models.UsageStorage> {
652
- let path = '/storage/usage';
653
- let payload: Payload = {};
654
-
655
- if (typeof range !== 'undefined') {
656
- payload['range'] = range;
657
- }
658
631
 
659
- const uri = new URL(this.client.config.endpoint + path);
660
- return await this.client.call('get', uri, {
661
- 'content-type': 'application/json',
662
- }, payload);
632
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
633
+ uri.searchParams.append(key, value);
634
+ }
635
+ return uri;
636
+ }
637
+
638
+ /**
639
+ * Get usage stats for storage
640
+ *
641
+ *
642
+ * @param {string} range
643
+ * @throws {AppwriteException}
644
+ * @returns {Promise}
645
+ */
646
+ async getUsage(range?: string): Promise<Models.UsageStorage> {
647
+ const apiPath = '/storage/usage';
648
+ const payload: Payload = {};
649
+
650
+ if (typeof range !== 'undefined') {
651
+ payload['range'] = range;
663
652
  }
664
653
 
665
- /**
666
- * Get usage stats for storage bucket
667
- *
668
- *
669
- * @param {string} bucketId
670
- * @param {string} range
671
- * @throws {AppwriteException}
672
- * @returns {Promise}
673
- */
674
- async getBucketUsage(bucketId: string, range?: string): Promise<Models.UsageBuckets> {
675
- if (typeof bucketId === 'undefined') {
676
- throw new AppwriteException('Missing required parameter: "bucketId"');
677
- }
678
-
679
- let path = '/storage/{bucketId}/usage'.replace('{bucketId}', bucketId);
680
- let payload: Payload = {};
654
+ const uri = new URL(this.client.config.endpoint + apiPath);
655
+ return await this.client.call('get', uri, {
656
+ 'content-type': 'application/json',
657
+ }, payload);
658
+ }
659
+
660
+ /**
661
+ * Get usage stats for storage bucket
662
+ *
663
+ *
664
+ * @param {string} bucketId
665
+ * @param {string} range
666
+ * @throws {AppwriteException}
667
+ * @returns {Promise}
668
+ */
669
+ async getBucketUsage(bucketId: string, range?: string): Promise<Models.UsageBuckets> {
670
+ if (typeof bucketId === 'undefined') {
671
+ throw new AppwriteException('Missing required parameter: "bucketId"');
672
+ }
681
673
 
682
- if (typeof range !== 'undefined') {
683
- payload['range'] = range;
684
- }
674
+ const apiPath = '/storage/{bucketId}/usage'.replace('{bucketId}', bucketId);
675
+ const payload: Payload = {};
685
676
 
686
- const uri = new URL(this.client.config.endpoint + path);
687
- return await this.client.call('get', uri, {
688
- 'content-type': 'application/json',
689
- }, payload);
677
+ if (typeof range !== 'undefined') {
678
+ payload['range'] = range;
690
679
  }
680
+
681
+ const uri = new URL(this.client.config.endpoint + apiPath);
682
+ return await this.client.call('get', uri, {
683
+ 'content-type': 'application/json',
684
+ }, payload);
685
+ }
691
686
  };