node-appwrite 11.0.0 → 12.0.0-rc.4
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/LICENSE +1 -1
- package/README.md +2 -2
- package/docs/examples/account/add-authenticator.md +12 -0
- package/docs/examples/account/create-anonymous-session.md +9 -0
- package/docs/examples/account/create-email-password-session.md +12 -0
- package/docs/examples/account/create-email-token.md +13 -0
- package/docs/examples/account/create-j-w-t.md +9 -0
- package/docs/examples/account/create-magic-u-r-l-token.md +14 -0
- package/docs/examples/account/create-o-auth2session.md +15 -0
- package/docs/examples/account/create-phone-token.md +12 -0
- package/docs/examples/account/create-phone-verification.md +4 -14
- package/docs/examples/account/create-recovery.md +7 -14
- package/docs/examples/account/create-session.md +12 -0
- package/docs/examples/account/create-verification.md +6 -14
- package/docs/examples/account/create.md +14 -0
- package/docs/examples/account/create2f-a-challenge.md +11 -0
- package/docs/examples/account/delete-authenticator.md +13 -0
- package/docs/examples/account/delete-identity.md +6 -14
- package/docs/examples/account/delete-session.md +6 -14
- package/docs/examples/account/delete-sessions.md +4 -14
- package/docs/examples/account/get-prefs.md +4 -14
- package/docs/examples/account/get-session.md +6 -14
- package/docs/examples/account/get.md +4 -14
- package/docs/examples/account/list-factors.md +10 -0
- package/docs/examples/account/list-identities.md +6 -14
- package/docs/examples/account/list-logs.md +6 -14
- package/docs/examples/account/list-sessions.md +4 -14
- package/docs/examples/account/update-challenge.md +13 -0
- package/docs/examples/account/update-email.md +7 -14
- package/docs/examples/account/update-m-f-a.md +12 -0
- package/docs/examples/account/update-magic-u-r-l-session.md +12 -0
- package/docs/examples/account/update-name.md +6 -14
- package/docs/examples/account/update-password.md +7 -14
- package/docs/examples/account/update-phone-verification.md +7 -14
- package/docs/examples/account/update-phone.md +7 -14
- package/docs/examples/account/update-prefs.md +6 -14
- package/docs/examples/account/update-recovery.md +8 -14
- package/docs/examples/account/update-session.md +6 -14
- package/docs/examples/account/update-status.md +4 -14
- package/docs/examples/account/update-verification.md +7 -14
- package/docs/examples/account/verify-authenticator.md +13 -0
- package/docs/examples/avatars/get-browser.md +9 -14
- package/docs/examples/avatars/get-credit-card.md +9 -14
- package/docs/examples/avatars/get-favicon.md +6 -14
- package/docs/examples/avatars/get-flag.md +9 -14
- package/docs/examples/avatars/get-image.md +8 -14
- package/docs/examples/avatars/get-initials.md +9 -14
- package/docs/examples/avatars/get-q-r.md +9 -14
- package/docs/examples/databases/create-boolean-attribute.md +11 -14
- package/docs/examples/databases/create-collection.md +11 -14
- package/docs/examples/databases/create-datetime-attribute.md +11 -14
- package/docs/examples/databases/create-document.md +10 -14
- package/docs/examples/databases/create-email-attribute.md +11 -14
- package/docs/examples/databases/create-enum-attribute.md +12 -14
- package/docs/examples/databases/create-float-attribute.md +13 -14
- package/docs/examples/databases/create-index.md +11 -14
- package/docs/examples/databases/create-integer-attribute.md +13 -14
- package/docs/examples/databases/create-ip-attribute.md +11 -14
- package/docs/examples/databases/create-relationship-attribute.md +13 -14
- package/docs/examples/databases/create-string-attribute.md +13 -14
- package/docs/examples/databases/create-url-attribute.md +11 -14
- package/docs/examples/databases/create.md +8 -14
- package/docs/examples/databases/delete-attribute.md +8 -14
- package/docs/examples/databases/delete-collection.md +7 -14
- package/docs/examples/databases/delete-document.md +8 -14
- package/docs/examples/databases/delete-index.md +8 -14
- package/docs/examples/databases/delete.md +6 -14
- package/docs/examples/databases/get-attribute.md +8 -14
- package/docs/examples/databases/get-collection.md +7 -14
- package/docs/examples/databases/get-document.md +9 -14
- package/docs/examples/databases/get-index.md +8 -14
- package/docs/examples/databases/get.md +6 -14
- package/docs/examples/databases/list-attributes.md +8 -14
- package/docs/examples/databases/list-collections.md +8 -14
- package/docs/examples/databases/list-documents.md +8 -14
- package/docs/examples/databases/list-indexes.md +8 -14
- package/docs/examples/databases/list.md +7 -14
- package/docs/examples/databases/update-boolean-attribute.md +10 -14
- package/docs/examples/databases/update-collection.md +11 -14
- package/docs/examples/databases/update-datetime-attribute.md +10 -14
- package/docs/examples/databases/update-document.md +10 -14
- package/docs/examples/databases/update-email-attribute.md +10 -14
- package/docs/examples/databases/update-enum-attribute.md +11 -14
- package/docs/examples/databases/update-float-attribute.md +12 -14
- package/docs/examples/databases/update-integer-attribute.md +12 -14
- package/docs/examples/databases/update-ip-attribute.md +10 -14
- package/docs/examples/databases/update-relationship-attribute.md +9 -14
- package/docs/examples/databases/update-string-attribute.md +10 -14
- package/docs/examples/databases/update-url-attribute.md +10 -14
- package/docs/examples/databases/update.md +8 -14
- package/docs/examples/functions/create-build.md +8 -14
- package/docs/examples/functions/create-deployment.md +10 -14
- package/docs/examples/functions/create-execution.md +11 -14
- package/docs/examples/functions/create-variable.md +8 -14
- package/docs/examples/functions/create.md +25 -14
- package/docs/examples/functions/delete-deployment.md +7 -14
- package/docs/examples/functions/delete-variable.md +7 -14
- package/docs/examples/functions/delete.md +6 -14
- package/docs/examples/functions/download-deployment.md +7 -14
- package/docs/examples/functions/get-deployment.md +7 -14
- package/docs/examples/functions/get-execution.md +7 -14
- package/docs/examples/functions/get-variable.md +7 -14
- package/docs/examples/functions/get.md +6 -14
- package/docs/examples/functions/list-deployments.md +8 -14
- package/docs/examples/functions/list-executions.md +8 -14
- package/docs/examples/functions/list-runtimes.md +4 -14
- package/docs/examples/functions/list-variables.md +6 -14
- package/docs/examples/functions/list.md +7 -14
- package/docs/examples/functions/update-deployment.md +7 -14
- package/docs/examples/functions/update-variable.md +9 -14
- package/docs/examples/functions/update.md +21 -14
- package/docs/examples/graphql/mutation.md +6 -14
- package/docs/examples/graphql/query.md +6 -14
- package/docs/examples/health/get-antivirus.md +4 -14
- package/docs/examples/health/get-cache.md +4 -14
- package/docs/examples/health/get-certificate.md +12 -0
- package/docs/examples/health/get-d-b.md +4 -14
- package/docs/examples/health/get-failed-jobs.md +13 -0
- package/docs/examples/health/get-pub-sub.md +4 -14
- package/docs/examples/health/get-queue-builds.md +12 -0
- package/docs/examples/health/get-queue-certificates.md +6 -14
- package/docs/examples/health/get-queue-databases.md +13 -0
- package/docs/examples/health/get-queue-deletes.md +12 -0
- package/docs/examples/health/get-queue-functions.md +6 -14
- package/docs/examples/health/get-queue-logs.md +6 -14
- package/docs/examples/health/get-queue-mails.md +12 -0
- package/docs/examples/health/get-queue-messaging.md +12 -0
- package/docs/examples/health/get-queue-migrations.md +12 -0
- package/docs/examples/health/get-queue-webhooks.md +6 -14
- package/docs/examples/health/get-queue.md +4 -14
- package/docs/examples/health/get-storage-local.md +4 -14
- package/docs/examples/health/get-time.md +4 -14
- package/docs/examples/health/get.md +4 -14
- package/docs/examples/locale/get.md +4 -14
- package/docs/examples/locale/list-codes.md +4 -14
- package/docs/examples/locale/list-continents.md +4 -14
- package/docs/examples/locale/list-countries-e-u.md +4 -14
- package/docs/examples/locale/list-countries-phones.md +4 -14
- package/docs/examples/locale/list-countries.md +4 -14
- package/docs/examples/locale/list-currencies.md +4 -14
- package/docs/examples/locale/list-languages.md +4 -14
- package/docs/examples/messaging/create-apns-provider.md +18 -0
- package/docs/examples/messaging/create-email.md +23 -0
- package/docs/examples/messaging/create-fcm-provider.md +15 -0
- package/docs/examples/messaging/create-mailgun-provider.md +21 -0
- package/docs/examples/messaging/create-msg91provider.md +17 -0
- package/docs/examples/messaging/create-push.md +27 -0
- package/docs/examples/messaging/create-sendgrid-provider.md +19 -0
- package/docs/examples/messaging/create-sms.md +18 -0
- package/docs/examples/messaging/create-smtp-provider.md +25 -0
- package/docs/examples/messaging/create-subscriber.md +14 -0
- package/docs/examples/messaging/create-telesign-provider.md +17 -0
- package/docs/examples/messaging/create-textmagic-provider.md +17 -0
- package/docs/examples/messaging/create-topic.md +14 -0
- package/docs/examples/messaging/create-twilio-provider.md +17 -0
- package/docs/examples/messaging/create-vonage-provider.md +17 -0
- package/docs/examples/messaging/delete-provider.md +12 -0
- package/docs/examples/messaging/delete-subscriber.md +13 -0
- package/docs/examples/messaging/delete-topic.md +12 -0
- package/docs/examples/messaging/delete.md +12 -0
- package/docs/examples/messaging/get-message.md +12 -0
- package/docs/examples/messaging/get-provider.md +12 -0
- package/docs/examples/messaging/get-subscriber.md +13 -0
- package/docs/examples/messaging/get-topic.md +12 -0
- package/docs/examples/messaging/list-message-logs.md +13 -0
- package/docs/examples/messaging/list-messages.md +13 -0
- package/docs/examples/messaging/list-provider-logs.md +13 -0
- package/docs/examples/messaging/list-providers.md +13 -0
- package/docs/examples/messaging/list-subscriber-logs.md +13 -0
- package/docs/examples/messaging/list-subscribers.md +14 -0
- package/docs/examples/messaging/list-targets.md +13 -0
- package/docs/examples/messaging/list-topic-logs.md +13 -0
- package/docs/examples/messaging/list-topics.md +13 -0
- package/docs/examples/messaging/update-a-p-n-s-provider.md +18 -0
- package/docs/examples/messaging/update-email.md +22 -0
- package/docs/examples/messaging/update-f-c-m-provider.md +15 -0
- package/docs/examples/messaging/update-mailgun-provider.md +21 -0
- package/docs/examples/messaging/update-msg91provider.md +17 -0
- package/docs/examples/messaging/update-push.md +27 -0
- package/docs/examples/messaging/update-sendgrid-provider.md +19 -0
- package/docs/examples/messaging/update-sms.md +18 -0
- package/docs/examples/messaging/update-smtp-provider.md +25 -0
- package/docs/examples/messaging/update-telesign-provider.md +17 -0
- package/docs/examples/messaging/update-textmagic-provider.md +17 -0
- package/docs/examples/messaging/update-topic.md +13 -0
- package/docs/examples/messaging/update-twilio-provider.md +17 -0
- package/docs/examples/messaging/update-vonage-provider.md +17 -0
- package/docs/examples/storage/create-bucket.md +15 -14
- package/docs/examples/storage/create-file.md +9 -14
- package/docs/examples/storage/delete-bucket.md +6 -14
- package/docs/examples/storage/delete-file.md +7 -14
- package/docs/examples/storage/get-bucket.md +6 -14
- package/docs/examples/storage/get-file-download.md +7 -14
- package/docs/examples/storage/get-file-preview.md +18 -14
- package/docs/examples/storage/get-file-view.md +7 -14
- package/docs/examples/storage/get-file.md +7 -14
- package/docs/examples/storage/list-buckets.md +7 -14
- package/docs/examples/storage/list-files.md +8 -14
- package/docs/examples/storage/update-bucket.md +15 -14
- package/docs/examples/storage/update-file.md +9 -14
- package/docs/examples/teams/create-membership.md +12 -14
- package/docs/examples/teams/create.md +8 -14
- package/docs/examples/teams/delete-membership.md +7 -14
- package/docs/examples/teams/delete.md +6 -14
- package/docs/examples/teams/get-membership.md +7 -14
- package/docs/examples/teams/get-prefs.md +6 -14
- package/docs/examples/teams/get.md +6 -14
- package/docs/examples/teams/list-memberships.md +8 -14
- package/docs/examples/teams/list.md +7 -14
- package/docs/examples/teams/update-membership-status.md +9 -14
- package/docs/examples/teams/update-membership.md +8 -14
- package/docs/examples/teams/update-name.md +7 -14
- package/docs/examples/teams/update-prefs.md +7 -14
- package/docs/examples/users/create-argon2user.md +9 -14
- package/docs/examples/users/create-bcrypt-user.md +9 -14
- package/docs/examples/users/create-m-d5user.md +9 -14
- package/docs/examples/users/create-p-h-pass-user.md +9 -14
- package/docs/examples/users/create-s-h-a-user.md +10 -14
- package/docs/examples/users/create-scrypt-modified-user.md +12 -14
- package/docs/examples/users/create-scrypt-user.md +14 -14
- package/docs/examples/users/create-session.md +12 -0
- package/docs/examples/users/create-target.md +17 -0
- package/docs/examples/users/create-token.md +14 -0
- package/docs/examples/users/create.md +10 -14
- package/docs/examples/users/delete-authenticator.md +14 -0
- package/docs/examples/users/delete-identity.md +6 -14
- package/docs/examples/users/delete-session.md +7 -14
- package/docs/examples/users/delete-sessions.md +6 -14
- package/docs/examples/users/delete-target.md +13 -0
- package/docs/examples/users/delete.md +6 -14
- package/docs/examples/users/get-prefs.md +6 -14
- package/docs/examples/users/get-target.md +13 -0
- package/docs/examples/users/get.md +6 -14
- package/docs/examples/users/list-factors.md +12 -0
- package/docs/examples/users/list-identities.md +7 -14
- package/docs/examples/users/list-logs.md +7 -14
- package/docs/examples/users/list-memberships.md +6 -14
- package/docs/examples/users/list-sessions.md +6 -14
- package/docs/examples/users/list-targets.md +13 -0
- package/docs/examples/users/list.md +7 -14
- package/docs/examples/users/update-email-verification.md +7 -14
- package/docs/examples/users/update-email.md +7 -14
- package/docs/examples/users/update-labels.md +7 -14
- package/docs/examples/users/update-mfa.md +13 -0
- package/docs/examples/users/update-name.md +7 -14
- package/docs/examples/users/update-password.md +7 -14
- package/docs/examples/users/update-phone-verification.md +7 -14
- package/docs/examples/users/update-phone.md +7 -14
- package/docs/examples/users/update-prefs.md +7 -14
- package/docs/examples/users/update-status.md +7 -14
- package/docs/examples/users/update-target.md +16 -0
- package/index.d.ts +2280 -309
- package/index.js +40 -0
- package/lib/client.js +122 -65
- package/lib/enums/authentication-factor.js +7 -0
- package/lib/enums/authenticator-type.js +5 -0
- package/lib/enums/browser.js +18 -0
- package/lib/enums/compression.js +7 -0
- package/lib/enums/credit-card.js +20 -0
- package/lib/enums/encryption.js +7 -0
- package/lib/enums/execution-method.js +10 -0
- package/lib/enums/flag.js +198 -0
- package/lib/enums/image-format.js +9 -0
- package/lib/enums/image-gravity.js +13 -0
- package/lib/enums/index-type.js +8 -0
- package/lib/enums/message-status.js +7 -0
- package/lib/enums/messaging-provider-type.js +7 -0
- package/lib/enums/name.js +16 -0
- package/lib/enums/o-auth-provider.js +43 -0
- package/lib/enums/password-hash.js +15 -0
- package/lib/enums/relation-mutate.js +7 -0
- package/lib/enums/relationship-type.js +8 -0
- package/lib/enums/runtime.js +40 -0
- package/lib/inputFile.js +88 -16
- package/lib/query.js +56 -38
- package/lib/services/account.js +639 -46
- package/lib/services/avatars.js +16 -13
- package/lib/services/databases.js +54 -52
- package/lib/services/functions.js +77 -109
- package/lib/services/graphql.js +4 -2
- package/lib/services/health.js +229 -14
- package/lib/services/locale.js +9 -7
- package/lib/services/messaging.js +2198 -0
- package/lib/services/storage.js +64 -100
- package/lib/services/teams.js +19 -17
- package/lib/services/users.js +367 -45
- package/package.json +2 -3
|
@@ -5,6 +5,8 @@ const client = require('../client.js');
|
|
|
5
5
|
const Stream = require('stream');
|
|
6
6
|
const { promisify } = require('util');
|
|
7
7
|
const fs = require('fs');
|
|
8
|
+
const { File } = require('undici');
|
|
9
|
+
const Query = require('../query.js');
|
|
8
10
|
|
|
9
11
|
class Functions extends Service {
|
|
10
12
|
|
|
@@ -15,7 +17,7 @@ class Functions extends Service {
|
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
|
-
* List
|
|
20
|
+
* List functions
|
|
19
21
|
*
|
|
20
22
|
* Get a list of all the project's functions. You can use the query params to
|
|
21
23
|
* filter your results.
|
|
@@ -43,15 +45,16 @@ class Functions extends Service {
|
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
/**
|
|
46
|
-
* Create
|
|
48
|
+
* Create function
|
|
47
49
|
*
|
|
48
50
|
* Create a new function. You can pass a list of
|
|
49
|
-
* [permissions](/docs/permissions) to allow different
|
|
50
|
-
* with access to execute the function using the client
|
|
51
|
+
* [permissions](https://appwrite.io/docs/permissions) to allow different
|
|
52
|
+
* project users or team with access to execute the function using the client
|
|
53
|
+
* API.
|
|
51
54
|
*
|
|
52
55
|
* @param {string} functionId
|
|
53
56
|
* @param {string} name
|
|
54
|
-
* @param {
|
|
57
|
+
* @param {Runtime} runtime
|
|
55
58
|
* @param {string[]} execute
|
|
56
59
|
* @param {string[]} events
|
|
57
60
|
* @param {string} schedule
|
|
@@ -191,7 +194,7 @@ class Functions extends Service {
|
|
|
191
194
|
}
|
|
192
195
|
|
|
193
196
|
/**
|
|
194
|
-
* Get
|
|
197
|
+
* Get function
|
|
195
198
|
*
|
|
196
199
|
* Get a function by its unique ID.
|
|
197
200
|
*
|
|
@@ -213,13 +216,13 @@ class Functions extends Service {
|
|
|
213
216
|
}
|
|
214
217
|
|
|
215
218
|
/**
|
|
216
|
-
* Update
|
|
219
|
+
* Update function
|
|
217
220
|
*
|
|
218
221
|
* Update function by its unique ID.
|
|
219
222
|
*
|
|
220
223
|
* @param {string} functionId
|
|
221
224
|
* @param {string} name
|
|
222
|
-
* @param {
|
|
225
|
+
* @param {Runtime} runtime
|
|
223
226
|
* @param {string[]} execute
|
|
224
227
|
* @param {string[]} events
|
|
225
228
|
* @param {string} schedule
|
|
@@ -314,7 +317,7 @@ class Functions extends Service {
|
|
|
314
317
|
}
|
|
315
318
|
|
|
316
319
|
/**
|
|
317
|
-
* Delete
|
|
320
|
+
* Delete function
|
|
318
321
|
*
|
|
319
322
|
* Delete a function by its unique ID.
|
|
320
323
|
*
|
|
@@ -336,7 +339,7 @@ class Functions extends Service {
|
|
|
336
339
|
}
|
|
337
340
|
|
|
338
341
|
/**
|
|
339
|
-
* List
|
|
342
|
+
* List deployments
|
|
340
343
|
*
|
|
341
344
|
* Get a list of all the project's code deployments. You can use the query
|
|
342
345
|
* params to filter your results.
|
|
@@ -369,7 +372,7 @@ class Functions extends Service {
|
|
|
369
372
|
}
|
|
370
373
|
|
|
371
374
|
/**
|
|
372
|
-
* Create
|
|
375
|
+
* Create deployment
|
|
373
376
|
*
|
|
374
377
|
* Create a new function code deployment. Use this endpoint to upload a new
|
|
375
378
|
* version of your code function. To execute your newly uploaded code, you'll
|
|
@@ -378,7 +381,7 @@ class Functions extends Service {
|
|
|
378
381
|
* This endpoint accepts a tar.gz file compressed with your code. Make sure to
|
|
379
382
|
* include any dependencies your code has within the compressed file. You can
|
|
380
383
|
* learn more about code packaging in the [Appwrite Cloud Functions
|
|
381
|
-
* tutorial](/docs/functions).
|
|
384
|
+
* tutorial](https://appwrite.io/docs/functions).
|
|
382
385
|
*
|
|
383
386
|
* Use the "command" param to set the entrypoint used to execute your code.
|
|
384
387
|
*
|
|
@@ -387,6 +390,7 @@ class Functions extends Service {
|
|
|
387
390
|
* @param {boolean} activate
|
|
388
391
|
* @param {string} entrypoint
|
|
389
392
|
* @param {string} commands
|
|
393
|
+
* @param {CallableFunction} onProgress
|
|
390
394
|
* @throws {AppwriteException}
|
|
391
395
|
* @returns {Promise}
|
|
392
396
|
*/
|
|
@@ -422,8 +426,9 @@ class Functions extends Service {
|
|
|
422
426
|
payload['activate'] = activate.toString();
|
|
423
427
|
}
|
|
424
428
|
|
|
425
|
-
const size = code.size;
|
|
426
429
|
|
|
430
|
+
const size = code.size;
|
|
431
|
+
|
|
427
432
|
const apiHeaders = {
|
|
428
433
|
'content-type': 'multipart/form-data',
|
|
429
434
|
};
|
|
@@ -434,123 +439,83 @@ class Functions extends Service {
|
|
|
434
439
|
let chunksUploaded = 0;
|
|
435
440
|
|
|
436
441
|
|
|
437
|
-
let currentChunk =
|
|
438
|
-
let
|
|
439
|
-
let
|
|
440
|
-
|
|
441
|
-
const selfClient = this.client;
|
|
442
|
+
let currentChunk = 1;
|
|
443
|
+
let currentPosition = 0;
|
|
444
|
+
let uploadableChunk = new Uint8Array(client.CHUNK_SIZE);
|
|
445
|
+
|
|
442
446
|
|
|
443
|
-
async
|
|
444
|
-
if(
|
|
447
|
+
const uploadChunk = async (lastUpload = false) => {
|
|
448
|
+
if(currentChunk <= chunksUploaded) {
|
|
445
449
|
return;
|
|
446
450
|
}
|
|
447
|
-
|
|
448
|
-
const start = currentChunkStart;
|
|
449
|
-
const end = currentChunkStart + currentChunkSize - 1;
|
|
450
451
|
|
|
451
|
-
|
|
452
|
+
const start = ((currentChunk - 1) * client.CHUNK_SIZE);
|
|
453
|
+
let end = start + currentPosition - 1;
|
|
454
|
+
|
|
455
|
+
if(!lastUpload || currentChunk !== 1) {
|
|
452
456
|
apiHeaders['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
|
|
453
457
|
}
|
|
454
458
|
|
|
459
|
+
let uploadableChunkTrimmed;
|
|
460
|
+
|
|
461
|
+
if(currentPosition + 1 >= client.CHUNK_SIZE) {
|
|
462
|
+
uploadableChunkTrimmed = uploadableChunk;
|
|
463
|
+
} else {
|
|
464
|
+
uploadableChunkTrimmed = new Uint8Array(currentPosition);
|
|
465
|
+
for(let i = 0; i <= currentPosition; i++) {
|
|
466
|
+
uploadableChunkTrimmed[i] = uploadableChunk[i];
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
455
470
|
if (id) {
|
|
456
471
|
apiHeaders['x-appwrite-id'] = id;
|
|
457
472
|
}
|
|
458
473
|
|
|
459
|
-
payload['code'] = {
|
|
460
|
-
type: 'file',
|
|
461
|
-
file: currentChunk,
|
|
462
|
-
filename: code.filename,
|
|
463
|
-
size: currentChunkSize
|
|
464
|
-
};
|
|
474
|
+
payload['code'] = { type: 'file', file: new File([uploadableChunkTrimmed], code.filename), filename: code.filename };
|
|
465
475
|
|
|
466
|
-
response = await
|
|
476
|
+
response = await this.client.call('post', apiPath, apiHeaders, payload);
|
|
467
477
|
|
|
468
478
|
if (!id) {
|
|
469
479
|
id = response['$id'];
|
|
470
480
|
}
|
|
471
|
-
|
|
481
|
+
|
|
472
482
|
if (onProgress !== null) {
|
|
473
483
|
onProgress({
|
|
474
484
|
$id: response['$id'],
|
|
475
|
-
progress: Math.min((
|
|
485
|
+
progress: Math.min((currentChunk) * client.CHUNK_SIZE, size) / size * 100,
|
|
476
486
|
sizeUploaded: end+1,
|
|
477
487
|
chunksTotal: response['chunksTotal'],
|
|
478
488
|
chunksUploaded: response['chunksUploaded']
|
|
479
489
|
});
|
|
480
490
|
}
|
|
481
491
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
const chunk = mainChunk.slice(i * client.CHUNK_SIZE, (i + 1) * client.CHUNK_SIZE);
|
|
496
|
-
chunks.push(chunk);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
for (const chunk of chunks) {
|
|
500
|
-
const chunkSize = Buffer.byteLength(chunk);
|
|
501
|
-
|
|
502
|
-
if(chunkSize + currentChunkSize == client.CHUNK_SIZE) {
|
|
503
|
-
// Upload chunk
|
|
504
|
-
currentChunk = Buffer.concat([currentChunk, chunk]);
|
|
505
|
-
currentChunkSize = Buffer.byteLength(currentChunk);
|
|
506
|
-
await uploadChunk();
|
|
507
|
-
currentChunk = Buffer.from('');
|
|
508
|
-
currentChunkSize = 0;
|
|
509
|
-
} else if(chunkSize + currentChunkSize > client.CHUNK_SIZE) {
|
|
510
|
-
// Upload chunk, put rest into next chunk
|
|
511
|
-
const bytesToUpload = client.CHUNK_SIZE - currentChunkSize;
|
|
512
|
-
const newChunkSection = chunk.slice(0, bytesToUpload);
|
|
513
|
-
currentChunk = Buffer.concat([currentChunk, newChunkSection]);
|
|
514
|
-
currentChunkSize = Buffer.byteLength(currentChunk);
|
|
515
|
-
await uploadChunk();
|
|
516
|
-
currentChunk = chunk.slice(bytesToUpload, undefined);
|
|
517
|
-
currentChunkSize = chunkSize - bytesToUpload;
|
|
518
|
-
} else {
|
|
519
|
-
// Append into current chunk
|
|
520
|
-
currentChunk = Buffer.concat([currentChunk, chunk]);
|
|
521
|
-
currentChunkSize = chunkSize + currentChunkSize;
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
callback();
|
|
526
|
-
} catch (e) {
|
|
527
|
-
callback(e);
|
|
492
|
+
uploadableChunk = new Uint8Array(client.CHUNK_SIZE);
|
|
493
|
+
currentChunk++;
|
|
494
|
+
currentPosition = 0;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
for await (const chunk of code.stream) {
|
|
498
|
+
for(const b of chunk) {
|
|
499
|
+
uploadableChunk[currentPosition] = b;
|
|
500
|
+
|
|
501
|
+
currentPosition++;
|
|
502
|
+
if(currentPosition >= client.CHUNK_SIZE) {
|
|
503
|
+
await uploadChunk();
|
|
504
|
+
currentPosition = 0;
|
|
528
505
|
}
|
|
529
506
|
}
|
|
507
|
+
}
|
|
530
508
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
await uploadChunk(true);
|
|
535
|
-
} catch (e) {
|
|
536
|
-
reject(e);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
resolve(response);
|
|
541
|
-
});
|
|
509
|
+
if (currentPosition > 0) { // Check if there's any remaining data for the last chunk
|
|
510
|
+
await uploadChunk(true);
|
|
511
|
+
}
|
|
542
512
|
|
|
543
|
-
|
|
544
|
-
reject(err);
|
|
545
|
-
});
|
|
546
|
-
|
|
547
|
-
code.stream.pipe(writeStream);
|
|
548
|
-
});
|
|
513
|
+
return response;
|
|
549
514
|
|
|
550
515
|
}
|
|
551
516
|
|
|
552
517
|
/**
|
|
553
|
-
* Get
|
|
518
|
+
* Get deployment
|
|
554
519
|
*
|
|
555
520
|
* Get a code deployment by its unique ID.
|
|
556
521
|
*
|
|
@@ -577,7 +542,7 @@ class Functions extends Service {
|
|
|
577
542
|
}
|
|
578
543
|
|
|
579
544
|
/**
|
|
580
|
-
* Update
|
|
545
|
+
* Update function deployment
|
|
581
546
|
*
|
|
582
547
|
* Update the function code deployment ID using the unique function ID. Use
|
|
583
548
|
* this endpoint to switch the code deployment that should be executed by the
|
|
@@ -606,7 +571,7 @@ class Functions extends Service {
|
|
|
606
571
|
}
|
|
607
572
|
|
|
608
573
|
/**
|
|
609
|
-
* Delete
|
|
574
|
+
* Delete deployment
|
|
610
575
|
*
|
|
611
576
|
* Delete a code deployment by its unique ID.
|
|
612
577
|
*
|
|
@@ -633,7 +598,7 @@ class Functions extends Service {
|
|
|
633
598
|
}
|
|
634
599
|
|
|
635
600
|
/**
|
|
636
|
-
* Create
|
|
601
|
+
* Create build
|
|
637
602
|
*
|
|
638
603
|
* Create a new build for an Appwrite Function deployment. This endpoint can
|
|
639
604
|
* be used to retry a failed build.
|
|
@@ -668,6 +633,9 @@ class Functions extends Service {
|
|
|
668
633
|
/**
|
|
669
634
|
* Download Deployment
|
|
670
635
|
*
|
|
636
|
+
* Get a Deployment's contents by its unique ID. This endpoint supports range
|
|
637
|
+
* requests for partial or streaming file download.
|
|
638
|
+
*
|
|
671
639
|
* @param {string} functionId
|
|
672
640
|
* @param {string} deploymentId
|
|
673
641
|
* @throws {AppwriteException}
|
|
@@ -691,7 +659,7 @@ class Functions extends Service {
|
|
|
691
659
|
}
|
|
692
660
|
|
|
693
661
|
/**
|
|
694
|
-
* List
|
|
662
|
+
* List executions
|
|
695
663
|
*
|
|
696
664
|
* Get a list of all the current user function execution logs. You can use the
|
|
697
665
|
* query params to filter your results.
|
|
@@ -724,7 +692,7 @@ class Functions extends Service {
|
|
|
724
692
|
}
|
|
725
693
|
|
|
726
694
|
/**
|
|
727
|
-
* Create
|
|
695
|
+
* Create execution
|
|
728
696
|
*
|
|
729
697
|
* Trigger a function execution. The returned object will return you the
|
|
730
698
|
* current execution status. You can ping the `Get Execution` endpoint to get
|
|
@@ -735,7 +703,7 @@ class Functions extends Service {
|
|
|
735
703
|
* @param {string} body
|
|
736
704
|
* @param {boolean} async
|
|
737
705
|
* @param {string} xpath
|
|
738
|
-
* @param {
|
|
706
|
+
* @param {ExecutionMethod} method
|
|
739
707
|
* @param {object} headers
|
|
740
708
|
* @throws {AppwriteException}
|
|
741
709
|
* @returns {Promise}
|
|
@@ -774,7 +742,7 @@ class Functions extends Service {
|
|
|
774
742
|
}
|
|
775
743
|
|
|
776
744
|
/**
|
|
777
|
-
* Get
|
|
745
|
+
* Get execution
|
|
778
746
|
*
|
|
779
747
|
* Get a function execution log by its unique ID.
|
|
780
748
|
*
|
|
@@ -801,7 +769,7 @@ class Functions extends Service {
|
|
|
801
769
|
}
|
|
802
770
|
|
|
803
771
|
/**
|
|
804
|
-
* List
|
|
772
|
+
* List variables
|
|
805
773
|
*
|
|
806
774
|
* Get a list of all variables of a specific function.
|
|
807
775
|
*
|
|
@@ -823,7 +791,7 @@ class Functions extends Service {
|
|
|
823
791
|
}
|
|
824
792
|
|
|
825
793
|
/**
|
|
826
|
-
* Create
|
|
794
|
+
* Create variable
|
|
827
795
|
*
|
|
828
796
|
* Create a new function environment variable. These variables can be accessed
|
|
829
797
|
* in the function at runtime as environment variables.
|
|
@@ -864,7 +832,7 @@ class Functions extends Service {
|
|
|
864
832
|
}
|
|
865
833
|
|
|
866
834
|
/**
|
|
867
|
-
* Get
|
|
835
|
+
* Get variable
|
|
868
836
|
*
|
|
869
837
|
* Get a variable by its unique ID.
|
|
870
838
|
*
|
|
@@ -891,7 +859,7 @@ class Functions extends Service {
|
|
|
891
859
|
}
|
|
892
860
|
|
|
893
861
|
/**
|
|
894
|
-
* Update
|
|
862
|
+
* Update variable
|
|
895
863
|
*
|
|
896
864
|
* Update variable by its unique ID.
|
|
897
865
|
*
|
|
@@ -932,7 +900,7 @@ class Functions extends Service {
|
|
|
932
900
|
}
|
|
933
901
|
|
|
934
902
|
/**
|
|
935
|
-
* Delete
|
|
903
|
+
* Delete variable
|
|
936
904
|
*
|
|
937
905
|
* Delete a variable by its unique ID.
|
|
938
906
|
*
|
package/lib/services/graphql.js
CHANGED
|
@@ -5,6 +5,8 @@ const client = require('../client.js');
|
|
|
5
5
|
const Stream = require('stream');
|
|
6
6
|
const { promisify } = require('util');
|
|
7
7
|
const fs = require('fs');
|
|
8
|
+
const { File } = require('undici');
|
|
9
|
+
const Query = require('../query.js');
|
|
8
10
|
|
|
9
11
|
class Graphql extends Service {
|
|
10
12
|
|
|
@@ -15,7 +17,7 @@ class Graphql extends Service {
|
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
|
-
* GraphQL
|
|
20
|
+
* GraphQL endpoint
|
|
19
21
|
*
|
|
20
22
|
* Execute a GraphQL mutation.
|
|
21
23
|
*
|
|
@@ -42,7 +44,7 @@ class Graphql extends Service {
|
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
|
-
* GraphQL
|
|
47
|
+
* GraphQL endpoint
|
|
46
48
|
*
|
|
47
49
|
* Execute a GraphQL mutation.
|
|
48
50
|
*
|