@appwrite.io/console 0.2.0 → 0.3.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 (314) hide show
  1. package/dist/cjs/sdk.js +2332 -633
  2. package/dist/cjs/sdk.js.map +1 -1
  3. package/dist/esm/sdk.js +2329 -634
  4. package/dist/esm/sdk.js.map +1 -1
  5. package/dist/iife/sdk.js +2332 -633
  6. package/docs/examples/account/create-anonymous-session.md +1 -1
  7. package/docs/examples/account/create-email-session.md +1 -1
  8. package/docs/examples/account/create-j-w-t.md +1 -1
  9. package/docs/examples/account/create-magic-u-r-l-session.md +1 -1
  10. package/docs/examples/account/create-o-auth2session.md +1 -1
  11. package/docs/examples/account/create-phone-session.md +1 -1
  12. package/docs/examples/account/create-phone-verification.md +1 -1
  13. package/docs/examples/account/create-recovery.md +1 -1
  14. package/docs/examples/account/create-verification.md +1 -1
  15. package/docs/examples/account/create-with-invite-code.md +1 -1
  16. package/docs/examples/account/create.md +1 -1
  17. package/docs/examples/account/delete-identity.md +18 -0
  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 +1 -1
  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 +2 -2
  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-certificates.md +1 -1
  125. package/docs/examples/health/get-queue-functions.md +1 -1
  126. package/docs/examples/health/get-queue-logs.md +1 -1
  127. package/docs/examples/health/get-queue-webhooks.md +1 -1
  128. package/docs/examples/health/get-queue.md +1 -1
  129. package/docs/examples/health/get-storage-local.md +1 -1
  130. package/docs/examples/health/get-time.md +1 -1
  131. package/docs/examples/health/get.md +1 -1
  132. package/docs/examples/locale/get.md +1 -1
  133. package/docs/examples/locale/list-codes.md +18 -0
  134. package/docs/examples/locale/list-continents.md +1 -1
  135. package/docs/examples/locale/list-countries-e-u.md +1 -1
  136. package/docs/examples/locale/list-countries-phones.md +1 -1
  137. package/docs/examples/locale/list-countries.md +1 -1
  138. package/docs/examples/locale/list-currencies.md +1 -1
  139. package/docs/examples/locale/list-languages.md +1 -1
  140. package/docs/examples/migrations/create-appwrite-migration.md +18 -0
  141. package/docs/examples/migrations/create-firebase-migration.md +18 -0
  142. package/docs/examples/migrations/create-firebase-o-auth-migration.md +18 -0
  143. package/docs/examples/migrations/create-n-host-migration.md +18 -0
  144. package/docs/examples/migrations/create-supabase-migration.md +18 -0
  145. package/docs/examples/migrations/delete-firebase-auth.md +18 -0
  146. package/docs/examples/migrations/delete.md +18 -0
  147. package/docs/examples/migrations/get-appwrite-report.md +18 -0
  148. package/docs/examples/migrations/get-firebase-report-o-auth.md +18 -0
  149. package/docs/examples/migrations/get-firebase-report.md +18 -0
  150. package/docs/examples/migrations/get-n-host-report.md +18 -0
  151. package/docs/examples/migrations/get-supabase-report.md +18 -0
  152. package/docs/examples/migrations/get.md +18 -0
  153. package/docs/examples/migrations/list-firebase-projects.md +18 -0
  154. package/docs/examples/migrations/list.md +18 -0
  155. package/docs/examples/migrations/retry.md +18 -0
  156. package/docs/examples/project/create-variable.md +18 -0
  157. package/docs/examples/project/delete-variable.md +18 -0
  158. package/docs/examples/project/get-usage.md +1 -1
  159. package/docs/examples/project/get-variable.md +18 -0
  160. package/docs/examples/project/list-variables.md +18 -0
  161. package/docs/examples/project/update-variable.md +18 -0
  162. package/docs/examples/projects/create-key.md +1 -1
  163. package/docs/examples/projects/create-platform.md +1 -1
  164. package/docs/examples/projects/create-webhook.md +1 -1
  165. package/docs/examples/projects/create.md +2 -2
  166. package/docs/examples/projects/delete-email-template.md +18 -0
  167. package/docs/examples/projects/delete-key.md +1 -1
  168. package/docs/examples/projects/delete-platform.md +1 -1
  169. package/docs/examples/projects/delete-sms-template.md +18 -0
  170. package/docs/examples/projects/delete-webhook.md +1 -1
  171. package/docs/examples/projects/delete.md +2 -2
  172. package/docs/examples/projects/get-email-template.md +18 -0
  173. package/docs/examples/projects/get-key.md +1 -1
  174. package/docs/examples/projects/get-platform.md +1 -1
  175. package/docs/examples/projects/get-sms-template.md +18 -0
  176. package/docs/examples/projects/{list-domains.md → get-usage.md} +2 -2
  177. package/docs/examples/projects/get-webhook.md +1 -1
  178. package/docs/examples/projects/get.md +1 -1
  179. package/docs/examples/projects/list-keys.md +1 -1
  180. package/docs/examples/projects/list-platforms.md +1 -1
  181. package/docs/examples/projects/list-webhooks.md +1 -1
  182. package/docs/examples/projects/list.md +1 -1
  183. package/docs/examples/projects/update-auth-duration.md +1 -1
  184. package/docs/examples/projects/update-auth-limit.md +1 -1
  185. package/docs/examples/projects/update-auth-password-dictionary.md +1 -1
  186. package/docs/examples/projects/update-auth-password-history.md +1 -1
  187. package/docs/examples/projects/update-auth-sessions-limit.md +1 -1
  188. package/docs/examples/projects/update-auth-status.md +1 -1
  189. package/docs/examples/projects/update-email-template.md +18 -0
  190. package/docs/examples/projects/update-key.md +1 -1
  191. package/docs/examples/projects/update-o-auth2.md +1 -1
  192. package/docs/examples/projects/{get-domain.md → update-personal-data-check.md} +2 -2
  193. package/docs/examples/projects/update-platform.md +1 -1
  194. package/docs/examples/projects/{delete-domain.md → update-service-status-all.md} +2 -2
  195. package/docs/examples/projects/update-service-status.md +1 -1
  196. package/docs/examples/projects/update-sms-template.md +18 -0
  197. package/docs/examples/projects/update-smtp-configuration.md +18 -0
  198. package/docs/examples/projects/{create-domain.md → update-team.md} +2 -2
  199. package/docs/examples/projects/update-webhook-signature.md +1 -1
  200. package/docs/examples/projects/update-webhook.md +1 -1
  201. package/docs/examples/projects/update.md +1 -1
  202. package/docs/examples/proxy/create-rule.md +18 -0
  203. package/docs/examples/proxy/delete-rule.md +18 -0
  204. package/docs/examples/proxy/get-rule.md +18 -0
  205. package/docs/examples/proxy/list-rules.md +18 -0
  206. package/docs/examples/proxy/update-rule-verification.md +18 -0
  207. package/docs/examples/storage/create-bucket.md +1 -1
  208. package/docs/examples/storage/create-file.md +1 -1
  209. package/docs/examples/storage/delete-bucket.md +1 -1
  210. package/docs/examples/storage/delete-file.md +1 -1
  211. package/docs/examples/storage/get-bucket-usage.md +1 -1
  212. package/docs/examples/storage/get-bucket.md +1 -1
  213. package/docs/examples/storage/get-file-download.md +1 -1
  214. package/docs/examples/storage/get-file-preview.md +1 -1
  215. package/docs/examples/storage/get-file-view.md +1 -1
  216. package/docs/examples/storage/get-file.md +1 -1
  217. package/docs/examples/storage/get-usage.md +1 -1
  218. package/docs/examples/storage/list-buckets.md +1 -1
  219. package/docs/examples/storage/list-files.md +1 -1
  220. package/docs/examples/storage/update-bucket.md +1 -1
  221. package/docs/examples/storage/update-file.md +1 -1
  222. package/docs/examples/teams/create-membership.md +1 -1
  223. package/docs/examples/teams/create.md +1 -1
  224. package/docs/examples/teams/delete-membership.md +1 -1
  225. package/docs/examples/teams/delete.md +1 -1
  226. package/docs/examples/teams/get-membership.md +1 -1
  227. package/docs/examples/teams/get-prefs.md +1 -1
  228. package/docs/examples/teams/get.md +1 -1
  229. package/docs/examples/teams/list-logs.md +1 -1
  230. package/docs/examples/teams/list-memberships.md +1 -1
  231. package/docs/examples/teams/list.md +1 -1
  232. package/docs/examples/teams/update-membership-status.md +1 -1
  233. package/docs/examples/teams/{update-membership-roles.md → update-membership.md} +2 -2
  234. package/docs/examples/teams/update-name.md +1 -1
  235. package/docs/examples/teams/update-prefs.md +1 -1
  236. package/docs/examples/users/create-argon2user.md +1 -1
  237. package/docs/examples/users/create-bcrypt-user.md +1 -1
  238. package/docs/examples/users/create-m-d5user.md +1 -1
  239. package/docs/examples/users/create-p-h-pass-user.md +1 -1
  240. package/docs/examples/users/create-s-h-a-user.md +1 -1
  241. package/docs/examples/users/create-scrypt-modified-user.md +1 -1
  242. package/docs/examples/users/create-scrypt-user.md +1 -1
  243. package/docs/examples/users/create.md +1 -1
  244. package/docs/examples/users/delete-identity.md +18 -0
  245. package/docs/examples/users/delete-session.md +1 -1
  246. package/docs/examples/users/delete-sessions.md +1 -1
  247. package/docs/examples/users/delete.md +1 -1
  248. package/docs/examples/users/get-prefs.md +1 -1
  249. package/docs/examples/users/get-usage.md +1 -1
  250. package/docs/examples/users/get.md +1 -1
  251. package/docs/examples/users/list-identities.md +18 -0
  252. package/docs/examples/users/list-logs.md +1 -1
  253. package/docs/examples/users/list-memberships.md +1 -1
  254. package/docs/examples/users/list-sessions.md +1 -1
  255. package/docs/examples/users/list.md +1 -1
  256. package/docs/examples/users/update-email-verification.md +1 -1
  257. package/docs/examples/users/update-email.md +1 -1
  258. package/docs/examples/users/update-labels.md +18 -0
  259. package/docs/examples/users/update-name.md +1 -1
  260. package/docs/examples/users/update-password.md +1 -1
  261. package/docs/examples/users/update-phone-verification.md +1 -1
  262. package/docs/examples/users/update-phone.md +1 -1
  263. package/docs/examples/users/update-prefs.md +1 -1
  264. package/docs/examples/users/update-status.md +1 -1
  265. package/docs/examples/vcs/create-repository-detection.md +18 -0
  266. package/docs/examples/vcs/create-repository.md +18 -0
  267. package/docs/examples/vcs/delete-installation.md +18 -0
  268. package/docs/examples/vcs/get-installation.md +18 -0
  269. package/docs/examples/vcs/get-repository.md +18 -0
  270. package/docs/examples/vcs/list-installations.md +18 -0
  271. package/docs/examples/vcs/list-repositories.md +18 -0
  272. package/docs/examples/vcs/list-repository-branches.md +18 -0
  273. package/docs/examples/vcs/update-external-deployments.md +18 -0
  274. package/package.json +1 -1
  275. package/src/client.ts +2 -2
  276. package/src/index.ts +4 -0
  277. package/src/models.ts +905 -114
  278. package/src/services/account.ts +1102 -1055
  279. package/src/services/assistant.ts +38 -0
  280. package/src/services/avatars.ts +337 -337
  281. package/src/services/console.ts +16 -16
  282. package/src/services/databases.ts +2170 -2140
  283. package/src/services/functions.ts +808 -652
  284. package/src/services/graphql.ts +47 -47
  285. package/src/services/health.ts +226 -226
  286. package/src/services/locale.ts +156 -137
  287. package/src/services/migrations.ts +707 -0
  288. package/src/services/project.ts +160 -20
  289. package/src/services/projects.ts +1538 -1256
  290. package/src/services/proxy.ts +150 -0
  291. package/src/services/storage.ts +576 -571
  292. package/src/services/teams.ts +502 -501
  293. package/src/services/users.ts +1094 -1001
  294. package/src/services/vcs.ts +272 -0
  295. package/types/index.d.ts +4 -0
  296. package/types/models.d.ts +905 -114
  297. package/types/services/account.d.ts +62 -41
  298. package/types/services/assistant.d.ts +14 -0
  299. package/types/services/avatars.d.ts +7 -7
  300. package/types/services/console.d.ts +1 -1
  301. package/types/services/databases.d.ts +60 -54
  302. package/types/services/functions.d.ts +66 -31
  303. package/types/services/graphql.d.ts +2 -2
  304. package/types/services/health.d.ts +12 -12
  305. package/types/services/locale.d.ts +17 -7
  306. package/types/services/migrations.d.ts +185 -0
  307. package/types/services/project.d.ts +56 -1
  308. package/types/services/projects.d.ts +159 -79
  309. package/types/services/proxy.d.ts +59 -0
  310. package/types/services/storage.d.ts +18 -17
  311. package/types/services/teams.d.ts +17 -16
  312. package/types/services/users.d.ts +65 -27
  313. package/types/services/vcs.d.ts +97 -0
  314. package/docs/examples/projects/update-domain-verification.md +0 -18
@@ -10,682 +10,687 @@ 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
+ let path = '/storage/buckets';
26
+ let 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
- }
32
+ if (typeof search !== 'undefined') {
33
+ payload['search'] = search;
34
+ }
68
35
 
69
- let path = '/storage/buckets';
70
- let payload: Payload = {};
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);
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
+ }
71
64
 
72
- if (typeof bucketId !== 'undefined') {
73
- payload['bucketId'] = bucketId;
74
- }
65
+ if (typeof name === 'undefined') {
66
+ throw new AppwriteException('Missing required parameter: "name"');
67
+ }
75
68
 
76
- if (typeof name !== 'undefined') {
77
- payload['name'] = name;
78
- }
69
+ let path = '/storage/buckets';
70
+ let payload: Payload = {};
79
71
 
80
- if (typeof permissions !== 'undefined') {
81
- payload['permissions'] = permissions;
82
- }
72
+ if (typeof bucketId !== 'undefined') {
73
+ payload['bucketId'] = bucketId;
74
+ }
83
75
 
84
- if (typeof fileSecurity !== 'undefined') {
85
- payload['fileSecurity'] = fileSecurity;
86
- }
76
+ if (typeof name !== 'undefined') {
77
+ payload['name'] = name;
78
+ }
87
79
 
88
- if (typeof enabled !== 'undefined') {
89
- payload['enabled'] = enabled;
90
- }
80
+ if (typeof permissions !== 'undefined') {
81
+ payload['permissions'] = permissions;
82
+ }
91
83
 
92
- if (typeof maximumFileSize !== 'undefined') {
93
- payload['maximumFileSize'] = maximumFileSize;
94
- }
84
+ if (typeof fileSecurity !== 'undefined') {
85
+ payload['fileSecurity'] = fileSecurity;
86
+ }
95
87
 
96
- if (typeof allowedFileExtensions !== 'undefined') {
97
- payload['allowedFileExtensions'] = allowedFileExtensions;
98
- }
88
+ if (typeof enabled !== 'undefined') {
89
+ payload['enabled'] = enabled;
90
+ }
99
91
 
100
- if (typeof compression !== 'undefined') {
101
- payload['compression'] = compression;
102
- }
92
+ if (typeof maximumFileSize !== 'undefined') {
93
+ payload['maximumFileSize'] = maximumFileSize;
94
+ }
103
95
 
104
- if (typeof encryption !== 'undefined') {
105
- payload['encryption'] = encryption;
106
- }
96
+ if (typeof allowedFileExtensions !== 'undefined') {
97
+ payload['allowedFileExtensions'] = allowedFileExtensions;
98
+ }
107
99
 
108
- if (typeof antivirus !== 'undefined') {
109
- payload['antivirus'] = antivirus;
110
- }
100
+ if (typeof compression !== 'undefined') {
101
+ payload['compression'] = compression;
102
+ }
111
103
 
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);
104
+ if (typeof encryption !== 'undefined') {
105
+ payload['encryption'] = encryption;
116
106
  }
117
107
 
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
- }
108
+ if (typeof antivirus !== 'undefined') {
109
+ payload['antivirus'] = antivirus;
110
+ }
132
111
 
133
- let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
134
- let payload: Payload = {};
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);
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
+ }
135
132
 
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);
133
+ let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
134
+ let payload: Payload = {};
135
+
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);
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"');
140
163
  }
141
164
 
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
- }
165
+ if (typeof name === 'undefined') {
166
+ throw new AppwriteException('Missing required parameter: "name"');
167
+ }
164
168
 
165
- if (typeof name === 'undefined') {
166
- throw new AppwriteException('Missing required parameter: "name"');
167
- }
169
+ let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
170
+ let payload: Payload = {};
168
171
 
169
- let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
170
- let payload: Payload = {};
172
+ if (typeof name !== 'undefined') {
173
+ payload['name'] = name;
174
+ }
171
175
 
172
- if (typeof name !== 'undefined') {
173
- payload['name'] = name;
174
- }
176
+ if (typeof permissions !== 'undefined') {
177
+ payload['permissions'] = permissions;
178
+ }
175
179
 
176
- if (typeof permissions !== 'undefined') {
177
- payload['permissions'] = permissions;
178
- }
180
+ if (typeof fileSecurity !== 'undefined') {
181
+ payload['fileSecurity'] = fileSecurity;
182
+ }
179
183
 
180
- if (typeof fileSecurity !== 'undefined') {
181
- payload['fileSecurity'] = fileSecurity;
182
- }
184
+ if (typeof enabled !== 'undefined') {
185
+ payload['enabled'] = enabled;
186
+ }
183
187
 
184
- if (typeof enabled !== 'undefined') {
185
- payload['enabled'] = enabled;
186
- }
188
+ if (typeof maximumFileSize !== 'undefined') {
189
+ payload['maximumFileSize'] = maximumFileSize;
190
+ }
187
191
 
188
- if (typeof maximumFileSize !== 'undefined') {
189
- payload['maximumFileSize'] = maximumFileSize;
190
- }
192
+ if (typeof allowedFileExtensions !== 'undefined') {
193
+ payload['allowedFileExtensions'] = allowedFileExtensions;
194
+ }
191
195
 
192
- if (typeof allowedFileExtensions !== 'undefined') {
193
- payload['allowedFileExtensions'] = allowedFileExtensions;
194
- }
196
+ if (typeof compression !== 'undefined') {
197
+ payload['compression'] = compression;
198
+ }
195
199
 
196
- if (typeof compression !== 'undefined') {
197
- payload['compression'] = compression;
198
- }
200
+ if (typeof encryption !== 'undefined') {
201
+ payload['encryption'] = encryption;
202
+ }
199
203
 
200
- if (typeof encryption !== 'undefined') {
201
- payload['encryption'] = encryption;
202
- }
204
+ if (typeof antivirus !== 'undefined') {
205
+ payload['antivirus'] = antivirus;
206
+ }
203
207
 
204
- if (typeof antivirus !== 'undefined') {
205
- payload['antivirus'] = antivirus;
206
- }
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);
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
+ }
207
227
 
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);
228
+ let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
229
+ let payload: Payload = {};
230
+
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);
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"');
212
252
  }
213
253
 
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
- }
254
+ let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
255
+ let payload: Payload = {};
227
256
 
228
- let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
229
- let payload: Payload = {};
257
+ if (typeof queries !== 'undefined') {
258
+ payload['queries'] = queries;
259
+ }
230
260
 
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);
261
+ if (typeof search !== 'undefined') {
262
+ payload['search'] = search;
235
263
  }
236
264
 
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
- }
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);
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](/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
+ }
253
304
 
254
- let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
255
- let payload: Payload = {};
305
+ if (typeof fileId === 'undefined') {
306
+ throw new AppwriteException('Missing required parameter: "fileId"');
307
+ }
256
308
 
257
- if (typeof queries !== 'undefined') {
258
- payload['queries'] = queries;
259
- }
309
+ if (typeof file === 'undefined') {
310
+ throw new AppwriteException('Missing required parameter: "file"');
311
+ }
260
312
 
261
- if (typeof search !== 'undefined') {
262
- payload['search'] = search;
263
- }
313
+ let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
314
+ let payload: Payload = {};
264
315
 
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);
316
+ if (typeof fileId !== 'undefined') {
317
+ payload['fileId'] = fileId;
269
318
  }
270
319
 
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
- }
320
+ if (typeof file !== 'undefined') {
321
+ payload['file'] = file;
322
+ }
304
323
 
305
- if (typeof fileId === 'undefined') {
306
- throw new AppwriteException('Missing required parameter: "fileId"');
307
- }
324
+ if (typeof permissions !== 'undefined') {
325
+ payload['permissions'] = permissions;
326
+ }
308
327
 
309
- if (typeof file === 'undefined') {
310
- throw new AppwriteException('Missing required parameter: "file"');
311
- }
328
+ const uri = new URL(this.client.config.endpoint + path);
312
329
 
313
- let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
314
- let payload: Payload = {};
330
+ if(!(file instanceof File)) {
331
+ throw new AppwriteException('Parameter "file" has to be a File.');
332
+ }
315
333
 
316
- if (typeof fileId !== 'undefined') {
317
- payload['fileId'] = fileId;
318
- }
334
+ const size = file.size;
319
335
 
320
- if (typeof file !== 'undefined') {
321
- payload['file'] = file;
322
- }
336
+ if (size <= Service.CHUNK_SIZE) {
337
+ return await this.client.call('post', uri, {
323
338
 
324
- if (typeof permissions !== 'undefined') {
325
- payload['permissions'] = permissions;
326
- }
339
+ 'content-type': 'multipart/form-data',
340
+ }, payload);
341
+ }
342
+ let id = undefined;
343
+ let response = undefined;
327
344
 
328
- const uri = new URL(this.client.config.endpoint + path);
345
+ const headers: { [header: string]: string } = {
346
+ 'content-type': 'multipart/form-data',
347
+ }
329
348
 
330
- if(!(file instanceof File)) {
331
- throw new AppwriteException('Parameter "file" has to be a File.');
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) {
332
356
  }
357
+ }
333
358
 
334
- const size = file.size;
335
-
336
- if (size <= Service.CHUNK_SIZE) {
337
- return await this.client.call('post', uri, {
338
-
339
- 'content-type': 'multipart/form-data',
340
- }, payload);
341
- }
342
- let id = undefined;
343
- let response = undefined;
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);
344
362
 
345
- const headers: { [header: string]: string } = {
346
- 'content-type': 'multipart/form-data',
347
- }
363
+ headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size
348
364
 
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
- }
365
+ if (id) {
366
+ headers['x-appwrite-id'] = id;
357
367
  }
358
368
 
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
- }
369
+ const stream = file.slice(start, end + 1);
370
+ payload['file'] = new File([stream], file.name);
368
371
 
369
- const stream = file.slice(start, end + 1);
370
- payload['file'] = new File([stream], file.name);
372
+ response = await this.client.call('post', uri, headers, payload);
371
373
 
372
- response = await this.client.call('post', uri, headers, payload);
373
-
374
- if (!id) {
375
- id = response['$id'];
376
- }
377
-
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
- }
374
+ if (!id) {
375
+ id = response['$id'];
387
376
  }
388
377
 
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"');
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
+ });
406
386
  }
407
-
408
- if (typeof fileId === 'undefined') {
409
- throw new AppwriteException('Missing required parameter: "fileId"');
410
- }
411
-
412
- let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
413
- let payload: Payload = {};
414
-
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
387
  }
420
388
 
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"');
440
- }
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
+ }
441
407
 
442
- let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
443
- let payload: Payload = {};
408
+ if (typeof fileId === 'undefined') {
409
+ throw new AppwriteException('Missing required parameter: "fileId"');
410
+ }
444
411
 
445
- if (typeof permissions !== 'undefined') {
446
- payload['permissions'] = permissions;
447
- }
412
+ let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
413
+ let payload: Payload = {};
414
+
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} name
430
+ * @param {string[]} permissions
431
+ * @throws {AppwriteException}
432
+ * @returns {Promise}
433
+ */
434
+ async updateFile(bucketId: string, fileId: string, name?: string, permissions?: string[]): Promise<Models.File> {
435
+ if (typeof bucketId === 'undefined') {
436
+ throw new AppwriteException('Missing required parameter: "bucketId"');
437
+ }
448
438
 
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);
439
+ if (typeof fileId === 'undefined') {
440
+ throw new AppwriteException('Missing required parameter: "fileId"');
453
441
  }
454
442
 
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
- }
443
+ let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
444
+ let payload: Payload = {};
470
445
 
471
- if (typeof fileId === 'undefined') {
472
- throw new AppwriteException('Missing required parameter: "fileId"');
473
- }
446
+ if (typeof name !== 'undefined') {
447
+ payload['name'] = name;
448
+ }
474
449
 
475
- let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
476
- let payload: Payload = {};
450
+ if (typeof permissions !== 'undefined') {
451
+ payload['permissions'] = permissions;
452
+ }
477
453
 
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);
454
+ const uri = new URL(this.client.config.endpoint + path);
455
+ return await this.client.call('put', uri, {
456
+ 'content-type': 'application/json',
457
+ }, payload);
458
+ }
459
+
460
+ /**
461
+ * Delete File
462
+ *
463
+ * Delete a file by its unique ID. Only users with write permissions have
464
+ * access to delete this resource.
465
+ *
466
+ * @param {string} bucketId
467
+ * @param {string} fileId
468
+ * @throws {AppwriteException}
469
+ * @returns {Promise}
470
+ */
471
+ async deleteFile(bucketId: string, fileId: string): Promise<{}> {
472
+ if (typeof bucketId === 'undefined') {
473
+ throw new AppwriteException('Missing required parameter: "bucketId"');
482
474
  }
483
475
 
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
- }
476
+ if (typeof fileId === 'undefined') {
477
+ throw new AppwriteException('Missing required parameter: "fileId"');
478
+ }
500
479
 
501
- if (typeof fileId === 'undefined') {
502
- throw new AppwriteException('Missing required parameter: "fileId"');
503
- }
480
+ let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
481
+ let payload: Payload = {};
482
+
483
+ const uri = new URL(this.client.config.endpoint + path);
484
+ return await this.client.call('delete', uri, {
485
+ 'content-type': 'application/json',
486
+ }, payload);
487
+ }
488
+
489
+ /**
490
+ * Get File for Download
491
+ *
492
+ * Get a file content by its unique ID. The endpoint response return with a
493
+ * 'Content-Disposition: attachment' header that tells the browser to start
494
+ * downloading the file to user downloads directory.
495
+ *
496
+ * @param {string} bucketId
497
+ * @param {string} fileId
498
+ * @throws {AppwriteException}
499
+ * @returns {URL}
500
+ */
501
+ getFileDownload(bucketId: string, fileId: string): URL {
502
+ if (typeof bucketId === 'undefined') {
503
+ throw new AppwriteException('Missing required parameter: "bucketId"');
504
+ }
504
505
 
505
- let path = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
506
- let payload: Payload = {};
506
+ if (typeof fileId === 'undefined') {
507
+ throw new AppwriteException('Missing required parameter: "fileId"');
508
+ }
507
509
 
508
- const uri = new URL(this.client.config.endpoint + path);
509
- payload['project'] = this.client.config.project;
510
+ let path = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
511
+ let payload: Payload = {};
510
512
 
513
+ const uri = new URL(this.client.config.endpoint + path);
514
+ payload['project'] = this.client.config.project;
511
515
 
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
516
 
548
- if (typeof fileId === 'undefined') {
549
- throw new AppwriteException('Missing required parameter: "fileId"');
550
- }
517
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
518
+ uri.searchParams.append(key, value);
519
+ }
520
+ return uri;
521
+ }
522
+
523
+ /**
524
+ * Get File Preview
525
+ *
526
+ * Get a file preview image. Currently, this method supports preview for image
527
+ * files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
528
+ * and spreadsheets, will return the file icon image. You can also pass query
529
+ * string arguments for cutting and resizing your preview image. Preview is
530
+ * supported only for image files smaller than 10MB.
531
+ *
532
+ * @param {string} bucketId
533
+ * @param {string} fileId
534
+ * @param {number} width
535
+ * @param {number} height
536
+ * @param {string} gravity
537
+ * @param {number} quality
538
+ * @param {number} borderWidth
539
+ * @param {string} borderColor
540
+ * @param {number} borderRadius
541
+ * @param {number} opacity
542
+ * @param {number} rotation
543
+ * @param {string} background
544
+ * @param {string} output
545
+ * @throws {AppwriteException}
546
+ * @returns {URL}
547
+ */
548
+ 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 {
549
+ if (typeof bucketId === 'undefined') {
550
+ throw new AppwriteException('Missing required parameter: "bucketId"');
551
+ }
551
552
 
552
- let path = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
553
- let payload: Payload = {};
553
+ if (typeof fileId === 'undefined') {
554
+ throw new AppwriteException('Missing required parameter: "fileId"');
555
+ }
554
556
 
555
- if (typeof width !== 'undefined') {
556
- payload['width'] = width;
557
- }
557
+ let path = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
558
+ let payload: Payload = {};
558
559
 
559
- if (typeof height !== 'undefined') {
560
- payload['height'] = height;
561
- }
560
+ if (typeof width !== 'undefined') {
561
+ payload['width'] = width;
562
+ }
562
563
 
563
- if (typeof gravity !== 'undefined') {
564
- payload['gravity'] = gravity;
565
- }
564
+ if (typeof height !== 'undefined') {
565
+ payload['height'] = height;
566
+ }
566
567
 
567
- if (typeof quality !== 'undefined') {
568
- payload['quality'] = quality;
569
- }
568
+ if (typeof gravity !== 'undefined') {
569
+ payload['gravity'] = gravity;
570
+ }
570
571
 
571
- if (typeof borderWidth !== 'undefined') {
572
- payload['borderWidth'] = borderWidth;
573
- }
572
+ if (typeof quality !== 'undefined') {
573
+ payload['quality'] = quality;
574
+ }
574
575
 
575
- if (typeof borderColor !== 'undefined') {
576
- payload['borderColor'] = borderColor;
577
- }
576
+ if (typeof borderWidth !== 'undefined') {
577
+ payload['borderWidth'] = borderWidth;
578
+ }
578
579
 
579
- if (typeof borderRadius !== 'undefined') {
580
- payload['borderRadius'] = borderRadius;
581
- }
580
+ if (typeof borderColor !== 'undefined') {
581
+ payload['borderColor'] = borderColor;
582
+ }
582
583
 
583
- if (typeof opacity !== 'undefined') {
584
- payload['opacity'] = opacity;
585
- }
584
+ if (typeof borderRadius !== 'undefined') {
585
+ payload['borderRadius'] = borderRadius;
586
+ }
586
587
 
587
- if (typeof rotation !== 'undefined') {
588
- payload['rotation'] = rotation;
589
- }
588
+ if (typeof opacity !== 'undefined') {
589
+ payload['opacity'] = opacity;
590
+ }
590
591
 
591
- if (typeof background !== 'undefined') {
592
- payload['background'] = background;
593
- }
592
+ if (typeof rotation !== 'undefined') {
593
+ payload['rotation'] = rotation;
594
+ }
594
595
 
595
- if (typeof output !== 'undefined') {
596
- payload['output'] = output;
597
- }
596
+ if (typeof background !== 'undefined') {
597
+ payload['background'] = background;
598
+ }
598
599
 
599
- const uri = new URL(this.client.config.endpoint + path);
600
- payload['project'] = this.client.config.project;
600
+ if (typeof output !== 'undefined') {
601
+ payload['output'] = output;
602
+ }
601
603
 
604
+ const uri = new URL(this.client.config.endpoint + path);
605
+ payload['project'] = this.client.config.project;
602
606
 
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
607
 
626
- if (typeof fileId === 'undefined') {
627
- throw new AppwriteException('Missing required parameter: "fileId"');
628
- }
608
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
609
+ uri.searchParams.append(key, value);
610
+ }
611
+ return uri;
612
+ }
613
+
614
+ /**
615
+ * Get File for View
616
+ *
617
+ * Get a file content by its unique ID. This endpoint is similar to the
618
+ * download method but returns with no 'Content-Disposition: attachment'
619
+ * header.
620
+ *
621
+ * @param {string} bucketId
622
+ * @param {string} fileId
623
+ * @throws {AppwriteException}
624
+ * @returns {URL}
625
+ */
626
+ getFileView(bucketId: string, fileId: string): URL {
627
+ if (typeof bucketId === 'undefined') {
628
+ throw new AppwriteException('Missing required parameter: "bucketId"');
629
+ }
629
630
 
630
- let path = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
631
- let payload: Payload = {};
631
+ if (typeof fileId === 'undefined') {
632
+ throw new AppwriteException('Missing required parameter: "fileId"');
633
+ }
632
634
 
633
- const uri = new URL(this.client.config.endpoint + path);
634
- payload['project'] = this.client.config.project;
635
+ let path = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
636
+ let payload: Payload = {};
635
637
 
638
+ const uri = new URL(this.client.config.endpoint + path);
639
+ payload['project'] = this.client.config.project;
636
640
 
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
641
 
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);
642
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
643
+ uri.searchParams.append(key, value);
644
+ }
645
+ return uri;
646
+ }
647
+
648
+ /**
649
+ * Get usage stats for storage
650
+ *
651
+ *
652
+ * @param {string} range
653
+ * @throws {AppwriteException}
654
+ * @returns {Promise}
655
+ */
656
+ async getUsage(range?: string): Promise<Models.UsageStorage> {
657
+ let path = '/storage/usage';
658
+ let payload: Payload = {};
659
+
660
+ if (typeof range !== 'undefined') {
661
+ payload['range'] = range;
663
662
  }
664
663
 
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 = {};
664
+ const uri = new URL(this.client.config.endpoint + path);
665
+ return await this.client.call('get', uri, {
666
+ 'content-type': 'application/json',
667
+ }, payload);
668
+ }
669
+
670
+ /**
671
+ * Get usage stats for a storage bucket
672
+ *
673
+ *
674
+ * @param {string} bucketId
675
+ * @param {string} range
676
+ * @throws {AppwriteException}
677
+ * @returns {Promise}
678
+ */
679
+ async getBucketUsage(bucketId: string, range?: string): Promise<Models.UsageBuckets> {
680
+ if (typeof bucketId === 'undefined') {
681
+ throw new AppwriteException('Missing required parameter: "bucketId"');
682
+ }
681
683
 
682
- if (typeof range !== 'undefined') {
683
- payload['range'] = range;
684
- }
684
+ let path = '/storage/{bucketId}/usage'.replace('{bucketId}', bucketId);
685
+ let payload: Payload = {};
685
686
 
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);
687
+ if (typeof range !== 'undefined') {
688
+ payload['range'] = range;
690
689
  }
690
+
691
+ const uri = new URL(this.client.config.endpoint + path);
692
+ return await this.client.call('get', uri, {
693
+ 'content-type': 'application/json',
694
+ }, payload);
695
+ }
691
696
  };