node-appwrite 4.0.1 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/docs/examples/account/update-session.md +20 -0
- package/docs/examples/functions/{create-tag.md → create-deployment.md} +1 -1
- package/docs/examples/functions/{delete-tag.md → delete-deployment.md} +1 -1
- package/docs/examples/functions/{update-tag.md → get-deployment.md} +1 -1
- package/docs/examples/functions/{list-tags.md → list-deployments.md} +1 -1
- package/docs/examples/functions/retry-build.md +20 -0
- package/docs/examples/functions/{get-tag.md → update-deployment.md} +1 -1
- package/docs/examples/storage/create-bucket.md +20 -0
- package/docs/examples/storage/create-file.md +1 -1
- package/docs/examples/storage/delete-bucket.md +20 -0
- package/docs/examples/storage/delete-file.md +1 -1
- package/docs/examples/storage/get-bucket.md +20 -0
- 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 +20 -0
- package/docs/examples/storage/list-files.md +1 -1
- package/docs/examples/storage/update-bucket.md +20 -0
- package/docs/examples/storage/update-file.md +1 -1
- package/index.d.ts +412 -152
- package/lib/client.js +7 -5
- package/lib/exception.js +2 -1
- package/lib/query.js +2 -0
- package/lib/services/account.js +28 -3
- package/lib/services/avatars.js +3 -0
- package/lib/services/database.js +6 -3
- package/lib/services/functions.js +212 -117
- package/lib/services/health.js +3 -0
- package/lib/services/locale.js +3 -0
- package/lib/services/storage.js +390 -33
- package/lib/services/teams.js +7 -0
- package/lib/services/users.js +6 -2
- package/package.json +2 -2
package/lib/client.js
CHANGED
|
@@ -4,13 +4,14 @@ const FormData = require('form-data');
|
|
|
4
4
|
const AppwriteException = require('./exception.js');
|
|
5
5
|
|
|
6
6
|
class Client {
|
|
7
|
+
static CHUNK_SIZE = 5*1024*1024; // 5MB
|
|
7
8
|
|
|
8
9
|
constructor() {
|
|
9
10
|
this.endpoint = 'https://HOSTNAME/v1';
|
|
10
11
|
this.headers = {
|
|
11
12
|
'content-type': '',
|
|
12
|
-
'x-sdk-version': 'appwrite:nodejs:
|
|
13
|
-
'X-Appwrite-Response-Format' : '0.
|
|
13
|
+
'x-sdk-version': 'appwrite:nodejs:5.1.0',
|
|
14
|
+
'X-Appwrite-Response-Format' : '0.13.0',
|
|
14
15
|
};
|
|
15
16
|
this.selfSigned = false;
|
|
16
17
|
}
|
|
@@ -115,7 +116,8 @@ class Client {
|
|
|
115
116
|
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
|
|
119
|
+
|
|
120
|
+
headers = Object.assign({}, this.headers, headers);
|
|
119
121
|
|
|
120
122
|
let contentType = headers['content-type'].toLowerCase();
|
|
121
123
|
|
|
@@ -155,9 +157,9 @@ class Client {
|
|
|
155
157
|
if('response' in error && error.response !== undefined) {
|
|
156
158
|
if(error.response && 'data' in error.response) {
|
|
157
159
|
if (typeof(error.response.data) === 'string') {
|
|
158
|
-
throw new AppwriteException(error.response.data, error.response.status, error.response.data);
|
|
160
|
+
throw new AppwriteException(error.response.data, error.response.status, '', error.response.data);
|
|
159
161
|
} else {
|
|
160
|
-
throw new AppwriteException(error.response.data.message, error.response.status, error.response.data);
|
|
162
|
+
throw new AppwriteException(error.response.data.message, error.response.status, error.response.data.type, error.response.data);
|
|
161
163
|
}
|
|
162
164
|
} else {
|
|
163
165
|
throw new AppwriteException(error.response.statusText, error.response.status, error.response.data);
|
package/lib/exception.js
CHANGED
package/lib/query.js
CHANGED
package/lib/services/account.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const Service = require('../service.js');
|
|
2
2
|
const AppwriteException = require('../exception.js');
|
|
3
|
+
const client = require('../client.js');
|
|
4
|
+
const { promisify } = require('util');
|
|
5
|
+
const fs = require('fs');
|
|
3
6
|
|
|
4
7
|
class Account extends Service {
|
|
5
8
|
|
|
@@ -190,8 +193,9 @@ class Account extends Service {
|
|
|
190
193
|
/**
|
|
191
194
|
* Update Account Preferences
|
|
192
195
|
*
|
|
193
|
-
* Update currently logged in user account preferences.
|
|
194
|
-
*
|
|
196
|
+
* Update currently logged in user account preferences. The object you pass is
|
|
197
|
+
* stored as is, and replaces any previous value. The maximum allowed prefs
|
|
198
|
+
* size is 64kB and throws error if exceeded.
|
|
195
199
|
*
|
|
196
200
|
* @param {object} prefs
|
|
197
201
|
* @throws {AppwriteException}
|
|
@@ -376,12 +380,33 @@ class Account extends Service {
|
|
|
376
380
|
}, payload);
|
|
377
381
|
}
|
|
378
382
|
|
|
383
|
+
/**
|
|
384
|
+
* Update Session (Refresh Tokens)
|
|
385
|
+
*
|
|
386
|
+
* @param {string} sessionId
|
|
387
|
+
* @throws {AppwriteException}
|
|
388
|
+
* @returns {Promise}
|
|
389
|
+
*/
|
|
390
|
+
async updateSession(sessionId) {
|
|
391
|
+
if (typeof sessionId === 'undefined') {
|
|
392
|
+
throw new AppwriteException('Missing required parameter: "sessionId"');
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
|
|
396
|
+
let payload = {};
|
|
397
|
+
|
|
398
|
+
return await this.client.call('patch', path, {
|
|
399
|
+
'content-type': 'application/json',
|
|
400
|
+
}, payload);
|
|
401
|
+
}
|
|
402
|
+
|
|
379
403
|
/**
|
|
380
404
|
* Delete Account Session
|
|
381
405
|
*
|
|
382
406
|
* Use this endpoint to log out the currently logged in user from all their
|
|
383
407
|
* account sessions across all of their different devices. When using the
|
|
384
|
-
*
|
|
408
|
+
* Session ID argument, only the unique session ID provided is deleted.
|
|
409
|
+
*
|
|
385
410
|
*
|
|
386
411
|
* @param {string} sessionId
|
|
387
412
|
* @throws {AppwriteException}
|
package/lib/services/avatars.js
CHANGED
package/lib/services/database.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const Service = require('../service.js');
|
|
2
2
|
const AppwriteException = require('../exception.js');
|
|
3
|
+
const client = require('../client.js');
|
|
4
|
+
const { promisify } = require('util');
|
|
5
|
+
const fs = require('fs');
|
|
3
6
|
|
|
4
7
|
class Database extends Service {
|
|
5
8
|
|
|
@@ -405,9 +408,9 @@ class Database extends Service {
|
|
|
405
408
|
* @param {string} collectionId
|
|
406
409
|
* @param {string} key
|
|
407
410
|
* @param {boolean} required
|
|
408
|
-
* @param {
|
|
409
|
-
* @param {
|
|
410
|
-
* @param {
|
|
411
|
+
* @param {number} min
|
|
412
|
+
* @param {number} max
|
|
413
|
+
* @param {number} xdefault
|
|
411
414
|
* @param {boolean} array
|
|
412
415
|
* @throws {AppwriteException}
|
|
413
416
|
* @returns {Promise}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const Service = require('../service.js');
|
|
2
2
|
const AppwriteException = require('../exception.js');
|
|
3
|
+
const client = require('../client.js');
|
|
4
|
+
const { promisify } = require('util');
|
|
5
|
+
const fs = require('fs');
|
|
3
6
|
|
|
4
7
|
class Functions extends Service {
|
|
5
8
|
|
|
@@ -129,7 +132,7 @@ class Functions extends Service {
|
|
|
129
132
|
/**
|
|
130
133
|
* List the currently active function runtimes.
|
|
131
134
|
*
|
|
132
|
-
* Get a list of all runtimes that are currently active
|
|
135
|
+
* Get a list of all runtimes that are currently active on your instance.
|
|
133
136
|
*
|
|
134
137
|
* @throws {AppwriteException}
|
|
135
138
|
* @returns {Promise}
|
|
@@ -248,30 +251,33 @@ class Functions extends Service {
|
|
|
248
251
|
}
|
|
249
252
|
|
|
250
253
|
/**
|
|
251
|
-
* List
|
|
254
|
+
* List Deployments
|
|
252
255
|
*
|
|
253
|
-
* Get a list of all the
|
|
254
|
-
*
|
|
255
|
-
* return a list of all of the project's executions. [Learn more about
|
|
256
|
-
* different API modes](/docs/admin).
|
|
256
|
+
* Get a list of all the project's code deployments. You can use the query
|
|
257
|
+
* params to filter your results.
|
|
257
258
|
*
|
|
258
259
|
* @param {string} functionId
|
|
260
|
+
* @param {string} search
|
|
259
261
|
* @param {number} limit
|
|
260
262
|
* @param {number} offset
|
|
261
|
-
* @param {string} search
|
|
262
263
|
* @param {string} cursor
|
|
263
264
|
* @param {string} cursorDirection
|
|
265
|
+
* @param {string} orderType
|
|
264
266
|
* @throws {AppwriteException}
|
|
265
267
|
* @returns {Promise}
|
|
266
268
|
*/
|
|
267
|
-
async
|
|
269
|
+
async listDeployments(functionId, search, limit, offset, cursor, cursorDirection, orderType) {
|
|
268
270
|
if (typeof functionId === 'undefined') {
|
|
269
271
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
270
272
|
}
|
|
271
273
|
|
|
272
|
-
let path = '/functions/{functionId}/
|
|
274
|
+
let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
|
|
273
275
|
let payload = {};
|
|
274
276
|
|
|
277
|
+
if (typeof search !== 'undefined') {
|
|
278
|
+
payload['search'] = search;
|
|
279
|
+
}
|
|
280
|
+
|
|
275
281
|
if (typeof limit !== 'undefined') {
|
|
276
282
|
payload['limit'] = limit;
|
|
277
283
|
}
|
|
@@ -280,10 +286,6 @@ class Functions extends Service {
|
|
|
280
286
|
payload['offset'] = offset;
|
|
281
287
|
}
|
|
282
288
|
|
|
283
|
-
if (typeof search !== 'undefined') {
|
|
284
|
-
payload['search'] = search;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
289
|
if (typeof cursor !== 'undefined') {
|
|
288
290
|
payload['cursor'] = cursor;
|
|
289
291
|
}
|
|
@@ -292,61 +294,145 @@ class Functions extends Service {
|
|
|
292
294
|
payload['cursorDirection'] = cursorDirection;
|
|
293
295
|
}
|
|
294
296
|
|
|
297
|
+
if (typeof orderType !== 'undefined') {
|
|
298
|
+
payload['orderType'] = orderType;
|
|
299
|
+
}
|
|
300
|
+
|
|
295
301
|
return await this.client.call('get', path, {
|
|
296
302
|
'content-type': 'application/json',
|
|
297
303
|
}, payload);
|
|
298
304
|
}
|
|
299
305
|
|
|
300
306
|
/**
|
|
301
|
-
* Create
|
|
307
|
+
* Create Deployment
|
|
302
308
|
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
309
|
+
* Create a new function code deployment. Use this endpoint to upload a new
|
|
310
|
+
* version of your code function. To execute your newly uploaded code, you'll
|
|
311
|
+
* need to update the function's deployment to use your new deployment UID.
|
|
312
|
+
*
|
|
313
|
+
* This endpoint accepts a tar.gz file compressed with your code. Make sure to
|
|
314
|
+
* include any dependencies your code has within the compressed file. You can
|
|
315
|
+
* learn more about code packaging in the [Appwrite Cloud Functions
|
|
316
|
+
* tutorial](/docs/functions).
|
|
317
|
+
*
|
|
318
|
+
* Use the "command" param to set the entry point used to execute your code.
|
|
307
319
|
*
|
|
308
320
|
* @param {string} functionId
|
|
309
|
-
* @param {string}
|
|
321
|
+
* @param {string} entrypoint
|
|
322
|
+
* @param {string} code
|
|
323
|
+
* @param {boolean} activate
|
|
310
324
|
* @throws {AppwriteException}
|
|
311
325
|
* @returns {Promise}
|
|
312
326
|
*/
|
|
313
|
-
async
|
|
327
|
+
async createDeployment(functionId, entrypoint, code, activate, onProgress = () => {}) {
|
|
314
328
|
if (typeof functionId === 'undefined') {
|
|
315
329
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
316
330
|
}
|
|
317
331
|
|
|
318
|
-
|
|
332
|
+
if (typeof entrypoint === 'undefined') {
|
|
333
|
+
throw new AppwriteException('Missing required parameter: "entrypoint"');
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (typeof code === 'undefined') {
|
|
337
|
+
throw new AppwriteException('Missing required parameter: "code"');
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (typeof activate === 'undefined') {
|
|
341
|
+
throw new AppwriteException('Missing required parameter: "activate"');
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
|
|
319
345
|
let payload = {};
|
|
320
346
|
|
|
321
|
-
if (typeof
|
|
322
|
-
payload['
|
|
347
|
+
if (typeof entrypoint !== 'undefined') {
|
|
348
|
+
payload['entrypoint'] = entrypoint;
|
|
323
349
|
}
|
|
324
350
|
|
|
325
|
-
|
|
326
|
-
'
|
|
327
|
-
}
|
|
351
|
+
if (typeof code !== 'undefined') {
|
|
352
|
+
payload['code'] = code.toString();
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (typeof activate !== 'undefined') {
|
|
356
|
+
payload['activate'] = activate.toString();
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const { size: size } = await promisify(fs.stat)(code);
|
|
360
|
+
|
|
361
|
+
if (size <= client.CHUNK_SIZE) {
|
|
362
|
+
payload['code'] = fs.createReadStream(code);
|
|
363
|
+
|
|
364
|
+
return await this.client.call('post', path, {
|
|
365
|
+
'content-type': 'multipart/form-data',
|
|
366
|
+
}, payload);
|
|
367
|
+
} else {
|
|
368
|
+
let id = undefined;
|
|
369
|
+
let response = undefined;
|
|
370
|
+
|
|
371
|
+
let counter = 0;
|
|
372
|
+
const totalCounters = Math.ceil(size / client.CHUNK_SIZE);
|
|
373
|
+
|
|
374
|
+
const headers = {
|
|
375
|
+
'content-type': 'multipart/form-data',
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
for (counter; counter < totalCounters; counter++) {
|
|
380
|
+
const start = (counter * client.CHUNK_SIZE);
|
|
381
|
+
const end = Math.min((((counter * client.CHUNK_SIZE) + client.CHUNK_SIZE) - 1), size);
|
|
382
|
+
|
|
383
|
+
headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
|
|
384
|
+
|
|
385
|
+
if (id) {
|
|
386
|
+
headers['x-appwrite-id'] = id;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const stream = fs.createReadStream(code, {
|
|
390
|
+
start,
|
|
391
|
+
end
|
|
392
|
+
});
|
|
393
|
+
payload['code'] = stream;
|
|
394
|
+
|
|
395
|
+
response = await this.client.call('post', path, headers, payload);
|
|
396
|
+
|
|
397
|
+
if (!id) {
|
|
398
|
+
id = response['$id'];
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
if (onProgress !== null) {
|
|
402
|
+
onProgress({
|
|
403
|
+
$id: response['$id'],
|
|
404
|
+
progress: Math.min((counter+1) * client.CHUNK_SIZE, size) / size * 100,
|
|
405
|
+
sizeUploaded: end+1,
|
|
406
|
+
chunksTotal: response['chunksTotal'],
|
|
407
|
+
chunksUploaded: response['chunksUploaded']
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
return response;
|
|
413
|
+
}
|
|
328
414
|
}
|
|
329
415
|
|
|
330
416
|
/**
|
|
331
|
-
* Get
|
|
417
|
+
* Get Deployment
|
|
332
418
|
*
|
|
333
|
-
* Get a
|
|
419
|
+
* Get a code deployment by its unique ID.
|
|
334
420
|
*
|
|
335
421
|
* @param {string} functionId
|
|
336
|
-
* @param {string}
|
|
422
|
+
* @param {string} deploymentId
|
|
337
423
|
* @throws {AppwriteException}
|
|
338
424
|
* @returns {Promise}
|
|
339
425
|
*/
|
|
340
|
-
async
|
|
426
|
+
async getDeployment(functionId, deploymentId) {
|
|
341
427
|
if (typeof functionId === 'undefined') {
|
|
342
428
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
343
429
|
}
|
|
344
430
|
|
|
345
|
-
if (typeof
|
|
346
|
-
throw new AppwriteException('Missing required parameter: "
|
|
431
|
+
if (typeof deploymentId === 'undefined') {
|
|
432
|
+
throw new AppwriteException('Missing required parameter: "deploymentId"');
|
|
347
433
|
}
|
|
348
434
|
|
|
349
|
-
let path = '/functions/{functionId}/
|
|
435
|
+
let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
|
|
350
436
|
let payload = {};
|
|
351
437
|
|
|
352
438
|
return await this.client.call('get', path, {
|
|
@@ -355,190 +441,199 @@ class Functions extends Service {
|
|
|
355
441
|
}
|
|
356
442
|
|
|
357
443
|
/**
|
|
358
|
-
* Update Function
|
|
444
|
+
* Update Function Deployment
|
|
359
445
|
*
|
|
360
|
-
* Update the function code
|
|
361
|
-
* endpoint to switch the code
|
|
362
|
-
* endpoint.
|
|
446
|
+
* Update the function code deployment ID using the unique function ID. Use
|
|
447
|
+
* this endpoint to switch the code deployment that should be executed by the
|
|
448
|
+
* execution endpoint.
|
|
363
449
|
*
|
|
364
450
|
* @param {string} functionId
|
|
365
|
-
* @param {string}
|
|
451
|
+
* @param {string} deploymentId
|
|
366
452
|
* @throws {AppwriteException}
|
|
367
453
|
* @returns {Promise}
|
|
368
454
|
*/
|
|
369
|
-
async
|
|
455
|
+
async updateDeployment(functionId, deploymentId) {
|
|
370
456
|
if (typeof functionId === 'undefined') {
|
|
371
457
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
372
458
|
}
|
|
373
459
|
|
|
374
|
-
if (typeof
|
|
375
|
-
throw new AppwriteException('Missing required parameter: "
|
|
460
|
+
if (typeof deploymentId === 'undefined') {
|
|
461
|
+
throw new AppwriteException('Missing required parameter: "deploymentId"');
|
|
376
462
|
}
|
|
377
463
|
|
|
378
|
-
let path = '/functions/{functionId}/
|
|
464
|
+
let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
|
|
379
465
|
let payload = {};
|
|
380
466
|
|
|
381
|
-
if (typeof tag !== 'undefined') {
|
|
382
|
-
payload['tag'] = tag;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
467
|
return await this.client.call('patch', path, {
|
|
386
468
|
'content-type': 'application/json',
|
|
387
469
|
}, payload);
|
|
388
470
|
}
|
|
389
471
|
|
|
390
472
|
/**
|
|
391
|
-
*
|
|
473
|
+
* Delete Deployment
|
|
392
474
|
*
|
|
393
|
-
*
|
|
394
|
-
* filter your results.
|
|
475
|
+
* Delete a code deployment by its unique ID.
|
|
395
476
|
*
|
|
396
477
|
* @param {string} functionId
|
|
397
|
-
* @param {string}
|
|
398
|
-
* @param {number} limit
|
|
399
|
-
* @param {number} offset
|
|
400
|
-
* @param {string} cursor
|
|
401
|
-
* @param {string} cursorDirection
|
|
402
|
-
* @param {string} orderType
|
|
478
|
+
* @param {string} deploymentId
|
|
403
479
|
* @throws {AppwriteException}
|
|
404
480
|
* @returns {Promise}
|
|
405
481
|
*/
|
|
406
|
-
async
|
|
482
|
+
async deleteDeployment(functionId, deploymentId) {
|
|
407
483
|
if (typeof functionId === 'undefined') {
|
|
408
484
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
409
485
|
}
|
|
410
486
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
if (typeof search !== 'undefined') {
|
|
415
|
-
payload['search'] = search;
|
|
487
|
+
if (typeof deploymentId === 'undefined') {
|
|
488
|
+
throw new AppwriteException('Missing required parameter: "deploymentId"');
|
|
416
489
|
}
|
|
417
490
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
491
|
+
let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
|
|
492
|
+
let payload = {};
|
|
421
493
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
}
|
|
494
|
+
return await this.client.call('delete', path, {
|
|
495
|
+
'content-type': 'application/json',
|
|
496
|
+
}, payload);
|
|
497
|
+
}
|
|
425
498
|
|
|
426
|
-
|
|
427
|
-
|
|
499
|
+
/**
|
|
500
|
+
* Retry Build
|
|
501
|
+
*
|
|
502
|
+
* @param {string} functionId
|
|
503
|
+
* @param {string} deploymentId
|
|
504
|
+
* @param {string} buildId
|
|
505
|
+
* @throws {AppwriteException}
|
|
506
|
+
* @returns {Promise}
|
|
507
|
+
*/
|
|
508
|
+
async retryBuild(functionId, deploymentId, buildId) {
|
|
509
|
+
if (typeof functionId === 'undefined') {
|
|
510
|
+
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
428
511
|
}
|
|
429
512
|
|
|
430
|
-
if (typeof
|
|
431
|
-
|
|
513
|
+
if (typeof deploymentId === 'undefined') {
|
|
514
|
+
throw new AppwriteException('Missing required parameter: "deploymentId"');
|
|
432
515
|
}
|
|
433
516
|
|
|
434
|
-
if (typeof
|
|
435
|
-
|
|
517
|
+
if (typeof buildId === 'undefined') {
|
|
518
|
+
throw new AppwriteException('Missing required parameter: "buildId"');
|
|
436
519
|
}
|
|
437
520
|
|
|
438
|
-
|
|
521
|
+
let path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId).replace('{buildId}', buildId);
|
|
522
|
+
let payload = {};
|
|
523
|
+
|
|
524
|
+
return await this.client.call('post', path, {
|
|
439
525
|
'content-type': 'application/json',
|
|
440
526
|
}, payload);
|
|
441
527
|
}
|
|
442
528
|
|
|
443
529
|
/**
|
|
444
|
-
*
|
|
530
|
+
* List Executions
|
|
445
531
|
*
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
* This endpoint accepts a tar.gz file compressed with your code. Make sure to
|
|
451
|
-
* include any dependencies your code has within the compressed file. You can
|
|
452
|
-
* learn more about code packaging in the [Appwrite Cloud Functions
|
|
453
|
-
* tutorial](/docs/functions).
|
|
454
|
-
*
|
|
455
|
-
* Use the "command" param to set the entry point used to execute your code.
|
|
532
|
+
* Get a list of all the current user function execution logs. You can use the
|
|
533
|
+
* query params to filter your results. On admin mode, this endpoint will
|
|
534
|
+
* return a list of all of the project's executions. [Learn more about
|
|
535
|
+
* different API modes](/docs/admin).
|
|
456
536
|
*
|
|
457
537
|
* @param {string} functionId
|
|
458
|
-
* @param {
|
|
459
|
-
* @param {
|
|
538
|
+
* @param {number} limit
|
|
539
|
+
* @param {number} offset
|
|
540
|
+
* @param {string} search
|
|
541
|
+
* @param {string} cursor
|
|
542
|
+
* @param {string} cursorDirection
|
|
460
543
|
* @throws {AppwriteException}
|
|
461
544
|
* @returns {Promise}
|
|
462
545
|
*/
|
|
463
|
-
async
|
|
546
|
+
async listExecutions(functionId, limit, offset, search, cursor, cursorDirection) {
|
|
464
547
|
if (typeof functionId === 'undefined') {
|
|
465
548
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
466
549
|
}
|
|
467
550
|
|
|
468
|
-
|
|
469
|
-
|
|
551
|
+
let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
|
|
552
|
+
let payload = {};
|
|
553
|
+
|
|
554
|
+
if (typeof limit !== 'undefined') {
|
|
555
|
+
payload['limit'] = limit;
|
|
470
556
|
}
|
|
471
557
|
|
|
472
|
-
if (typeof
|
|
473
|
-
|
|
558
|
+
if (typeof offset !== 'undefined') {
|
|
559
|
+
payload['offset'] = offset;
|
|
474
560
|
}
|
|
475
561
|
|
|
476
|
-
|
|
477
|
-
|
|
562
|
+
if (typeof search !== 'undefined') {
|
|
563
|
+
payload['search'] = search;
|
|
564
|
+
}
|
|
478
565
|
|
|
479
|
-
if (typeof
|
|
480
|
-
payload['
|
|
566
|
+
if (typeof cursor !== 'undefined') {
|
|
567
|
+
payload['cursor'] = cursor;
|
|
481
568
|
}
|
|
482
569
|
|
|
483
|
-
if (typeof
|
|
484
|
-
payload['
|
|
570
|
+
if (typeof cursorDirection !== 'undefined') {
|
|
571
|
+
payload['cursorDirection'] = cursorDirection;
|
|
485
572
|
}
|
|
486
573
|
|
|
487
|
-
return await this.client.call('
|
|
488
|
-
'content-type': '
|
|
574
|
+
return await this.client.call('get', path, {
|
|
575
|
+
'content-type': 'application/json',
|
|
489
576
|
}, payload);
|
|
490
577
|
}
|
|
491
578
|
|
|
492
579
|
/**
|
|
493
|
-
*
|
|
580
|
+
* Create Execution
|
|
494
581
|
*
|
|
495
|
-
*
|
|
582
|
+
* Trigger a function execution. The returned object will return you the
|
|
583
|
+
* current execution status. You can ping the `Get Execution` endpoint to get
|
|
584
|
+
* updates on the current execution status. Once this endpoint is called, your
|
|
585
|
+
* function execution process will start asynchronously.
|
|
496
586
|
*
|
|
497
587
|
* @param {string} functionId
|
|
498
|
-
* @param {string}
|
|
588
|
+
* @param {string} data
|
|
589
|
+
* @param {boolean} async
|
|
499
590
|
* @throws {AppwriteException}
|
|
500
591
|
* @returns {Promise}
|
|
501
592
|
*/
|
|
502
|
-
async
|
|
593
|
+
async createExecution(functionId, data, async) {
|
|
503
594
|
if (typeof functionId === 'undefined') {
|
|
504
595
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
505
596
|
}
|
|
506
597
|
|
|
507
|
-
|
|
508
|
-
|
|
598
|
+
let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
|
|
599
|
+
let payload = {};
|
|
600
|
+
|
|
601
|
+
if (typeof data !== 'undefined') {
|
|
602
|
+
payload['data'] = data;
|
|
509
603
|
}
|
|
510
604
|
|
|
511
|
-
|
|
512
|
-
|
|
605
|
+
if (typeof async !== 'undefined') {
|
|
606
|
+
payload['async'] = async;
|
|
607
|
+
}
|
|
513
608
|
|
|
514
|
-
return await this.client.call('
|
|
609
|
+
return await this.client.call('post', path, {
|
|
515
610
|
'content-type': 'application/json',
|
|
516
611
|
}, payload);
|
|
517
612
|
}
|
|
518
613
|
|
|
519
614
|
/**
|
|
520
|
-
*
|
|
615
|
+
* Get Execution
|
|
521
616
|
*
|
|
522
|
-
*
|
|
617
|
+
* Get a function execution log by its unique ID.
|
|
523
618
|
*
|
|
524
619
|
* @param {string} functionId
|
|
525
|
-
* @param {string}
|
|
620
|
+
* @param {string} executionId
|
|
526
621
|
* @throws {AppwriteException}
|
|
527
622
|
* @returns {Promise}
|
|
528
623
|
*/
|
|
529
|
-
async
|
|
624
|
+
async getExecution(functionId, executionId) {
|
|
530
625
|
if (typeof functionId === 'undefined') {
|
|
531
626
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
532
627
|
}
|
|
533
628
|
|
|
534
|
-
if (typeof
|
|
535
|
-
throw new AppwriteException('Missing required parameter: "
|
|
629
|
+
if (typeof executionId === 'undefined') {
|
|
630
|
+
throw new AppwriteException('Missing required parameter: "executionId"');
|
|
536
631
|
}
|
|
537
632
|
|
|
538
|
-
let path = '/functions/{functionId}/
|
|
633
|
+
let path = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
|
|
539
634
|
let payload = {};
|
|
540
635
|
|
|
541
|
-
return await this.client.call('
|
|
636
|
+
return await this.client.call('get', path, {
|
|
542
637
|
'content-type': 'application/json',
|
|
543
638
|
}, payload);
|
|
544
639
|
}
|