@appwrite.io/console 0.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 (228) hide show
  1. package/.github/workflows/publish.yml +18 -0
  2. package/CHANGELOG.md +1 -0
  3. package/LICENSE +12 -0
  4. package/README.md +111 -0
  5. package/dist/cjs/package.json +3 -0
  6. package/dist/esm/package.json +3 -0
  7. package/docs/examples/account/create-anonymous-session.md +18 -0
  8. package/docs/examples/account/create-email-session.md +18 -0
  9. package/docs/examples/account/create-j-w-t.md +18 -0
  10. package/docs/examples/account/create-magic-u-r-l-session.md +18 -0
  11. package/docs/examples/account/create-o-auth2session.md +14 -0
  12. package/docs/examples/account/create-phone-session.md +18 -0
  13. package/docs/examples/account/create-phone-verification.md +18 -0
  14. package/docs/examples/account/create-recovery.md +18 -0
  15. package/docs/examples/account/create-verification.md +18 -0
  16. package/docs/examples/account/create.md +18 -0
  17. package/docs/examples/account/delete-session.md +18 -0
  18. package/docs/examples/account/delete-sessions.md +18 -0
  19. package/docs/examples/account/get-prefs.md +18 -0
  20. package/docs/examples/account/get-session.md +18 -0
  21. package/docs/examples/account/get.md +18 -0
  22. package/docs/examples/account/list-logs.md +18 -0
  23. package/docs/examples/account/list-sessions.md +18 -0
  24. package/docs/examples/account/update-email.md +18 -0
  25. package/docs/examples/account/update-magic-u-r-l-session.md +18 -0
  26. package/docs/examples/account/update-name.md +18 -0
  27. package/docs/examples/account/update-password.md +18 -0
  28. package/docs/examples/account/update-phone-session.md +18 -0
  29. package/docs/examples/account/update-phone-verification.md +18 -0
  30. package/docs/examples/account/update-phone.md +18 -0
  31. package/docs/examples/account/update-prefs.md +18 -0
  32. package/docs/examples/account/update-recovery.md +18 -0
  33. package/docs/examples/account/update-session.md +18 -0
  34. package/docs/examples/account/update-status.md +18 -0
  35. package/docs/examples/account/update-verification.md +18 -0
  36. package/docs/examples/avatars/get-browser.md +14 -0
  37. package/docs/examples/avatars/get-credit-card.md +14 -0
  38. package/docs/examples/avatars/get-favicon.md +14 -0
  39. package/docs/examples/avatars/get-flag.md +14 -0
  40. package/docs/examples/avatars/get-image.md +14 -0
  41. package/docs/examples/avatars/get-initials.md +14 -0
  42. package/docs/examples/avatars/get-q-r.md +14 -0
  43. package/docs/examples/databases/create-boolean-attribute.md +18 -0
  44. package/docs/examples/databases/create-collection.md +18 -0
  45. package/docs/examples/databases/create-datetime-attribute.md +18 -0
  46. package/docs/examples/databases/create-document.md +18 -0
  47. package/docs/examples/databases/create-email-attribute.md +18 -0
  48. package/docs/examples/databases/create-enum-attribute.md +18 -0
  49. package/docs/examples/databases/create-float-attribute.md +18 -0
  50. package/docs/examples/databases/create-index.md +18 -0
  51. package/docs/examples/databases/create-integer-attribute.md +18 -0
  52. package/docs/examples/databases/create-ip-attribute.md +18 -0
  53. package/docs/examples/databases/create-string-attribute.md +18 -0
  54. package/docs/examples/databases/create-url-attribute.md +18 -0
  55. package/docs/examples/databases/create.md +18 -0
  56. package/docs/examples/databases/delete-attribute.md +18 -0
  57. package/docs/examples/databases/delete-collection.md +18 -0
  58. package/docs/examples/databases/delete-document.md +18 -0
  59. package/docs/examples/databases/delete-index.md +18 -0
  60. package/docs/examples/databases/delete.md +18 -0
  61. package/docs/examples/databases/get-attribute.md +18 -0
  62. package/docs/examples/databases/get-collection-usage.md +18 -0
  63. package/docs/examples/databases/get-collection.md +18 -0
  64. package/docs/examples/databases/get-database-usage.md +18 -0
  65. package/docs/examples/databases/get-document.md +18 -0
  66. package/docs/examples/databases/get-index.md +18 -0
  67. package/docs/examples/databases/get-usage.md +18 -0
  68. package/docs/examples/databases/get.md +18 -0
  69. package/docs/examples/databases/list-attributes.md +18 -0
  70. package/docs/examples/databases/list-collection-logs.md +18 -0
  71. package/docs/examples/databases/list-collections.md +18 -0
  72. package/docs/examples/databases/list-document-logs.md +18 -0
  73. package/docs/examples/databases/list-documents.md +18 -0
  74. package/docs/examples/databases/list-indexes.md +18 -0
  75. package/docs/examples/databases/list-logs.md +18 -0
  76. package/docs/examples/databases/list.md +18 -0
  77. package/docs/examples/databases/update-collection.md +18 -0
  78. package/docs/examples/databases/update-document.md +18 -0
  79. package/docs/examples/databases/update.md +18 -0
  80. package/docs/examples/functions/create-build.md +18 -0
  81. package/docs/examples/functions/create-deployment.md +18 -0
  82. package/docs/examples/functions/create-execution.md +18 -0
  83. package/docs/examples/functions/create-variable.md +18 -0
  84. package/docs/examples/functions/create.md +18 -0
  85. package/docs/examples/functions/delete-deployment.md +18 -0
  86. package/docs/examples/functions/delete-variable.md +18 -0
  87. package/docs/examples/functions/delete.md +18 -0
  88. package/docs/examples/functions/get-deployment.md +18 -0
  89. package/docs/examples/functions/get-execution.md +18 -0
  90. package/docs/examples/functions/get-function-usage.md +18 -0
  91. package/docs/examples/functions/get-usage.md +18 -0
  92. package/docs/examples/functions/get-variable.md +18 -0
  93. package/docs/examples/functions/get.md +18 -0
  94. package/docs/examples/functions/list-deployments.md +18 -0
  95. package/docs/examples/functions/list-executions.md +18 -0
  96. package/docs/examples/functions/list-runtimes.md +18 -0
  97. package/docs/examples/functions/list-variables.md +18 -0
  98. package/docs/examples/functions/list.md +18 -0
  99. package/docs/examples/functions/update-deployment.md +18 -0
  100. package/docs/examples/functions/update-variable.md +18 -0
  101. package/docs/examples/functions/update.md +18 -0
  102. package/docs/examples/graphql/mutation.md +18 -0
  103. package/docs/examples/graphql/query.md +18 -0
  104. package/docs/examples/health/get-antivirus.md +18 -0
  105. package/docs/examples/health/get-cache.md +18 -0
  106. package/docs/examples/health/get-d-b.md +18 -0
  107. package/docs/examples/health/get-queue-certificates.md +18 -0
  108. package/docs/examples/health/get-queue-functions.md +18 -0
  109. package/docs/examples/health/get-queue-logs.md +18 -0
  110. package/docs/examples/health/get-queue-webhooks.md +18 -0
  111. package/docs/examples/health/get-storage-local.md +18 -0
  112. package/docs/examples/health/get-time.md +18 -0
  113. package/docs/examples/health/get.md +18 -0
  114. package/docs/examples/locale/get.md +18 -0
  115. package/docs/examples/locale/list-continents.md +18 -0
  116. package/docs/examples/locale/list-countries-e-u.md +18 -0
  117. package/docs/examples/locale/list-countries-phones.md +18 -0
  118. package/docs/examples/locale/list-countries.md +18 -0
  119. package/docs/examples/locale/list-currencies.md +18 -0
  120. package/docs/examples/locale/list-languages.md +18 -0
  121. package/docs/examples/projects/create-domain.md +18 -0
  122. package/docs/examples/projects/create-key.md +18 -0
  123. package/docs/examples/projects/create-platform.md +18 -0
  124. package/docs/examples/projects/create-webhook.md +18 -0
  125. package/docs/examples/projects/create.md +18 -0
  126. package/docs/examples/projects/delete-domain.md +18 -0
  127. package/docs/examples/projects/delete-key.md +18 -0
  128. package/docs/examples/projects/delete-platform.md +18 -0
  129. package/docs/examples/projects/delete-webhook.md +18 -0
  130. package/docs/examples/projects/delete.md +18 -0
  131. package/docs/examples/projects/get-domain.md +18 -0
  132. package/docs/examples/projects/get-key.md +18 -0
  133. package/docs/examples/projects/get-platform.md +18 -0
  134. package/docs/examples/projects/get-usage.md +18 -0
  135. package/docs/examples/projects/get-webhook.md +18 -0
  136. package/docs/examples/projects/get.md +18 -0
  137. package/docs/examples/projects/list-domains.md +18 -0
  138. package/docs/examples/projects/list-keys.md +18 -0
  139. package/docs/examples/projects/list-platforms.md +18 -0
  140. package/docs/examples/projects/list-webhooks.md +18 -0
  141. package/docs/examples/projects/list.md +18 -0
  142. package/docs/examples/projects/update-auth-duration.md +18 -0
  143. package/docs/examples/projects/update-auth-limit.md +18 -0
  144. package/docs/examples/projects/update-auth-sessions-limit.md +18 -0
  145. package/docs/examples/projects/update-auth-status.md +18 -0
  146. package/docs/examples/projects/update-domain-verification.md +18 -0
  147. package/docs/examples/projects/update-key.md +18 -0
  148. package/docs/examples/projects/update-o-auth2.md +18 -0
  149. package/docs/examples/projects/update-platform.md +18 -0
  150. package/docs/examples/projects/update-service-status.md +18 -0
  151. package/docs/examples/projects/update-webhook-signature.md +18 -0
  152. package/docs/examples/projects/update-webhook.md +18 -0
  153. package/docs/examples/projects/update.md +18 -0
  154. package/docs/examples/storage/create-bucket.md +18 -0
  155. package/docs/examples/storage/create-file.md +18 -0
  156. package/docs/examples/storage/delete-bucket.md +18 -0
  157. package/docs/examples/storage/delete-file.md +18 -0
  158. package/docs/examples/storage/get-bucket-usage.md +18 -0
  159. package/docs/examples/storage/get-bucket.md +18 -0
  160. package/docs/examples/storage/get-file-download.md +14 -0
  161. package/docs/examples/storage/get-file-preview.md +14 -0
  162. package/docs/examples/storage/get-file-view.md +14 -0
  163. package/docs/examples/storage/get-file.md +18 -0
  164. package/docs/examples/storage/get-usage.md +18 -0
  165. package/docs/examples/storage/list-buckets.md +18 -0
  166. package/docs/examples/storage/list-files.md +18 -0
  167. package/docs/examples/storage/update-bucket.md +18 -0
  168. package/docs/examples/storage/update-file.md +18 -0
  169. package/docs/examples/teams/create-membership.md +18 -0
  170. package/docs/examples/teams/create.md +18 -0
  171. package/docs/examples/teams/delete-membership.md +18 -0
  172. package/docs/examples/teams/delete.md +18 -0
  173. package/docs/examples/teams/get-membership.md +18 -0
  174. package/docs/examples/teams/get.md +18 -0
  175. package/docs/examples/teams/list-logs.md +18 -0
  176. package/docs/examples/teams/list-memberships.md +18 -0
  177. package/docs/examples/teams/list.md +18 -0
  178. package/docs/examples/teams/update-membership-roles.md +18 -0
  179. package/docs/examples/teams/update-membership-status.md +18 -0
  180. package/docs/examples/teams/update.md +18 -0
  181. package/docs/examples/users/create-argon2user.md +18 -0
  182. package/docs/examples/users/create-bcrypt-user.md +18 -0
  183. package/docs/examples/users/create-m-d5user.md +18 -0
  184. package/docs/examples/users/create-p-h-pass-user.md +18 -0
  185. package/docs/examples/users/create-s-h-a-user.md +18 -0
  186. package/docs/examples/users/create-scrypt-modified-user.md +18 -0
  187. package/docs/examples/users/create-scrypt-user.md +18 -0
  188. package/docs/examples/users/create.md +18 -0
  189. package/docs/examples/users/delete-session.md +18 -0
  190. package/docs/examples/users/delete-sessions.md +18 -0
  191. package/docs/examples/users/delete.md +18 -0
  192. package/docs/examples/users/get-prefs.md +18 -0
  193. package/docs/examples/users/get-usage.md +18 -0
  194. package/docs/examples/users/get.md +18 -0
  195. package/docs/examples/users/list-logs.md +18 -0
  196. package/docs/examples/users/list-memberships.md +18 -0
  197. package/docs/examples/users/list-sessions.md +18 -0
  198. package/docs/examples/users/list.md +18 -0
  199. package/docs/examples/users/update-email-verification.md +18 -0
  200. package/docs/examples/users/update-email.md +18 -0
  201. package/docs/examples/users/update-name.md +18 -0
  202. package/docs/examples/users/update-password.md +18 -0
  203. package/docs/examples/users/update-phone-verification.md +18 -0
  204. package/docs/examples/users/update-phone.md +18 -0
  205. package/docs/examples/users/update-prefs.md +18 -0
  206. package/docs/examples/users/update-status.md +18 -0
  207. package/package.json +40 -0
  208. package/rollup.config.js +31 -0
  209. package/src/client.ts +472 -0
  210. package/src/id.ts +9 -0
  211. package/src/index.ts +17 -0
  212. package/src/models.ts +2540 -0
  213. package/src/permission.ts +22 -0
  214. package/src/query.ts +56 -0
  215. package/src/role.ts +34 -0
  216. package/src/service.ts +30 -0
  217. package/src/services/account.ts +1009 -0
  218. package/src/services/avatars.ts +351 -0
  219. package/src/services/databases.ts +1525 -0
  220. package/src/services/functions.ts +814 -0
  221. package/src/services/graphql.ts +68 -0
  222. package/src/services/health.ts +202 -0
  223. package/src/services/locale.ts +150 -0
  224. package/src/services/projects.ts +1235 -0
  225. package/src/services/storage.ts +691 -0
  226. package/src/services/teams.ts +445 -0
  227. package/src/services/users.ts +1020 -0
  228. package/tsconfig.json +24 -0
@@ -0,0 +1,814 @@
1
+ import { Service } from '../service';
2
+ import { AppwriteException, Client } from '../client';
3
+ import type { Models } from '../models';
4
+ import type { UploadProgress, Payload } from '../client';
5
+
6
+ export class Functions extends Service {
7
+
8
+ constructor(client: Client)
9
+ {
10
+ super(client);
11
+ }
12
+
13
+ /**
14
+ * List Functions
15
+ *
16
+ * Get a list of all the project's functions. 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 list(queries?: string[], search?: string): Promise<Models.FunctionList> {
25
+ let path = '/functions';
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);
40
+ }
41
+
42
+ /**
43
+ * Create Function
44
+ *
45
+ * Create a new function. You can pass a list of
46
+ * [permissions](/docs/permissions) to allow different project users or team
47
+ * with access to execute the function using the client API.
48
+ *
49
+ * @param {string} functionId
50
+ * @param {string} name
51
+ * @param {string[]} execute
52
+ * @param {string} runtime
53
+ * @param {string[]} events
54
+ * @param {string} schedule
55
+ * @param {number} timeout
56
+ * @param {boolean} enabled
57
+ * @throws {AppwriteException}
58
+ * @returns {Promise}
59
+ */
60
+ async create(functionId: string, name: string, execute: string[], runtime: string, events?: string[], schedule?: string, timeout?: number, enabled?: boolean): Promise<Models.Function> {
61
+ if (typeof functionId === 'undefined') {
62
+ throw new AppwriteException('Missing required parameter: "functionId"');
63
+ }
64
+
65
+ if (typeof name === 'undefined') {
66
+ throw new AppwriteException('Missing required parameter: "name"');
67
+ }
68
+
69
+ if (typeof execute === 'undefined') {
70
+ throw new AppwriteException('Missing required parameter: "execute"');
71
+ }
72
+
73
+ if (typeof runtime === 'undefined') {
74
+ throw new AppwriteException('Missing required parameter: "runtime"');
75
+ }
76
+
77
+ let path = '/functions';
78
+ let payload: Payload = {};
79
+
80
+ if (typeof functionId !== 'undefined') {
81
+ payload['functionId'] = functionId;
82
+ }
83
+
84
+ if (typeof name !== 'undefined') {
85
+ payload['name'] = name;
86
+ }
87
+
88
+ if (typeof execute !== 'undefined') {
89
+ payload['execute'] = execute;
90
+ }
91
+
92
+ if (typeof runtime !== 'undefined') {
93
+ payload['runtime'] = runtime;
94
+ }
95
+
96
+ if (typeof events !== 'undefined') {
97
+ payload['events'] = events;
98
+ }
99
+
100
+ if (typeof schedule !== 'undefined') {
101
+ payload['schedule'] = schedule;
102
+ }
103
+
104
+ if (typeof timeout !== 'undefined') {
105
+ payload['timeout'] = timeout;
106
+ }
107
+
108
+ if (typeof enabled !== 'undefined') {
109
+ payload['enabled'] = enabled;
110
+ }
111
+
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
+ * List runtimes
120
+ *
121
+ * Get a list of all runtimes that are currently active on your instance.
122
+ *
123
+ * @throws {AppwriteException}
124
+ * @returns {Promise}
125
+ */
126
+ async listRuntimes(): Promise<Models.RuntimeList> {
127
+ let path = '/functions/runtimes';
128
+ let payload: Payload = {};
129
+
130
+ const uri = new URL(this.client.config.endpoint + path);
131
+ return await this.client.call('get', uri, {
132
+ 'content-type': 'application/json',
133
+ }, payload);
134
+ }
135
+
136
+ /**
137
+ * Get Functions Usage
138
+ *
139
+ *
140
+ * @param {string} range
141
+ * @throws {AppwriteException}
142
+ * @returns {Promise}
143
+ */
144
+ async getUsage(range?: string): Promise<Models.UsageFunctions> {
145
+ let path = '/functions/usage';
146
+ let payload: Payload = {};
147
+
148
+ if (typeof range !== 'undefined') {
149
+ payload['range'] = range;
150
+ }
151
+
152
+ const uri = new URL(this.client.config.endpoint + path);
153
+ return await this.client.call('get', uri, {
154
+ 'content-type': 'application/json',
155
+ }, payload);
156
+ }
157
+
158
+ /**
159
+ * Get Function
160
+ *
161
+ * Get a function by its unique ID.
162
+ *
163
+ * @param {string} functionId
164
+ * @throws {AppwriteException}
165
+ * @returns {Promise}
166
+ */
167
+ async get(functionId: string): Promise<Models.Function> {
168
+ if (typeof functionId === 'undefined') {
169
+ throw new AppwriteException('Missing required parameter: "functionId"');
170
+ }
171
+
172
+ let path = '/functions/{functionId}'.replace('{functionId}', functionId);
173
+ let payload: Payload = {};
174
+
175
+ const uri = new URL(this.client.config.endpoint + path);
176
+ return await this.client.call('get', uri, {
177
+ 'content-type': 'application/json',
178
+ }, payload);
179
+ }
180
+
181
+ /**
182
+ * Update Function
183
+ *
184
+ * Update function by its unique ID.
185
+ *
186
+ * @param {string} functionId
187
+ * @param {string} name
188
+ * @param {string[]} execute
189
+ * @param {string[]} events
190
+ * @param {string} schedule
191
+ * @param {number} timeout
192
+ * @param {boolean} enabled
193
+ * @throws {AppwriteException}
194
+ * @returns {Promise}
195
+ */
196
+ async update(functionId: string, name: string, execute: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean): Promise<Models.Function> {
197
+ if (typeof functionId === 'undefined') {
198
+ throw new AppwriteException('Missing required parameter: "functionId"');
199
+ }
200
+
201
+ if (typeof name === 'undefined') {
202
+ throw new AppwriteException('Missing required parameter: "name"');
203
+ }
204
+
205
+ if (typeof execute === 'undefined') {
206
+ throw new AppwriteException('Missing required parameter: "execute"');
207
+ }
208
+
209
+ let path = '/functions/{functionId}'.replace('{functionId}', functionId);
210
+ let payload: Payload = {};
211
+
212
+ if (typeof name !== 'undefined') {
213
+ payload['name'] = name;
214
+ }
215
+
216
+ if (typeof execute !== 'undefined') {
217
+ payload['execute'] = execute;
218
+ }
219
+
220
+ if (typeof events !== 'undefined') {
221
+ payload['events'] = events;
222
+ }
223
+
224
+ if (typeof schedule !== 'undefined') {
225
+ payload['schedule'] = schedule;
226
+ }
227
+
228
+ if (typeof timeout !== 'undefined') {
229
+ payload['timeout'] = timeout;
230
+ }
231
+
232
+ if (typeof enabled !== 'undefined') {
233
+ payload['enabled'] = enabled;
234
+ }
235
+
236
+ const uri = new URL(this.client.config.endpoint + path);
237
+ return await this.client.call('put', uri, {
238
+ 'content-type': 'application/json',
239
+ }, payload);
240
+ }
241
+
242
+ /**
243
+ * Delete Function
244
+ *
245
+ * Delete a function by its unique ID.
246
+ *
247
+ * @param {string} functionId
248
+ * @throws {AppwriteException}
249
+ * @returns {Promise}
250
+ */
251
+ async delete(functionId: string): Promise<{}> {
252
+ if (typeof functionId === 'undefined') {
253
+ throw new AppwriteException('Missing required parameter: "functionId"');
254
+ }
255
+
256
+ let path = '/functions/{functionId}'.replace('{functionId}', functionId);
257
+ let payload: Payload = {};
258
+
259
+ const uri = new URL(this.client.config.endpoint + path);
260
+ return await this.client.call('delete', uri, {
261
+ 'content-type': 'application/json',
262
+ }, payload);
263
+ }
264
+
265
+ /**
266
+ * List Deployments
267
+ *
268
+ * Get a list of all the project's code deployments. You can use the query
269
+ * params to filter your results.
270
+ *
271
+ * @param {string} functionId
272
+ * @param {string[]} queries
273
+ * @param {string} search
274
+ * @throws {AppwriteException}
275
+ * @returns {Promise}
276
+ */
277
+ async listDeployments(functionId: string, queries?: string[], search?: string): Promise<Models.DeploymentList> {
278
+ if (typeof functionId === 'undefined') {
279
+ throw new AppwriteException('Missing required parameter: "functionId"');
280
+ }
281
+
282
+ let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
283
+ let payload: Payload = {};
284
+
285
+ if (typeof queries !== 'undefined') {
286
+ payload['queries'] = queries;
287
+ }
288
+
289
+ if (typeof search !== 'undefined') {
290
+ payload['search'] = search;
291
+ }
292
+
293
+ const uri = new URL(this.client.config.endpoint + path);
294
+ return await this.client.call('get', uri, {
295
+ 'content-type': 'application/json',
296
+ }, payload);
297
+ }
298
+
299
+ /**
300
+ * Create Deployment
301
+ *
302
+ * Create a new function code deployment. Use this endpoint to upload a new
303
+ * version of your code function. To execute your newly uploaded code, you'll
304
+ * need to update the function's deployment to use your new deployment UID.
305
+ *
306
+ * This endpoint accepts a tar.gz file compressed with your code. Make sure to
307
+ * include any dependencies your code has within the compressed file. You can
308
+ * learn more about code packaging in the [Appwrite Cloud Functions
309
+ * tutorial](/docs/functions).
310
+ *
311
+ * Use the "command" param to set the entry point used to execute your code.
312
+ *
313
+ * @param {string} functionId
314
+ * @param {string} entrypoint
315
+ * @param {File} code
316
+ * @param {boolean} activate
317
+ * @throws {AppwriteException}
318
+ * @returns {Promise}
319
+ */
320
+ async createDeployment(functionId: string, entrypoint: string, code: File, activate: boolean, onProgress = (progress: UploadProgress) => {}): Promise<Models.Deployment> {
321
+ if (typeof functionId === 'undefined') {
322
+ throw new AppwriteException('Missing required parameter: "functionId"');
323
+ }
324
+
325
+ if (typeof entrypoint === 'undefined') {
326
+ throw new AppwriteException('Missing required parameter: "entrypoint"');
327
+ }
328
+
329
+ if (typeof code === 'undefined') {
330
+ throw new AppwriteException('Missing required parameter: "code"');
331
+ }
332
+
333
+ if (typeof activate === 'undefined') {
334
+ throw new AppwriteException('Missing required parameter: "activate"');
335
+ }
336
+
337
+ let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
338
+ let payload: Payload = {};
339
+
340
+ if (typeof entrypoint !== 'undefined') {
341
+ payload['entrypoint'] = entrypoint;
342
+ }
343
+
344
+ if (typeof code !== 'undefined') {
345
+ payload['code'] = code;
346
+ }
347
+
348
+ if (typeof activate !== 'undefined') {
349
+ payload['activate'] = activate;
350
+ }
351
+
352
+ const uri = new URL(this.client.config.endpoint + path);
353
+
354
+ if(!(code instanceof File)) {
355
+ throw new AppwriteException('Parameter "code" has to be a File.');
356
+ }
357
+
358
+ const size = code.size;
359
+
360
+ if (size <= Service.CHUNK_SIZE) {
361
+ return await this.client.call('post', uri, {
362
+
363
+ 'content-type': 'multipart/form-data',
364
+ }, payload);
365
+ }
366
+ let id = undefined;
367
+ let response = undefined;
368
+
369
+ const headers: { [header: string]: string } = {
370
+ 'content-type': 'multipart/form-data',
371
+ }
372
+
373
+ let counter = 0;
374
+ const totalCounters = Math.ceil(size / Service.CHUNK_SIZE);
375
+
376
+ for (counter; counter < totalCounters; counter++) {
377
+ const start = (counter * Service.CHUNK_SIZE);
378
+ const end = Math.min((((counter * Service.CHUNK_SIZE) + Service.CHUNK_SIZE) - 1), size);
379
+
380
+ headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size
381
+
382
+ if (id) {
383
+ headers['x-appwrite-id'] = id;
384
+ }
385
+
386
+ const stream = code.slice(start, end + 1);
387
+ payload['code'] = new File([stream], code.name);
388
+
389
+ response = await this.client.call('post', uri, headers, payload);
390
+
391
+ if (!id) {
392
+ id = response['$id'];
393
+ }
394
+
395
+ if (onProgress) {
396
+ onProgress({
397
+ $id: response.$id,
398
+ progress: Math.min((counter + 1) * Service.CHUNK_SIZE - 1, size) / size * 100,
399
+ sizeUploaded: end,
400
+ chunksTotal: response.chunksTotal,
401
+ chunksUploaded: response.chunksUploaded
402
+ });
403
+ }
404
+ }
405
+
406
+ return response;
407
+ }
408
+
409
+ /**
410
+ * Get Deployment
411
+ *
412
+ * Get a code deployment by its unique ID.
413
+ *
414
+ * @param {string} functionId
415
+ * @param {string} deploymentId
416
+ * @throws {AppwriteException}
417
+ * @returns {Promise}
418
+ */
419
+ async getDeployment(functionId: string, deploymentId: string): Promise<Models.Deployment> {
420
+ if (typeof functionId === 'undefined') {
421
+ throw new AppwriteException('Missing required parameter: "functionId"');
422
+ }
423
+
424
+ if (typeof deploymentId === 'undefined') {
425
+ throw new AppwriteException('Missing required parameter: "deploymentId"');
426
+ }
427
+
428
+ let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
429
+ let payload: Payload = {};
430
+
431
+ const uri = new URL(this.client.config.endpoint + path);
432
+ return await this.client.call('get', uri, {
433
+ 'content-type': 'application/json',
434
+ }, payload);
435
+ }
436
+
437
+ /**
438
+ * Update Function Deployment
439
+ *
440
+ * Update the function code deployment ID using the unique function ID. Use
441
+ * this endpoint to switch the code deployment that should be executed by the
442
+ * execution endpoint.
443
+ *
444
+ * @param {string} functionId
445
+ * @param {string} deploymentId
446
+ * @throws {AppwriteException}
447
+ * @returns {Promise}
448
+ */
449
+ async updateDeployment(functionId: string, deploymentId: string): Promise<Models.Function> {
450
+ if (typeof functionId === 'undefined') {
451
+ throw new AppwriteException('Missing required parameter: "functionId"');
452
+ }
453
+
454
+ if (typeof deploymentId === 'undefined') {
455
+ throw new AppwriteException('Missing required parameter: "deploymentId"');
456
+ }
457
+
458
+ let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
459
+ let payload: Payload = {};
460
+
461
+ const uri = new URL(this.client.config.endpoint + path);
462
+ return await this.client.call('patch', uri, {
463
+ 'content-type': 'application/json',
464
+ }, payload);
465
+ }
466
+
467
+ /**
468
+ * Delete Deployment
469
+ *
470
+ * Delete a code deployment by its unique ID.
471
+ *
472
+ * @param {string} functionId
473
+ * @param {string} deploymentId
474
+ * @throws {AppwriteException}
475
+ * @returns {Promise}
476
+ */
477
+ async deleteDeployment(functionId: string, deploymentId: string): Promise<{}> {
478
+ if (typeof functionId === 'undefined') {
479
+ throw new AppwriteException('Missing required parameter: "functionId"');
480
+ }
481
+
482
+ if (typeof deploymentId === 'undefined') {
483
+ throw new AppwriteException('Missing required parameter: "deploymentId"');
484
+ }
485
+
486
+ let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
487
+ let payload: Payload = {};
488
+
489
+ const uri = new URL(this.client.config.endpoint + path);
490
+ return await this.client.call('delete', uri, {
491
+ 'content-type': 'application/json',
492
+ }, payload);
493
+ }
494
+
495
+ /**
496
+ * Create Build
497
+ *
498
+ *
499
+ * @param {string} functionId
500
+ * @param {string} deploymentId
501
+ * @param {string} buildId
502
+ * @throws {AppwriteException}
503
+ * @returns {Promise}
504
+ */
505
+ async createBuild(functionId: string, deploymentId: string, buildId: string): Promise<{}> {
506
+ if (typeof functionId === 'undefined') {
507
+ throw new AppwriteException('Missing required parameter: "functionId"');
508
+ }
509
+
510
+ if (typeof deploymentId === 'undefined') {
511
+ throw new AppwriteException('Missing required parameter: "deploymentId"');
512
+ }
513
+
514
+ if (typeof buildId === 'undefined') {
515
+ throw new AppwriteException('Missing required parameter: "buildId"');
516
+ }
517
+
518
+ let path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId).replace('{buildId}', buildId);
519
+ let payload: Payload = {};
520
+
521
+ const uri = new URL(this.client.config.endpoint + path);
522
+ return await this.client.call('post', uri, {
523
+ 'content-type': 'application/json',
524
+ }, payload);
525
+ }
526
+
527
+ /**
528
+ * List Executions
529
+ *
530
+ * Get a list of all the current user function execution logs. You can use the
531
+ * query params to filter your results.
532
+ *
533
+ * @param {string} functionId
534
+ * @param {string[]} queries
535
+ * @param {string} search
536
+ * @throws {AppwriteException}
537
+ * @returns {Promise}
538
+ */
539
+ async listExecutions(functionId: string, queries?: string[], search?: string): Promise<Models.ExecutionList> {
540
+ if (typeof functionId === 'undefined') {
541
+ throw new AppwriteException('Missing required parameter: "functionId"');
542
+ }
543
+
544
+ let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
545
+ let payload: Payload = {};
546
+
547
+ if (typeof queries !== 'undefined') {
548
+ payload['queries'] = queries;
549
+ }
550
+
551
+ if (typeof search !== 'undefined') {
552
+ payload['search'] = search;
553
+ }
554
+
555
+ const uri = new URL(this.client.config.endpoint + path);
556
+ return await this.client.call('get', uri, {
557
+ 'content-type': 'application/json',
558
+ }, payload);
559
+ }
560
+
561
+ /**
562
+ * Create Execution
563
+ *
564
+ * Trigger a function execution. The returned object will return you the
565
+ * current execution status. You can ping the `Get Execution` endpoint to get
566
+ * updates on the current execution status. Once this endpoint is called, your
567
+ * function execution process will start asynchronously.
568
+ *
569
+ * @param {string} functionId
570
+ * @param {string} data
571
+ * @param {boolean} async
572
+ * @throws {AppwriteException}
573
+ * @returns {Promise}
574
+ */
575
+ async createExecution(functionId: string, data?: string, async?: boolean): Promise<Models.Execution> {
576
+ if (typeof functionId === 'undefined') {
577
+ throw new AppwriteException('Missing required parameter: "functionId"');
578
+ }
579
+
580
+ let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
581
+ let payload: Payload = {};
582
+
583
+ if (typeof data !== 'undefined') {
584
+ payload['data'] = data;
585
+ }
586
+
587
+ if (typeof async !== 'undefined') {
588
+ payload['async'] = async;
589
+ }
590
+
591
+ const uri = new URL(this.client.config.endpoint + path);
592
+ return await this.client.call('post', uri, {
593
+ 'content-type': 'application/json',
594
+ }, payload);
595
+ }
596
+
597
+ /**
598
+ * Get Execution
599
+ *
600
+ * Get a function execution log by its unique ID.
601
+ *
602
+ * @param {string} functionId
603
+ * @param {string} executionId
604
+ * @throws {AppwriteException}
605
+ * @returns {Promise}
606
+ */
607
+ async getExecution(functionId: string, executionId: string): Promise<Models.Execution> {
608
+ if (typeof functionId === 'undefined') {
609
+ throw new AppwriteException('Missing required parameter: "functionId"');
610
+ }
611
+
612
+ if (typeof executionId === 'undefined') {
613
+ throw new AppwriteException('Missing required parameter: "executionId"');
614
+ }
615
+
616
+ let path = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
617
+ let payload: Payload = {};
618
+
619
+ const uri = new URL(this.client.config.endpoint + path);
620
+ return await this.client.call('get', uri, {
621
+ 'content-type': 'application/json',
622
+ }, payload);
623
+ }
624
+
625
+ /**
626
+ * Get Function Usage
627
+ *
628
+ *
629
+ * @param {string} functionId
630
+ * @param {string} range
631
+ * @throws {AppwriteException}
632
+ * @returns {Promise}
633
+ */
634
+ async getFunctionUsage(functionId: string, range?: string): Promise<Models.UsageFunctions> {
635
+ if (typeof functionId === 'undefined') {
636
+ throw new AppwriteException('Missing required parameter: "functionId"');
637
+ }
638
+
639
+ let path = '/functions/{functionId}/usage'.replace('{functionId}', functionId);
640
+ let payload: Payload = {};
641
+
642
+ if (typeof range !== 'undefined') {
643
+ payload['range'] = range;
644
+ }
645
+
646
+ const uri = new URL(this.client.config.endpoint + path);
647
+ return await this.client.call('get', uri, {
648
+ 'content-type': 'application/json',
649
+ }, payload);
650
+ }
651
+
652
+ /**
653
+ * List Variables
654
+ *
655
+ * Get a list of all variables of a specific function.
656
+ *
657
+ * @param {string} functionId
658
+ * @throws {AppwriteException}
659
+ * @returns {Promise}
660
+ */
661
+ async listVariables(functionId: string): Promise<Models.VariableList> {
662
+ if (typeof functionId === 'undefined') {
663
+ throw new AppwriteException('Missing required parameter: "functionId"');
664
+ }
665
+
666
+ let path = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
667
+ let payload: Payload = {};
668
+
669
+ const uri = new URL(this.client.config.endpoint + path);
670
+ return await this.client.call('get', uri, {
671
+ 'content-type': 'application/json',
672
+ }, payload);
673
+ }
674
+
675
+ /**
676
+ * Create Variable
677
+ *
678
+ * Create a new function variable. These variables can be accessed within
679
+ * function in the `env` object under the request variable.
680
+ *
681
+ * @param {string} functionId
682
+ * @param {string} key
683
+ * @param {string} value
684
+ * @throws {AppwriteException}
685
+ * @returns {Promise}
686
+ */
687
+ async createVariable(functionId: string, key: string, value: string): Promise<Models.Variable> {
688
+ if (typeof functionId === 'undefined') {
689
+ throw new AppwriteException('Missing required parameter: "functionId"');
690
+ }
691
+
692
+ if (typeof key === 'undefined') {
693
+ throw new AppwriteException('Missing required parameter: "key"');
694
+ }
695
+
696
+ if (typeof value === 'undefined') {
697
+ throw new AppwriteException('Missing required parameter: "value"');
698
+ }
699
+
700
+ let path = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
701
+ let payload: Payload = {};
702
+
703
+ if (typeof key !== 'undefined') {
704
+ payload['key'] = key;
705
+ }
706
+
707
+ if (typeof value !== 'undefined') {
708
+ payload['value'] = value;
709
+ }
710
+
711
+ const uri = new URL(this.client.config.endpoint + path);
712
+ return await this.client.call('post', uri, {
713
+ 'content-type': 'application/json',
714
+ }, payload);
715
+ }
716
+
717
+ /**
718
+ * Get Variable
719
+ *
720
+ * Get a variable by its unique ID.
721
+ *
722
+ * @param {string} functionId
723
+ * @param {string} variableId
724
+ * @throws {AppwriteException}
725
+ * @returns {Promise}
726
+ */
727
+ async getVariable(functionId: string, variableId: string): Promise<Models.Variable> {
728
+ if (typeof functionId === 'undefined') {
729
+ throw new AppwriteException('Missing required parameter: "functionId"');
730
+ }
731
+
732
+ if (typeof variableId === 'undefined') {
733
+ throw new AppwriteException('Missing required parameter: "variableId"');
734
+ }
735
+
736
+ let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
737
+ let payload: Payload = {};
738
+
739
+ const uri = new URL(this.client.config.endpoint + path);
740
+ return await this.client.call('get', uri, {
741
+ 'content-type': 'application/json',
742
+ }, payload);
743
+ }
744
+
745
+ /**
746
+ * Update Variable
747
+ *
748
+ * Update variable by its unique ID.
749
+ *
750
+ * @param {string} functionId
751
+ * @param {string} variableId
752
+ * @param {string} key
753
+ * @param {string} value
754
+ * @throws {AppwriteException}
755
+ * @returns {Promise}
756
+ */
757
+ async updateVariable(functionId: string, variableId: string, key: string, value?: string): Promise<Models.Variable> {
758
+ if (typeof functionId === 'undefined') {
759
+ throw new AppwriteException('Missing required parameter: "functionId"');
760
+ }
761
+
762
+ if (typeof variableId === 'undefined') {
763
+ throw new AppwriteException('Missing required parameter: "variableId"');
764
+ }
765
+
766
+ if (typeof key === 'undefined') {
767
+ throw new AppwriteException('Missing required parameter: "key"');
768
+ }
769
+
770
+ let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
771
+ let payload: Payload = {};
772
+
773
+ if (typeof key !== 'undefined') {
774
+ payload['key'] = key;
775
+ }
776
+
777
+ if (typeof value !== 'undefined') {
778
+ payload['value'] = value;
779
+ }
780
+
781
+ const uri = new URL(this.client.config.endpoint + path);
782
+ return await this.client.call('put', uri, {
783
+ 'content-type': 'application/json',
784
+ }, payload);
785
+ }
786
+
787
+ /**
788
+ * Delete Variable
789
+ *
790
+ * Delete a variable by its unique ID.
791
+ *
792
+ * @param {string} functionId
793
+ * @param {string} variableId
794
+ * @throws {AppwriteException}
795
+ * @returns {Promise}
796
+ */
797
+ async deleteVariable(functionId: string, variableId: string): Promise<{}> {
798
+ if (typeof functionId === 'undefined') {
799
+ throw new AppwriteException('Missing required parameter: "functionId"');
800
+ }
801
+
802
+ if (typeof variableId === 'undefined') {
803
+ throw new AppwriteException('Missing required parameter: "variableId"');
804
+ }
805
+
806
+ let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
807
+ let payload: Payload = {};
808
+
809
+ const uri = new URL(this.client.config.endpoint + path);
810
+ return await this.client.call('delete', uri, {
811
+ 'content-type': 'application/json',
812
+ }, payload);
813
+ }
814
+ };