node-appwrite 9.0.0 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/README.md +2 -2
  2. package/docs/examples/account/create-phone-verification.md +1 -1
  3. package/docs/examples/account/create-recovery.md +1 -1
  4. package/docs/examples/account/create-verification.md +1 -1
  5. package/docs/examples/account/delete-identity.md +20 -0
  6. package/docs/examples/account/delete-session.md +1 -1
  7. package/docs/examples/account/delete-sessions.md +1 -1
  8. package/docs/examples/account/get-prefs.md +1 -1
  9. package/docs/examples/account/get-session.md +1 -1
  10. package/docs/examples/account/get.md +1 -1
  11. package/docs/examples/account/list-identities.md +20 -0
  12. package/docs/examples/account/list-logs.md +1 -1
  13. package/docs/examples/account/list-sessions.md +1 -1
  14. package/docs/examples/account/update-email.md +1 -1
  15. package/docs/examples/account/update-name.md +1 -1
  16. package/docs/examples/account/update-password.md +1 -1
  17. package/docs/examples/account/update-phone-verification.md +1 -1
  18. package/docs/examples/account/update-phone.md +1 -1
  19. package/docs/examples/account/update-prefs.md +1 -1
  20. package/docs/examples/account/update-recovery.md +1 -1
  21. package/docs/examples/account/update-session.md +1 -1
  22. package/docs/examples/account/update-status.md +1 -1
  23. package/docs/examples/account/update-verification.md +1 -1
  24. package/docs/examples/avatars/get-browser.md +1 -1
  25. package/docs/examples/avatars/get-credit-card.md +1 -1
  26. package/docs/examples/avatars/get-favicon.md +1 -1
  27. package/docs/examples/avatars/get-flag.md +1 -1
  28. package/docs/examples/avatars/get-image.md +1 -1
  29. package/docs/examples/avatars/get-initials.md +1 -1
  30. package/docs/examples/avatars/get-q-r.md +1 -1
  31. package/docs/examples/databases/create-boolean-attribute.md +1 -1
  32. package/docs/examples/databases/create-collection.md +1 -1
  33. package/docs/examples/databases/create-datetime-attribute.md +1 -1
  34. package/docs/examples/databases/create-document.md +1 -1
  35. package/docs/examples/databases/create-email-attribute.md +1 -1
  36. package/docs/examples/databases/create-enum-attribute.md +1 -1
  37. package/docs/examples/databases/create-float-attribute.md +1 -1
  38. package/docs/examples/databases/create-index.md +1 -1
  39. package/docs/examples/databases/create-integer-attribute.md +1 -1
  40. package/docs/examples/databases/create-ip-attribute.md +1 -1
  41. package/docs/examples/databases/create-relationship-attribute.md +1 -1
  42. package/docs/examples/databases/create-string-attribute.md +1 -1
  43. package/docs/examples/databases/create-url-attribute.md +1 -1
  44. package/docs/examples/databases/create.md +1 -1
  45. package/docs/examples/databases/delete-attribute.md +1 -1
  46. package/docs/examples/databases/delete-collection.md +1 -1
  47. package/docs/examples/databases/delete-document.md +1 -1
  48. package/docs/examples/databases/delete-index.md +1 -1
  49. package/docs/examples/databases/delete.md +1 -1
  50. package/docs/examples/databases/get-attribute.md +1 -1
  51. package/docs/examples/databases/get-collection.md +1 -1
  52. package/docs/examples/databases/get-document.md +1 -1
  53. package/docs/examples/databases/get-index.md +1 -1
  54. package/docs/examples/databases/get.md +1 -1
  55. package/docs/examples/databases/list-attributes.md +1 -1
  56. package/docs/examples/databases/list-collections.md +1 -1
  57. package/docs/examples/databases/list-documents.md +1 -1
  58. package/docs/examples/databases/list-indexes.md +1 -1
  59. package/docs/examples/databases/list.md +1 -1
  60. package/docs/examples/databases/update-boolean-attribute.md +1 -1
  61. package/docs/examples/databases/update-collection.md +1 -1
  62. package/docs/examples/databases/update-datetime-attribute.md +1 -1
  63. package/docs/examples/databases/update-document.md +1 -1
  64. package/docs/examples/databases/update-email-attribute.md +1 -1
  65. package/docs/examples/databases/update-enum-attribute.md +1 -1
  66. package/docs/examples/databases/update-float-attribute.md +1 -1
  67. package/docs/examples/databases/update-integer-attribute.md +1 -1
  68. package/docs/examples/databases/update-ip-attribute.md +1 -1
  69. package/docs/examples/databases/update-relationship-attribute.md +1 -1
  70. package/docs/examples/databases/update-string-attribute.md +1 -1
  71. package/docs/examples/databases/update-url-attribute.md +1 -1
  72. package/docs/examples/databases/update.md +1 -1
  73. package/docs/examples/functions/create-build.md +1 -1
  74. package/docs/examples/functions/create-deployment.md +2 -2
  75. package/docs/examples/functions/create-execution.md +1 -1
  76. package/docs/examples/functions/create-variable.md +1 -1
  77. package/docs/examples/functions/create.md +1 -1
  78. package/docs/examples/functions/delete-deployment.md +1 -1
  79. package/docs/examples/functions/delete-variable.md +1 -1
  80. package/docs/examples/functions/delete.md +1 -1
  81. package/docs/examples/functions/download-deployment.md +20 -0
  82. package/docs/examples/functions/get-deployment.md +1 -1
  83. package/docs/examples/functions/get-execution.md +1 -1
  84. package/docs/examples/functions/get-variable.md +1 -1
  85. package/docs/examples/functions/get.md +1 -1
  86. package/docs/examples/functions/list-deployments.md +1 -1
  87. package/docs/examples/functions/list-executions.md +1 -1
  88. package/docs/examples/functions/list-runtimes.md +1 -1
  89. package/docs/examples/functions/list-variables.md +1 -1
  90. package/docs/examples/functions/list.md +1 -1
  91. package/docs/examples/functions/update-deployment.md +1 -1
  92. package/docs/examples/functions/update-variable.md +1 -1
  93. package/docs/examples/functions/update.md +2 -2
  94. package/docs/examples/graphql/mutation.md +1 -1
  95. package/docs/examples/graphql/query.md +1 -1
  96. package/docs/examples/health/get-antivirus.md +1 -1
  97. package/docs/examples/health/get-cache.md +1 -1
  98. package/docs/examples/health/get-d-b.md +1 -1
  99. package/docs/examples/health/get-pub-sub.md +20 -0
  100. package/docs/examples/health/get-queue-certificates.md +1 -1
  101. package/docs/examples/health/get-queue-functions.md +1 -1
  102. package/docs/examples/health/get-queue-logs.md +1 -1
  103. package/docs/examples/health/get-queue-webhooks.md +1 -1
  104. package/docs/examples/health/get-queue.md +20 -0
  105. package/docs/examples/health/get-storage-local.md +1 -1
  106. package/docs/examples/health/get-time.md +1 -1
  107. package/docs/examples/health/get.md +1 -1
  108. package/docs/examples/locale/get.md +1 -1
  109. package/docs/examples/locale/list-codes.md +20 -0
  110. package/docs/examples/locale/list-continents.md +1 -1
  111. package/docs/examples/locale/list-countries-e-u.md +1 -1
  112. package/docs/examples/locale/list-countries-phones.md +1 -1
  113. package/docs/examples/locale/list-countries.md +1 -1
  114. package/docs/examples/locale/list-currencies.md +1 -1
  115. package/docs/examples/locale/list-languages.md +1 -1
  116. package/docs/examples/storage/create-bucket.md +1 -1
  117. package/docs/examples/storage/create-file.md +1 -1
  118. package/docs/examples/storage/delete-bucket.md +1 -1
  119. package/docs/examples/storage/delete-file.md +1 -1
  120. package/docs/examples/storage/get-bucket.md +1 -1
  121. package/docs/examples/storage/get-file-download.md +1 -1
  122. package/docs/examples/storage/get-file-preview.md +1 -1
  123. package/docs/examples/storage/get-file-view.md +1 -1
  124. package/docs/examples/storage/get-file.md +1 -1
  125. package/docs/examples/storage/list-buckets.md +1 -1
  126. package/docs/examples/storage/list-files.md +1 -1
  127. package/docs/examples/storage/update-bucket.md +1 -1
  128. package/docs/examples/storage/update-file.md +1 -1
  129. package/docs/examples/teams/create-membership.md +1 -1
  130. package/docs/examples/teams/create.md +1 -1
  131. package/docs/examples/teams/delete-membership.md +1 -1
  132. package/docs/examples/teams/delete.md +1 -1
  133. package/docs/examples/teams/get-membership.md +1 -1
  134. package/docs/examples/teams/get-prefs.md +1 -1
  135. package/docs/examples/teams/get.md +1 -1
  136. package/docs/examples/teams/list-memberships.md +1 -1
  137. package/docs/examples/teams/list.md +1 -1
  138. package/docs/examples/teams/update-membership-status.md +1 -1
  139. package/docs/examples/teams/{update-membership-roles.md → update-membership.md} +2 -2
  140. package/docs/examples/teams/update-name.md +1 -1
  141. package/docs/examples/teams/update-prefs.md +1 -1
  142. package/docs/examples/users/create-argon2user.md +1 -1
  143. package/docs/examples/users/create-bcrypt-user.md +1 -1
  144. package/docs/examples/users/create-m-d5user.md +1 -1
  145. package/docs/examples/users/create-p-h-pass-user.md +1 -1
  146. package/docs/examples/users/create-s-h-a-user.md +1 -1
  147. package/docs/examples/users/create-scrypt-modified-user.md +1 -1
  148. package/docs/examples/users/create-scrypt-user.md +1 -1
  149. package/docs/examples/users/create.md +1 -1
  150. package/docs/examples/users/delete-identity.md +20 -0
  151. package/docs/examples/users/delete-session.md +1 -1
  152. package/docs/examples/users/delete-sessions.md +1 -1
  153. package/docs/examples/users/delete.md +1 -1
  154. package/docs/examples/users/get-prefs.md +1 -1
  155. package/docs/examples/users/get.md +1 -1
  156. package/docs/examples/users/list-identities.md +20 -0
  157. package/docs/examples/users/list-logs.md +1 -1
  158. package/docs/examples/users/list-memberships.md +1 -1
  159. package/docs/examples/users/list-sessions.md +1 -1
  160. package/docs/examples/users/list.md +1 -1
  161. package/docs/examples/users/update-email-verification.md +1 -1
  162. package/docs/examples/users/update-email.md +1 -1
  163. package/docs/examples/users/update-labels.md +20 -0
  164. package/docs/examples/users/update-name.md +1 -1
  165. package/docs/examples/users/update-password.md +1 -1
  166. package/docs/examples/users/update-phone-verification.md +1 -1
  167. package/docs/examples/users/update-phone.md +1 -1
  168. package/docs/examples/users/update-prefs.md +1 -1
  169. package/docs/examples/users/update-status.md +1 -1
  170. package/index.d.ts +435 -55
  171. package/lib/client.js +4 -2
  172. package/lib/role.js +74 -3
  173. package/lib/services/account.js +94 -50
  174. package/lib/services/avatars.js +14 -14
  175. package/lib/services/databases.js +120 -90
  176. package/lib/services/functions.js +223 -65
  177. package/lib/services/graphql.js +4 -4
  178. package/lib/services/health.js +57 -22
  179. package/lib/services/locale.js +32 -14
  180. package/lib/services/storage.js +44 -34
  181. package/lib/services/teams.js +29 -28
  182. package/lib/services/users.js +135 -50
  183. package/package.json +2 -2
@@ -26,7 +26,7 @@ class Functions extends Service {
26
26
  * @returns {Promise}
27
27
  */
28
28
  async list(queries, search) {
29
- let path = '/functions';
29
+ const apiPath = '/functions';
30
30
  let payload = {};
31
31
 
32
32
  if (typeof queries !== 'undefined') {
@@ -37,7 +37,7 @@ class Functions extends Service {
37
37
  payload['search'] = search;
38
38
  }
39
39
 
40
- return await this.client.call('get', path, {
40
+ return await this.client.call('get', apiPath, {
41
41
  'content-type': 'application/json',
42
42
  }, payload);
43
43
  }
@@ -57,11 +57,23 @@ class Functions extends Service {
57
57
  * @param {string} schedule
58
58
  * @param {number} timeout
59
59
  * @param {boolean} enabled
60
+ * @param {boolean} logging
61
+ * @param {string} entrypoint
62
+ * @param {string} commands
63
+ * @param {string} installationId
64
+ * @param {string} providerRepositoryId
65
+ * @param {string} providerBranch
66
+ * @param {boolean} providerSilentMode
67
+ * @param {string} providerRootDirectory
68
+ * @param {string} templateRepository
69
+ * @param {string} templateOwner
70
+ * @param {string} templateRootDirectory
71
+ * @param {string} templateBranch
60
72
  * @throws {AppwriteException}
61
73
  * @returns {Promise}
62
74
  */
63
- async create(functionId, name, runtime, execute, events, schedule, timeout, enabled) {
64
- let path = '/functions';
75
+ async create(functionId, name, runtime, execute, events, schedule, timeout, enabled, logging, entrypoint, commands, installationId, providerRepositoryId, providerBranch, providerSilentMode, providerRootDirectory, templateRepository, templateOwner, templateRootDirectory, templateBranch) {
76
+ const apiPath = '/functions';
65
77
  let payload = {};
66
78
  if (typeof functionId === 'undefined') {
67
79
  throw new AppwriteException('Missing required parameter: "functionId"');
@@ -84,14 +96,14 @@ class Functions extends Service {
84
96
  payload['name'] = name;
85
97
  }
86
98
 
87
- if (typeof execute !== 'undefined') {
88
- payload['execute'] = execute;
89
- }
90
-
91
99
  if (typeof runtime !== 'undefined') {
92
100
  payload['runtime'] = runtime;
93
101
  }
94
102
 
103
+ if (typeof execute !== 'undefined') {
104
+ payload['execute'] = execute;
105
+ }
106
+
95
107
  if (typeof events !== 'undefined') {
96
108
  payload['events'] = events;
97
109
  }
@@ -108,7 +120,55 @@ class Functions extends Service {
108
120
  payload['enabled'] = enabled;
109
121
  }
110
122
 
111
- return await this.client.call('post', path, {
123
+ if (typeof logging !== 'undefined') {
124
+ payload['logging'] = logging;
125
+ }
126
+
127
+ if (typeof entrypoint !== 'undefined') {
128
+ payload['entrypoint'] = entrypoint;
129
+ }
130
+
131
+ if (typeof commands !== 'undefined') {
132
+ payload['commands'] = commands;
133
+ }
134
+
135
+ if (typeof installationId !== 'undefined') {
136
+ payload['installationId'] = installationId;
137
+ }
138
+
139
+ if (typeof providerRepositoryId !== 'undefined') {
140
+ payload['providerRepositoryId'] = providerRepositoryId;
141
+ }
142
+
143
+ if (typeof providerBranch !== 'undefined') {
144
+ payload['providerBranch'] = providerBranch;
145
+ }
146
+
147
+ if (typeof providerSilentMode !== 'undefined') {
148
+ payload['providerSilentMode'] = providerSilentMode;
149
+ }
150
+
151
+ if (typeof providerRootDirectory !== 'undefined') {
152
+ payload['providerRootDirectory'] = providerRootDirectory;
153
+ }
154
+
155
+ if (typeof templateRepository !== 'undefined') {
156
+ payload['templateRepository'] = templateRepository;
157
+ }
158
+
159
+ if (typeof templateOwner !== 'undefined') {
160
+ payload['templateOwner'] = templateOwner;
161
+ }
162
+
163
+ if (typeof templateRootDirectory !== 'undefined') {
164
+ payload['templateRootDirectory'] = templateRootDirectory;
165
+ }
166
+
167
+ if (typeof templateBranch !== 'undefined') {
168
+ payload['templateBranch'] = templateBranch;
169
+ }
170
+
171
+ return await this.client.call('post', apiPath, {
112
172
  'content-type': 'application/json',
113
173
  }, payload);
114
174
  }
@@ -122,10 +182,10 @@ class Functions extends Service {
122
182
  * @returns {Promise}
123
183
  */
124
184
  async listRuntimes() {
125
- let path = '/functions/runtimes';
185
+ const apiPath = '/functions/runtimes';
126
186
  let payload = {};
127
187
 
128
- return await this.client.call('get', path, {
188
+ return await this.client.call('get', apiPath, {
129
189
  'content-type': 'application/json',
130
190
  }, payload);
131
191
  }
@@ -140,14 +200,14 @@ class Functions extends Service {
140
200
  * @returns {Promise}
141
201
  */
142
202
  async get(functionId) {
143
- let path = '/functions/{functionId}'.replace('{functionId}', functionId);
203
+ const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
144
204
  let payload = {};
145
205
  if (typeof functionId === 'undefined') {
146
206
  throw new AppwriteException('Missing required parameter: "functionId"');
147
207
  }
148
208
 
149
209
 
150
- return await this.client.call('get', path, {
210
+ return await this.client.call('get', apiPath, {
151
211
  'content-type': 'application/json',
152
212
  }, payload);
153
213
  }
@@ -159,16 +219,25 @@ class Functions extends Service {
159
219
  *
160
220
  * @param {string} functionId
161
221
  * @param {string} name
222
+ * @param {string} runtime
162
223
  * @param {string[]} execute
163
224
  * @param {string[]} events
164
225
  * @param {string} schedule
165
226
  * @param {number} timeout
166
227
  * @param {boolean} enabled
228
+ * @param {boolean} logging
229
+ * @param {string} entrypoint
230
+ * @param {string} commands
231
+ * @param {string} installationId
232
+ * @param {string} providerRepositoryId
233
+ * @param {string} providerBranch
234
+ * @param {boolean} providerSilentMode
235
+ * @param {string} providerRootDirectory
167
236
  * @throws {AppwriteException}
168
237
  * @returns {Promise}
169
238
  */
170
- async update(functionId, name, execute, events, schedule, timeout, enabled) {
171
- let path = '/functions/{functionId}'.replace('{functionId}', functionId);
239
+ async update(functionId, name, runtime, execute, events, schedule, timeout, enabled, logging, entrypoint, commands, installationId, providerRepositoryId, providerBranch, providerSilentMode, providerRootDirectory) {
240
+ const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
172
241
  let payload = {};
173
242
  if (typeof functionId === 'undefined') {
174
243
  throw new AppwriteException('Missing required parameter: "functionId"');
@@ -178,11 +247,19 @@ class Functions extends Service {
178
247
  throw new AppwriteException('Missing required parameter: "name"');
179
248
  }
180
249
 
250
+ if (typeof runtime === 'undefined') {
251
+ throw new AppwriteException('Missing required parameter: "runtime"');
252
+ }
253
+
181
254
 
182
255
  if (typeof name !== 'undefined') {
183
256
  payload['name'] = name;
184
257
  }
185
258
 
259
+ if (typeof runtime !== 'undefined') {
260
+ payload['runtime'] = runtime;
261
+ }
262
+
186
263
  if (typeof execute !== 'undefined') {
187
264
  payload['execute'] = execute;
188
265
  }
@@ -203,7 +280,39 @@ class Functions extends Service {
203
280
  payload['enabled'] = enabled;
204
281
  }
205
282
 
206
- return await this.client.call('put', path, {
283
+ if (typeof logging !== 'undefined') {
284
+ payload['logging'] = logging;
285
+ }
286
+
287
+ if (typeof entrypoint !== 'undefined') {
288
+ payload['entrypoint'] = entrypoint;
289
+ }
290
+
291
+ if (typeof commands !== 'undefined') {
292
+ payload['commands'] = commands;
293
+ }
294
+
295
+ if (typeof installationId !== 'undefined') {
296
+ payload['installationId'] = installationId;
297
+ }
298
+
299
+ if (typeof providerRepositoryId !== 'undefined') {
300
+ payload['providerRepositoryId'] = providerRepositoryId;
301
+ }
302
+
303
+ if (typeof providerBranch !== 'undefined') {
304
+ payload['providerBranch'] = providerBranch;
305
+ }
306
+
307
+ if (typeof providerSilentMode !== 'undefined') {
308
+ payload['providerSilentMode'] = providerSilentMode;
309
+ }
310
+
311
+ if (typeof providerRootDirectory !== 'undefined') {
312
+ payload['providerRootDirectory'] = providerRootDirectory;
313
+ }
314
+
315
+ return await this.client.call('put', apiPath, {
207
316
  'content-type': 'application/json',
208
317
  }, payload);
209
318
  }
@@ -218,14 +327,14 @@ class Functions extends Service {
218
327
  * @returns {Promise}
219
328
  */
220
329
  async delete(functionId) {
221
- let path = '/functions/{functionId}'.replace('{functionId}', functionId);
330
+ const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
222
331
  let payload = {};
223
332
  if (typeof functionId === 'undefined') {
224
333
  throw new AppwriteException('Missing required parameter: "functionId"');
225
334
  }
226
335
 
227
336
 
228
- return await this.client.call('delete', path, {
337
+ return await this.client.call('delete', apiPath, {
229
338
  'content-type': 'application/json',
230
339
  }, payload);
231
340
  }
@@ -243,7 +352,7 @@ class Functions extends Service {
243
352
  * @returns {Promise}
244
353
  */
245
354
  async listDeployments(functionId, queries, search) {
246
- let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
355
+ const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
247
356
  let payload = {};
248
357
  if (typeof functionId === 'undefined') {
249
358
  throw new AppwriteException('Missing required parameter: "functionId"');
@@ -258,7 +367,7 @@ class Functions extends Service {
258
367
  payload['search'] = search;
259
368
  }
260
369
 
261
- return await this.client.call('get', path, {
370
+ return await this.client.call('get', apiPath, {
262
371
  'content-type': 'application/json',
263
372
  }, payload);
264
373
  }
@@ -275,26 +384,23 @@ class Functions extends Service {
275
384
  * learn more about code packaging in the [Appwrite Cloud Functions
276
385
  * tutorial](/docs/functions).
277
386
  *
278
- * Use the "command" param to set the entry point used to execute your code.
387
+ * Use the "command" param to set the entrypoint used to execute your code.
279
388
  *
280
389
  * @param {string} functionId
281
- * @param {string} entrypoint
282
390
  * @param {InputFile} code
283
391
  * @param {boolean} activate
392
+ * @param {string} entrypoint
393
+ * @param {string} commands
284
394
  * @throws {AppwriteException}
285
395
  * @returns {Promise}
286
396
  */
287
- async createDeployment(functionId, entrypoint, code, activate, onProgress = () => {}) {
288
- let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
397
+ async createDeployment(functionId, code, activate, entrypoint, commands, onProgress = () => {}) {
398
+ const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
289
399
  let payload = {};
290
400
  if (typeof functionId === 'undefined') {
291
401
  throw new AppwriteException('Missing required parameter: "functionId"');
292
402
  }
293
403
 
294
- if (typeof entrypoint === 'undefined') {
295
- throw new AppwriteException('Missing required parameter: "entrypoint"');
296
- }
297
-
298
404
  if (typeof code === 'undefined') {
299
405
  throw new AppwriteException('Missing required parameter: "code"');
300
406
  }
@@ -308,6 +414,10 @@ class Functions extends Service {
308
414
  payload['entrypoint'] = entrypoint;
309
415
  }
310
416
 
417
+ if (typeof commands !== 'undefined') {
418
+ payload['commands'] = commands;
419
+ }
420
+
311
421
  if (typeof code !== 'undefined') {
312
422
  payload['code'] = code;
313
423
  }
@@ -318,7 +428,7 @@ class Functions extends Service {
318
428
 
319
429
  const size = code.size;
320
430
 
321
- const headers = {
431
+ const apiHeaders = {
322
432
  'content-type': 'multipart/form-data',
323
433
  };
324
434
 
@@ -340,20 +450,24 @@ class Functions extends Service {
340
450
  }
341
451
 
342
452
  const start = currentChunkStart;
343
- const end = Math.min(((start + client.CHUNK_SIZE) - 1), size);
453
+ const end = currentChunkStart + currentChunkSize - 1;
344
454
 
345
455
  if(!lastUpload || currentChunkStart !== 0) {
346
- headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
456
+ apiHeaders['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
347
457
  }
348
458
 
349
459
  if (id) {
350
- headers['x-appwrite-id'] = id;
460
+ apiHeaders['x-appwrite-id'] = id;
351
461
  }
352
462
 
353
- const stream = Stream.Readable.from(currentChunk);
354
- payload['code'] = { type: 'file', file: stream, filename: code.filename };
463
+ payload['code'] = {
464
+ type: 'file',
465
+ file: currentChunk,
466
+ filename: code.filename,
467
+ size: currentChunkSize
468
+ };
355
469
 
356
- response = await selfClient.call('post', path, headers, payload);
470
+ response = await selfClient.call('post', apiPath, apiHeaders, payload);
357
471
 
358
472
  if (!id) {
359
473
  id = response['$id'];
@@ -392,6 +506,7 @@ class Functions extends Service {
392
506
  if(chunkSize + currentChunkSize == client.CHUNK_SIZE) {
393
507
  // Upload chunk
394
508
  currentChunk = Buffer.concat([currentChunk, chunk]);
509
+ currentChunkSize = Buffer.byteLength(currentChunk);
395
510
  await uploadChunk();
396
511
  currentChunk = Buffer.from('');
397
512
  currentChunkSize = 0;
@@ -449,7 +564,7 @@ class Functions extends Service {
449
564
  * @returns {Promise}
450
565
  */
451
566
  async getDeployment(functionId, deploymentId) {
452
- let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
567
+ const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
453
568
  let payload = {};
454
569
  if (typeof functionId === 'undefined') {
455
570
  throw new AppwriteException('Missing required parameter: "functionId"');
@@ -460,7 +575,7 @@ class Functions extends Service {
460
575
  }
461
576
 
462
577
 
463
- return await this.client.call('get', path, {
578
+ return await this.client.call('get', apiPath, {
464
579
  'content-type': 'application/json',
465
580
  }, payload);
466
581
  }
@@ -478,7 +593,7 @@ class Functions extends Service {
478
593
  * @returns {Promise}
479
594
  */
480
595
  async updateDeployment(functionId, deploymentId) {
481
- let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
596
+ const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
482
597
  let payload = {};
483
598
  if (typeof functionId === 'undefined') {
484
599
  throw new AppwriteException('Missing required parameter: "functionId"');
@@ -489,7 +604,7 @@ class Functions extends Service {
489
604
  }
490
605
 
491
606
 
492
- return await this.client.call('patch', path, {
607
+ return await this.client.call('patch', apiPath, {
493
608
  'content-type': 'application/json',
494
609
  }, payload);
495
610
  }
@@ -505,7 +620,7 @@ class Functions extends Service {
505
620
  * @returns {Promise}
506
621
  */
507
622
  async deleteDeployment(functionId, deploymentId) {
508
- let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
623
+ const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
509
624
  let payload = {};
510
625
  if (typeof functionId === 'undefined') {
511
626
  throw new AppwriteException('Missing required parameter: "functionId"');
@@ -516,7 +631,7 @@ class Functions extends Service {
516
631
  }
517
632
 
518
633
 
519
- return await this.client.call('delete', path, {
634
+ return await this.client.call('delete', apiPath, {
520
635
  'content-type': 'application/json',
521
636
  }, payload);
522
637
  }
@@ -524,6 +639,9 @@ class Functions extends Service {
524
639
  /**
525
640
  * Create Build
526
641
  *
642
+ * Create a new build for an Appwrite Function deployment. This endpoint can
643
+ * be used to retry a failed build.
644
+ *
527
645
  * @param {string} functionId
528
646
  * @param {string} deploymentId
529
647
  * @param {string} buildId
@@ -531,7 +649,7 @@ class Functions extends Service {
531
649
  * @returns {Promise}
532
650
  */
533
651
  async createBuild(functionId, deploymentId, buildId) {
534
- let path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId).replace('{buildId}', buildId);
652
+ const apiPath = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId).replace('{buildId}', buildId);
535
653
  let payload = {};
536
654
  if (typeof functionId === 'undefined') {
537
655
  throw new AppwriteException('Missing required parameter: "functionId"');
@@ -546,11 +664,36 @@ class Functions extends Service {
546
664
  }
547
665
 
548
666
 
549
- return await this.client.call('post', path, {
667
+ return await this.client.call('post', apiPath, {
550
668
  'content-type': 'application/json',
551
669
  }, payload);
552
670
  }
553
671
 
672
+ /**
673
+ * Download Deployment
674
+ *
675
+ * @param {string} functionId
676
+ * @param {string} deploymentId
677
+ * @throws {AppwriteException}
678
+ * @returns {Promise}
679
+ */
680
+ async downloadDeployment(functionId, deploymentId) {
681
+ const apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
682
+ let payload = {};
683
+ if (typeof functionId === 'undefined') {
684
+ throw new AppwriteException('Missing required parameter: "functionId"');
685
+ }
686
+
687
+ if (typeof deploymentId === 'undefined') {
688
+ throw new AppwriteException('Missing required parameter: "deploymentId"');
689
+ }
690
+
691
+
692
+ return await this.client.call('get', apiPath, {
693
+ 'content-type': 'application/json',
694
+ }, payload, 'arraybuffer');
695
+ }
696
+
554
697
  /**
555
698
  * List Executions
556
699
  *
@@ -564,7 +707,7 @@ class Functions extends Service {
564
707
  * @returns {Promise}
565
708
  */
566
709
  async listExecutions(functionId, queries, search) {
567
- let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
710
+ const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
568
711
  let payload = {};
569
712
  if (typeof functionId === 'undefined') {
570
713
  throw new AppwriteException('Missing required parameter: "functionId"');
@@ -579,7 +722,7 @@ class Functions extends Service {
579
722
  payload['search'] = search;
580
723
  }
581
724
 
582
- return await this.client.call('get', path, {
725
+ return await this.client.call('get', apiPath, {
583
726
  'content-type': 'application/json',
584
727
  }, payload);
585
728
  }
@@ -593,28 +736,43 @@ class Functions extends Service {
593
736
  * function execution process will start asynchronously.
594
737
  *
595
738
  * @param {string} functionId
596
- * @param {string} data
739
+ * @param {string} body
597
740
  * @param {boolean} async
741
+ * @param {string} xpath
742
+ * @param {string} method
743
+ * @param {object} headers
598
744
  * @throws {AppwriteException}
599
745
  * @returns {Promise}
600
746
  */
601
- async createExecution(functionId, data, async) {
602
- let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
747
+ async createExecution(functionId, body, async, xpath, method, headers) {
748
+ const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
603
749
  let payload = {};
604
750
  if (typeof functionId === 'undefined') {
605
751
  throw new AppwriteException('Missing required parameter: "functionId"');
606
752
  }
607
753
 
608
754
 
609
- if (typeof data !== 'undefined') {
610
- payload['data'] = data;
755
+ if (typeof body !== 'undefined') {
756
+ payload['body'] = body;
611
757
  }
612
758
 
613
759
  if (typeof async !== 'undefined') {
614
760
  payload['async'] = async;
615
761
  }
616
762
 
617
- return await this.client.call('post', path, {
763
+ if (typeof xpath !== 'undefined') {
764
+ payload['path'] = xpath;
765
+ }
766
+
767
+ if (typeof method !== 'undefined') {
768
+ payload['method'] = method;
769
+ }
770
+
771
+ if (typeof headers !== 'undefined') {
772
+ payload['headers'] = headers;
773
+ }
774
+
775
+ return await this.client.call('post', apiPath, {
618
776
  'content-type': 'application/json',
619
777
  }, payload);
620
778
  }
@@ -630,7 +788,7 @@ class Functions extends Service {
630
788
  * @returns {Promise}
631
789
  */
632
790
  async getExecution(functionId, executionId) {
633
- let path = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
791
+ const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
634
792
  let payload = {};
635
793
  if (typeof functionId === 'undefined') {
636
794
  throw new AppwriteException('Missing required parameter: "functionId"');
@@ -641,7 +799,7 @@ class Functions extends Service {
641
799
  }
642
800
 
643
801
 
644
- return await this.client.call('get', path, {
802
+ return await this.client.call('get', apiPath, {
645
803
  'content-type': 'application/json',
646
804
  }, payload);
647
805
  }
@@ -656,14 +814,14 @@ class Functions extends Service {
656
814
  * @returns {Promise}
657
815
  */
658
816
  async listVariables(functionId) {
659
- let path = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
817
+ const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
660
818
  let payload = {};
661
819
  if (typeof functionId === 'undefined') {
662
820
  throw new AppwriteException('Missing required parameter: "functionId"');
663
821
  }
664
822
 
665
823
 
666
- return await this.client.call('get', path, {
824
+ return await this.client.call('get', apiPath, {
667
825
  'content-type': 'application/json',
668
826
  }, payload);
669
827
  }
@@ -671,8 +829,8 @@ class Functions extends Service {
671
829
  /**
672
830
  * Create Variable
673
831
  *
674
- * Create a new function variable. These variables can be accessed within
675
- * function in the `env` object under the request variable.
832
+ * Create a new function environment variable. These variables can be accessed
833
+ * in the function at runtime as environment variables.
676
834
  *
677
835
  * @param {string} functionId
678
836
  * @param {string} key
@@ -681,7 +839,7 @@ class Functions extends Service {
681
839
  * @returns {Promise}
682
840
  */
683
841
  async createVariable(functionId, key, value) {
684
- let path = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
842
+ const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
685
843
  let payload = {};
686
844
  if (typeof functionId === 'undefined') {
687
845
  throw new AppwriteException('Missing required parameter: "functionId"');
@@ -704,7 +862,7 @@ class Functions extends Service {
704
862
  payload['value'] = value;
705
863
  }
706
864
 
707
- return await this.client.call('post', path, {
865
+ return await this.client.call('post', apiPath, {
708
866
  'content-type': 'application/json',
709
867
  }, payload);
710
868
  }
@@ -720,7 +878,7 @@ class Functions extends Service {
720
878
  * @returns {Promise}
721
879
  */
722
880
  async getVariable(functionId, variableId) {
723
- let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
881
+ const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
724
882
  let payload = {};
725
883
  if (typeof functionId === 'undefined') {
726
884
  throw new AppwriteException('Missing required parameter: "functionId"');
@@ -731,7 +889,7 @@ class Functions extends Service {
731
889
  }
732
890
 
733
891
 
734
- return await this.client.call('get', path, {
892
+ return await this.client.call('get', apiPath, {
735
893
  'content-type': 'application/json',
736
894
  }, payload);
737
895
  }
@@ -749,7 +907,7 @@ class Functions extends Service {
749
907
  * @returns {Promise}
750
908
  */
751
909
  async updateVariable(functionId, variableId, key, value) {
752
- let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
910
+ const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
753
911
  let payload = {};
754
912
  if (typeof functionId === 'undefined') {
755
913
  throw new AppwriteException('Missing required parameter: "functionId"');
@@ -772,7 +930,7 @@ class Functions extends Service {
772
930
  payload['value'] = value;
773
931
  }
774
932
 
775
- return await this.client.call('put', path, {
933
+ return await this.client.call('put', apiPath, {
776
934
  'content-type': 'application/json',
777
935
  }, payload);
778
936
  }
@@ -788,7 +946,7 @@ class Functions extends Service {
788
946
  * @returns {Promise}
789
947
  */
790
948
  async deleteVariable(functionId, variableId) {
791
- let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
949
+ const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
792
950
  let payload = {};
793
951
  if (typeof functionId === 'undefined') {
794
952
  throw new AppwriteException('Missing required parameter: "functionId"');
@@ -799,7 +957,7 @@ class Functions extends Service {
799
957
  }
800
958
 
801
959
 
802
- return await this.client.call('delete', path, {
960
+ return await this.client.call('delete', apiPath, {
803
961
  'content-type': 'application/json',
804
962
  }, payload);
805
963
  }