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.
- package/README.md +2 -2
- package/docs/examples/account/create-phone-verification.md +1 -1
- package/docs/examples/account/create-recovery.md +1 -1
- package/docs/examples/account/create-verification.md +1 -1
- package/docs/examples/account/delete-identity.md +20 -0
- package/docs/examples/account/delete-session.md +1 -1
- package/docs/examples/account/delete-sessions.md +1 -1
- package/docs/examples/account/get-prefs.md +1 -1
- package/docs/examples/account/get-session.md +1 -1
- package/docs/examples/account/get.md +1 -1
- package/docs/examples/account/list-identities.md +20 -0
- package/docs/examples/account/list-logs.md +1 -1
- package/docs/examples/account/list-sessions.md +1 -1
- package/docs/examples/account/update-email.md +1 -1
- package/docs/examples/account/update-name.md +1 -1
- package/docs/examples/account/update-password.md +1 -1
- package/docs/examples/account/update-phone-verification.md +1 -1
- package/docs/examples/account/update-phone.md +1 -1
- package/docs/examples/account/update-prefs.md +1 -1
- package/docs/examples/account/update-recovery.md +1 -1
- package/docs/examples/account/update-session.md +1 -1
- package/docs/examples/account/update-status.md +1 -1
- package/docs/examples/account/update-verification.md +1 -1
- package/docs/examples/avatars/get-browser.md +1 -1
- package/docs/examples/avatars/get-credit-card.md +1 -1
- package/docs/examples/avatars/get-favicon.md +1 -1
- package/docs/examples/avatars/get-flag.md +1 -1
- package/docs/examples/avatars/get-image.md +1 -1
- package/docs/examples/avatars/get-initials.md +1 -1
- package/docs/examples/avatars/get-q-r.md +1 -1
- package/docs/examples/databases/create-boolean-attribute.md +1 -1
- package/docs/examples/databases/create-collection.md +1 -1
- package/docs/examples/databases/create-datetime-attribute.md +1 -1
- package/docs/examples/databases/create-document.md +1 -1
- package/docs/examples/databases/create-email-attribute.md +1 -1
- package/docs/examples/databases/create-enum-attribute.md +1 -1
- package/docs/examples/databases/create-float-attribute.md +1 -1
- package/docs/examples/databases/create-index.md +1 -1
- package/docs/examples/databases/create-integer-attribute.md +1 -1
- package/docs/examples/databases/create-ip-attribute.md +1 -1
- package/docs/examples/databases/create-relationship-attribute.md +1 -1
- package/docs/examples/databases/create-string-attribute.md +1 -1
- package/docs/examples/databases/create-url-attribute.md +1 -1
- package/docs/examples/databases/create.md +1 -1
- package/docs/examples/databases/delete-attribute.md +1 -1
- package/docs/examples/databases/delete-collection.md +1 -1
- package/docs/examples/databases/delete-document.md +1 -1
- package/docs/examples/databases/delete-index.md +1 -1
- package/docs/examples/databases/delete.md +1 -1
- package/docs/examples/databases/get-attribute.md +1 -1
- package/docs/examples/databases/get-collection.md +1 -1
- package/docs/examples/databases/get-document.md +1 -1
- package/docs/examples/databases/get-index.md +1 -1
- package/docs/examples/databases/get.md +1 -1
- package/docs/examples/databases/list-attributes.md +1 -1
- package/docs/examples/databases/list-collections.md +1 -1
- package/docs/examples/databases/list-documents.md +1 -1
- package/docs/examples/databases/list-indexes.md +1 -1
- package/docs/examples/databases/list.md +1 -1
- package/docs/examples/databases/update-boolean-attribute.md +1 -1
- package/docs/examples/databases/update-collection.md +1 -1
- package/docs/examples/databases/update-datetime-attribute.md +1 -1
- package/docs/examples/databases/update-document.md +1 -1
- package/docs/examples/databases/update-email-attribute.md +1 -1
- package/docs/examples/databases/update-enum-attribute.md +1 -1
- package/docs/examples/databases/update-float-attribute.md +1 -1
- package/docs/examples/databases/update-integer-attribute.md +1 -1
- package/docs/examples/databases/update-ip-attribute.md +1 -1
- package/docs/examples/databases/update-relationship-attribute.md +1 -1
- package/docs/examples/databases/update-string-attribute.md +1 -1
- package/docs/examples/databases/update-url-attribute.md +1 -1
- package/docs/examples/databases/update.md +1 -1
- package/docs/examples/functions/create-build.md +1 -1
- package/docs/examples/functions/create-deployment.md +2 -2
- package/docs/examples/functions/create-execution.md +1 -1
- package/docs/examples/functions/create-variable.md +1 -1
- package/docs/examples/functions/create.md +1 -1
- package/docs/examples/functions/delete-deployment.md +1 -1
- package/docs/examples/functions/delete-variable.md +1 -1
- package/docs/examples/functions/delete.md +1 -1
- package/docs/examples/functions/download-deployment.md +20 -0
- package/docs/examples/functions/get-deployment.md +1 -1
- package/docs/examples/functions/get-execution.md +1 -1
- package/docs/examples/functions/get-variable.md +1 -1
- package/docs/examples/functions/get.md +1 -1
- package/docs/examples/functions/list-deployments.md +1 -1
- package/docs/examples/functions/list-executions.md +1 -1
- package/docs/examples/functions/list-runtimes.md +1 -1
- package/docs/examples/functions/list-variables.md +1 -1
- package/docs/examples/functions/list.md +1 -1
- package/docs/examples/functions/update-deployment.md +1 -1
- package/docs/examples/functions/update-variable.md +1 -1
- package/docs/examples/functions/update.md +2 -2
- package/docs/examples/graphql/mutation.md +1 -1
- package/docs/examples/graphql/query.md +1 -1
- package/docs/examples/health/get-antivirus.md +1 -1
- package/docs/examples/health/get-cache.md +1 -1
- package/docs/examples/health/get-d-b.md +1 -1
- package/docs/examples/health/get-pub-sub.md +20 -0
- package/docs/examples/health/get-queue-certificates.md +1 -1
- package/docs/examples/health/get-queue-functions.md +1 -1
- package/docs/examples/health/get-queue-logs.md +1 -1
- package/docs/examples/health/get-queue-webhooks.md +1 -1
- package/docs/examples/health/get-queue.md +20 -0
- package/docs/examples/health/get-storage-local.md +1 -1
- package/docs/examples/health/get-time.md +1 -1
- package/docs/examples/health/get.md +1 -1
- package/docs/examples/locale/get.md +1 -1
- package/docs/examples/locale/list-codes.md +20 -0
- package/docs/examples/locale/list-continents.md +1 -1
- package/docs/examples/locale/list-countries-e-u.md +1 -1
- package/docs/examples/locale/list-countries-phones.md +1 -1
- package/docs/examples/locale/list-countries.md +1 -1
- package/docs/examples/locale/list-currencies.md +1 -1
- package/docs/examples/locale/list-languages.md +1 -1
- package/docs/examples/storage/create-bucket.md +1 -1
- package/docs/examples/storage/create-file.md +1 -1
- package/docs/examples/storage/delete-bucket.md +1 -1
- package/docs/examples/storage/delete-file.md +1 -1
- package/docs/examples/storage/get-bucket.md +1 -1
- package/docs/examples/storage/get-file-download.md +1 -1
- package/docs/examples/storage/get-file-preview.md +1 -1
- package/docs/examples/storage/get-file-view.md +1 -1
- package/docs/examples/storage/get-file.md +1 -1
- package/docs/examples/storage/list-buckets.md +1 -1
- package/docs/examples/storage/list-files.md +1 -1
- package/docs/examples/storage/update-bucket.md +1 -1
- package/docs/examples/storage/update-file.md +1 -1
- package/docs/examples/teams/create-membership.md +1 -1
- package/docs/examples/teams/create.md +1 -1
- package/docs/examples/teams/delete-membership.md +1 -1
- package/docs/examples/teams/delete.md +1 -1
- package/docs/examples/teams/get-membership.md +1 -1
- package/docs/examples/teams/get-prefs.md +1 -1
- package/docs/examples/teams/get.md +1 -1
- package/docs/examples/teams/list-memberships.md +1 -1
- package/docs/examples/teams/list.md +1 -1
- package/docs/examples/teams/update-membership-status.md +1 -1
- package/docs/examples/teams/{update-membership-roles.md → update-membership.md} +2 -2
- package/docs/examples/teams/update-name.md +1 -1
- package/docs/examples/teams/update-prefs.md +1 -1
- package/docs/examples/users/create-argon2user.md +1 -1
- package/docs/examples/users/create-bcrypt-user.md +1 -1
- package/docs/examples/users/create-m-d5user.md +1 -1
- package/docs/examples/users/create-p-h-pass-user.md +1 -1
- package/docs/examples/users/create-s-h-a-user.md +1 -1
- package/docs/examples/users/create-scrypt-modified-user.md +1 -1
- package/docs/examples/users/create-scrypt-user.md +1 -1
- package/docs/examples/users/create.md +1 -1
- package/docs/examples/users/delete-identity.md +20 -0
- package/docs/examples/users/delete-session.md +1 -1
- package/docs/examples/users/delete-sessions.md +1 -1
- package/docs/examples/users/delete.md +1 -1
- package/docs/examples/users/get-prefs.md +1 -1
- package/docs/examples/users/get.md +1 -1
- package/docs/examples/users/list-identities.md +20 -0
- package/docs/examples/users/list-logs.md +1 -1
- package/docs/examples/users/list-memberships.md +1 -1
- package/docs/examples/users/list-sessions.md +1 -1
- package/docs/examples/users/list.md +1 -1
- package/docs/examples/users/update-email-verification.md +1 -1
- package/docs/examples/users/update-email.md +1 -1
- package/docs/examples/users/update-labels.md +20 -0
- package/docs/examples/users/update-name.md +1 -1
- package/docs/examples/users/update-password.md +1 -1
- package/docs/examples/users/update-phone-verification.md +1 -1
- package/docs/examples/users/update-phone.md +1 -1
- package/docs/examples/users/update-prefs.md +1 -1
- package/docs/examples/users/update-status.md +1 -1
- package/index.d.ts +435 -55
- package/lib/client.js +4 -2
- package/lib/role.js +74 -3
- package/lib/services/account.js +94 -50
- package/lib/services/avatars.js +14 -14
- package/lib/services/databases.js +120 -90
- package/lib/services/functions.js +223 -65
- package/lib/services/graphql.js +4 -4
- package/lib/services/health.js +57 -22
- package/lib/services/locale.js +32 -14
- package/lib/services/storage.js +44 -34
- package/lib/services/teams.js +29 -28
- package/lib/services/users.js +135 -50
- 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
|
-
|
|
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',
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
185
|
+
const apiPath = '/functions/runtimes';
|
|
126
186
|
let payload = {};
|
|
127
187
|
|
|
128
|
-
return await this.client.call('get',
|
|
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
|
-
|
|
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',
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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',
|
|
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
|
-
|
|
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',
|
|
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
|
|
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,
|
|
288
|
-
|
|
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
|
|
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 =
|
|
453
|
+
const end = currentChunkStart + currentChunkSize - 1;
|
|
344
454
|
|
|
345
455
|
if(!lastUpload || currentChunkStart !== 0) {
|
|
346
|
-
|
|
456
|
+
apiHeaders['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
|
|
347
457
|
}
|
|
348
458
|
|
|
349
459
|
if (id) {
|
|
350
|
-
|
|
460
|
+
apiHeaders['x-appwrite-id'] = id;
|
|
351
461
|
}
|
|
352
462
|
|
|
353
|
-
|
|
354
|
-
|
|
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',
|
|
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
|
-
|
|
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',
|
|
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
|
-
|
|
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',
|
|
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
|
-
|
|
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',
|
|
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
|
-
|
|
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',
|
|
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
|
-
|
|
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',
|
|
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}
|
|
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,
|
|
602
|
-
|
|
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
|
|
610
|
-
payload['
|
|
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
|
-
|
|
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
|
-
|
|
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',
|
|
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
|
-
|
|
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',
|
|
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
|
|
675
|
-
*
|
|
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
|
-
|
|
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',
|
|
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
|
-
|
|
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',
|
|
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
|
-
|
|
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',
|
|
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
|
-
|
|
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',
|
|
960
|
+
return await this.client.call('delete', apiPath, {
|
|
803
961
|
'content-type': 'application/json',
|
|
804
962
|
}, payload);
|
|
805
963
|
}
|