node-appwrite 11.1.1 → 12.0.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/.travis.yml +2 -2
- package/LICENSE +1 -1
- package/README.md +6 -6
- 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-mfa-authenticator.md +12 -0
- package/docs/examples/account/create-mfa-challenge.md +11 -0
- package/docs/examples/account/create-mfa-recovery-codes.md +10 -0
- package/docs/examples/account/create-o-auth2token.md +14 -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/delete-identity.md +6 -14
- package/docs/examples/account/delete-mfa-authenticator.md +13 -0
- package/docs/examples/account/delete-session.md +6 -14
- package/docs/examples/account/delete-sessions.md +4 -14
- package/docs/examples/account/get-mfa-recovery-codes.md +10 -0
- 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-identities.md +6 -14
- package/docs/examples/account/list-logs.md +6 -14
- package/docs/examples/account/list-mfa-factors.md +10 -0
- package/docs/examples/account/list-sessions.md +4 -14
- 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-mfa-authenticator.md +13 -0
- package/docs/examples/account/update-mfa-challenge.md +13 -0
- package/docs/examples/account/update-mfa-recovery-codes.md +10 -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-session.md +12 -0
- 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/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 +6 -14
- package/docs/examples/health/get-queue-certificates.md +6 -14
- package/docs/examples/health/get-queue-databases.md +7 -14
- package/docs/examples/health/get-queue-deletes.md +6 -14
- 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 +6 -14
- package/docs/examples/health/get-queue-messaging.md +6 -14
- package/docs/examples/health/get-queue-migrations.md +6 -14
- package/docs/examples/health/get-queue-usage-dump.md +12 -0
- package/docs/examples/health/get-queue-usage.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-storage.md +10 -0
- 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 +19 -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-apns-provider.md +19 -0
- package/docs/examples/messaging/update-email.md +22 -0
- package/docs/examples/messaging/update-fcm-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 +14 -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-mfa-recovery-codes.md +12 -0
- 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-identity.md +6 -14
- package/docs/examples/users/delete-mfa-authenticator.md +13 -0
- 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-mfa-recovery-codes.md +12 -0
- 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-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-mfa-factors.md +12 -0
- 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-recovery-codes.md +12 -0
- 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 +2164 -81
- package/index.js +38 -0
- package/lib/client.js +107 -65
- package/lib/enums/authentication-factor.js +8 -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/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 +7 -0
- package/lib/enums/messaging-provider-type.js +7 -0
- package/lib/enums/name.js +17 -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 +48 -0
- package/lib/enums/smtp-encryption.js +7 -0
- package/lib/inputFile.js +88 -16
- package/lib/query.js +56 -38
- package/lib/services/account.js +722 -16
- package/lib/services/avatars.js +5 -3
- package/lib/services/databases.js +34 -4
- package/lib/services/functions.js +51 -87
- package/lib/services/graphql.js +2 -0
- package/lib/services/health.js +118 -0
- package/lib/services/locale.js +2 -0
- package/lib/services/messaging.js +2218 -0
- package/lib/services/storage.js +52 -88
- package/lib/services/teams.js +2 -0
- package/lib/services/users.js +405 -3
- package/package.json +2 -3
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const OAuthProvider = Object.freeze({
|
|
2
|
+
Amazon: 'amazon' ,
|
|
3
|
+
Apple: 'apple' ,
|
|
4
|
+
Auth0: 'auth0' ,
|
|
5
|
+
Authentik: 'authentik' ,
|
|
6
|
+
Autodesk: 'autodesk' ,
|
|
7
|
+
Bitbucket: 'bitbucket' ,
|
|
8
|
+
Bitly: 'bitly' ,
|
|
9
|
+
Box: 'box' ,
|
|
10
|
+
Dailymotion: 'dailymotion' ,
|
|
11
|
+
Discord: 'discord' ,
|
|
12
|
+
Disqus: 'disqus' ,
|
|
13
|
+
Dropbox: 'dropbox' ,
|
|
14
|
+
Etsy: 'etsy' ,
|
|
15
|
+
Facebook: 'facebook' ,
|
|
16
|
+
Github: 'github' ,
|
|
17
|
+
Gitlab: 'gitlab' ,
|
|
18
|
+
Google: 'google' ,
|
|
19
|
+
Linkedin: 'linkedin' ,
|
|
20
|
+
Microsoft: 'microsoft' ,
|
|
21
|
+
Notion: 'notion' ,
|
|
22
|
+
Oidc: 'oidc' ,
|
|
23
|
+
Okta: 'okta' ,
|
|
24
|
+
Paypal: 'paypal' ,
|
|
25
|
+
PaypalSandbox: 'paypalSandbox' ,
|
|
26
|
+
Podio: 'podio' ,
|
|
27
|
+
Salesforce: 'salesforce' ,
|
|
28
|
+
Slack: 'slack' ,
|
|
29
|
+
Spotify: 'spotify' ,
|
|
30
|
+
Stripe: 'stripe' ,
|
|
31
|
+
Tradeshift: 'tradeshift' ,
|
|
32
|
+
TradeshiftBox: 'tradeshiftBox' ,
|
|
33
|
+
Twitch: 'twitch' ,
|
|
34
|
+
Wordpress: 'wordpress' ,
|
|
35
|
+
Yahoo: 'yahoo' ,
|
|
36
|
+
Yammer: 'yammer' ,
|
|
37
|
+
Yandex: 'yandex' ,
|
|
38
|
+
Zoho: 'zoho' ,
|
|
39
|
+
Zoom: 'zoom' ,
|
|
40
|
+
Mock: 'mock'
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
module.exports = OAuthProvider;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const PasswordHash = Object.freeze({
|
|
2
|
+
Sha1: 'sha1' ,
|
|
3
|
+
Sha224: 'sha224' ,
|
|
4
|
+
Sha256: 'sha256' ,
|
|
5
|
+
Sha384: 'sha384' ,
|
|
6
|
+
Sha512224: 'sha512/224' ,
|
|
7
|
+
Sha512256: 'sha512/256' ,
|
|
8
|
+
Sha512: 'sha512' ,
|
|
9
|
+
Sha3224: 'sha3-224' ,
|
|
10
|
+
Sha3256: 'sha3-256' ,
|
|
11
|
+
Sha3384: 'sha3-384' ,
|
|
12
|
+
Sha3512: 'sha3-512'
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
module.exports = PasswordHash;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const Runtime = Object.freeze({
|
|
2
|
+
Node145: 'node-14.5' ,
|
|
3
|
+
Node160: 'node-16.0' ,
|
|
4
|
+
Node180: 'node-18.0' ,
|
|
5
|
+
Node190: 'node-19.0' ,
|
|
6
|
+
Node200: 'node-20.0' ,
|
|
7
|
+
Node210: 'node-21.0' ,
|
|
8
|
+
Php80: 'php-8.0' ,
|
|
9
|
+
Php81: 'php-8.1' ,
|
|
10
|
+
Php82: 'php-8.2' ,
|
|
11
|
+
Php83: 'php-8.3' ,
|
|
12
|
+
Ruby30: 'ruby-3.0' ,
|
|
13
|
+
Ruby31: 'ruby-3.1' ,
|
|
14
|
+
Ruby32: 'ruby-3.2' ,
|
|
15
|
+
Ruby33: 'ruby-3.3' ,
|
|
16
|
+
Python38: 'python-3.8' ,
|
|
17
|
+
Python39: 'python-3.9' ,
|
|
18
|
+
Python310: 'python-3.10' ,
|
|
19
|
+
Python311: 'python-3.11' ,
|
|
20
|
+
Python312: 'python-3.12' ,
|
|
21
|
+
Deno140: 'deno-1.40' ,
|
|
22
|
+
Dart215: 'dart-2.15' ,
|
|
23
|
+
Dart216: 'dart-2.16' ,
|
|
24
|
+
Dart217: 'dart-2.17' ,
|
|
25
|
+
Dart218: 'dart-2.18' ,
|
|
26
|
+
Dart30: 'dart-3.0' ,
|
|
27
|
+
Dart31: 'dart-3.1' ,
|
|
28
|
+
Dart33: 'dart-3.3' ,
|
|
29
|
+
Dotnet31: 'dotnet-3.1' ,
|
|
30
|
+
Dotnet60: 'dotnet-6.0' ,
|
|
31
|
+
Dotnet70: 'dotnet-7.0' ,
|
|
32
|
+
Java80: 'java-8.0' ,
|
|
33
|
+
Java110: 'java-11.0' ,
|
|
34
|
+
Java170: 'java-17.0' ,
|
|
35
|
+
Java180: 'java-18.0' ,
|
|
36
|
+
Java210: 'java-21.0' ,
|
|
37
|
+
Swift55: 'swift-5.5' ,
|
|
38
|
+
Swift58: 'swift-5.8' ,
|
|
39
|
+
Swift59: 'swift-5.9' ,
|
|
40
|
+
Kotlin16: 'kotlin-1.6' ,
|
|
41
|
+
Kotlin18: 'kotlin-1.8' ,
|
|
42
|
+
Kotlin19: 'kotlin-1.9' ,
|
|
43
|
+
Cpp17: 'cpp-17' ,
|
|
44
|
+
Cpp20: 'cpp-20' ,
|
|
45
|
+
Bun10: 'bun-1.0'
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
module.exports = Runtime;
|
package/lib/inputFile.js
CHANGED
|
@@ -1,40 +1,112 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const { ReadableStream } = require("stream/web");
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {fs.ReadStream} readStream
|
|
6
|
+
* @returns {ReadableStream}
|
|
7
|
+
*/
|
|
8
|
+
function convertReadStreamToReadableStream(readStream) {
|
|
9
|
+
return new ReadableStream({
|
|
10
|
+
start(controller) {
|
|
11
|
+
readStream.on("data", (chunk) => {
|
|
12
|
+
controller.enqueue(chunk);
|
|
13
|
+
});
|
|
14
|
+
readStream.on("end", () => {
|
|
15
|
+
controller.close();
|
|
16
|
+
});
|
|
17
|
+
readStream.on("error", (err) => {
|
|
18
|
+
controller.error(err);
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
cancel() {
|
|
22
|
+
readStream.destroy();
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param {Buffer} buffer
|
|
29
|
+
* @returns {ReadableStream}
|
|
30
|
+
*/
|
|
31
|
+
function bufferToReadableStream(buffer) {
|
|
32
|
+
return new ReadableStream({
|
|
33
|
+
start(controller) {
|
|
34
|
+
controller.enqueue(buffer);
|
|
35
|
+
controller.close();
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
3
39
|
|
|
4
40
|
class InputFile {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
filename; // File name
|
|
41
|
+
/** @type {ReadableStream} Content of file as a stream */
|
|
42
|
+
stream;
|
|
8
43
|
|
|
44
|
+
/** @type {number} Total final size of the file content */
|
|
45
|
+
size;
|
|
46
|
+
|
|
47
|
+
/** @type {string} File name */
|
|
48
|
+
filename;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {string} filePath
|
|
52
|
+
* @param {string} filename
|
|
53
|
+
* @returns {InputFile}
|
|
54
|
+
*/
|
|
9
55
|
static fromPath = (filePath, filename) => {
|
|
10
|
-
const
|
|
11
|
-
const
|
|
56
|
+
const nodeStream = fs.createReadStream(filePath);
|
|
57
|
+
const stream = convertReadStreamToReadableStream(nodeStream);
|
|
58
|
+
const size = fs.statSync(filePath).size;
|
|
12
59
|
return new InputFile(stream, filename, size);
|
|
13
60
|
};
|
|
14
61
|
|
|
62
|
+
/**
|
|
63
|
+
* @param {Buffer} buffer
|
|
64
|
+
* @param {string} filename
|
|
65
|
+
* @returns {InputFile}
|
|
66
|
+
*/
|
|
15
67
|
static fromBuffer = (buffer, filename) => {
|
|
16
|
-
const stream =
|
|
17
|
-
const size =
|
|
68
|
+
const stream = bufferToReadableStream(buffer);
|
|
69
|
+
const size = buffer.byteLength;
|
|
18
70
|
return new InputFile(stream, filename, size);
|
|
19
71
|
};
|
|
20
72
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
73
|
+
/**
|
|
74
|
+
* @param {string} content
|
|
75
|
+
* @param {string} filename
|
|
76
|
+
* @returns {InputFile}
|
|
77
|
+
*/
|
|
78
|
+
static fromPlainText = (content, filename) => {
|
|
79
|
+
const array = new TextEncoder().encode(content);
|
|
80
|
+
const buffer = Buffer.from(array);
|
|
24
81
|
return InputFile.fromBuffer(buffer, filename);
|
|
25
82
|
};
|
|
26
83
|
|
|
84
|
+
/**
|
|
85
|
+
* @param {ReadableStream} stream
|
|
86
|
+
* @param {string} filename
|
|
87
|
+
* @param {number} size
|
|
88
|
+
* @returns {InputFile}
|
|
89
|
+
*/
|
|
27
90
|
static fromStream = (stream, filename, size) => {
|
|
28
91
|
return new InputFile(stream, filename, size);
|
|
29
92
|
};
|
|
30
93
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
94
|
+
/**
|
|
95
|
+
* @param {Blob} blob
|
|
96
|
+
* @param {string} filename
|
|
97
|
+
* @returns {InputFile}
|
|
98
|
+
*/
|
|
99
|
+
static fromBlob = (blob, filename) => {
|
|
100
|
+
const stream = blob.stream();
|
|
101
|
+
const size = blob.size;
|
|
35
102
|
return new InputFile(stream, filename, size);
|
|
36
103
|
};
|
|
37
104
|
|
|
105
|
+
/**
|
|
106
|
+
* @param {ReadableStream} stream
|
|
107
|
+
* @param {string} filename
|
|
108
|
+
* @param {number} size
|
|
109
|
+
*/
|
|
38
110
|
constructor(stream, filename, size) {
|
|
39
111
|
this.stream = stream;
|
|
40
112
|
this.filename = filename;
|
package/lib/query.js
CHANGED
|
@@ -1,72 +1,90 @@
|
|
|
1
1
|
class Query {
|
|
2
|
+
constructor(method, attribute, values) {
|
|
3
|
+
this.method = method
|
|
4
|
+
this.attribute = attribute
|
|
5
|
+
|
|
6
|
+
if (values !== undefined) {
|
|
7
|
+
if (Array.isArray(values)) {
|
|
8
|
+
this.values = values
|
|
9
|
+
} else {
|
|
10
|
+
this.values = [values]
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
2
15
|
static equal = (attribute, value) =>
|
|
3
|
-
Query
|
|
16
|
+
new Query("equal", attribute, value).toString()
|
|
4
17
|
|
|
5
18
|
static notEqual = (attribute, value) =>
|
|
6
|
-
Query
|
|
19
|
+
new Query("notEqual", attribute, value).toString()
|
|
7
20
|
|
|
8
21
|
static lessThan = (attribute, value) =>
|
|
9
|
-
Query
|
|
22
|
+
new Query("lessThan", attribute, value).toString()
|
|
10
23
|
|
|
11
24
|
static lessThanEqual = (attribute, value) =>
|
|
12
|
-
Query
|
|
25
|
+
new Query("lessThanEqual", attribute, value).toString()
|
|
13
26
|
|
|
14
27
|
static greaterThan = (attribute, value) =>
|
|
15
|
-
Query
|
|
28
|
+
new Query("greaterThan", attribute, value).toString()
|
|
16
29
|
|
|
17
30
|
static greaterThanEqual = (attribute, value) =>
|
|
18
|
-
Query
|
|
31
|
+
new Query("greaterThanEqual", attribute, value).toString()
|
|
19
32
|
|
|
20
|
-
static isNull =
|
|
21
|
-
|
|
33
|
+
static isNull = attribute =>
|
|
34
|
+
new Query("isNull", attribute).toString()
|
|
22
35
|
|
|
23
|
-
static isNotNull =
|
|
24
|
-
|
|
36
|
+
static isNotNull = attribute =>
|
|
37
|
+
new Query("isNotNull", attribute).toString()
|
|
25
38
|
|
|
26
39
|
static between = (attribute, start, end) =>
|
|
27
|
-
|
|
40
|
+
new Query("between", attribute, [start, end]).toString()
|
|
28
41
|
|
|
29
42
|
static startsWith = (attribute, value) =>
|
|
30
|
-
Query
|
|
43
|
+
new Query("startsWith", attribute, value).toString()
|
|
31
44
|
|
|
32
45
|
static endsWith = (attribute, value) =>
|
|
33
|
-
Query
|
|
46
|
+
new Query("endsWith", attribute, value).toString()
|
|
34
47
|
|
|
35
|
-
static select =
|
|
36
|
-
|
|
48
|
+
static select = attributes =>
|
|
49
|
+
new Query("select", undefined, attributes).toString()
|
|
37
50
|
|
|
38
51
|
static search = (attribute, value) =>
|
|
39
|
-
Query
|
|
52
|
+
new Query("search", attribute, value).toString()
|
|
53
|
+
|
|
54
|
+
static orderDesc = attribute =>
|
|
55
|
+
new Query("orderDesc", attribute).toString()
|
|
40
56
|
|
|
41
|
-
static
|
|
42
|
-
|
|
57
|
+
static orderAsc = attribute =>
|
|
58
|
+
new Query("orderAsc", attribute).toString()
|
|
43
59
|
|
|
44
|
-
static
|
|
45
|
-
|
|
60
|
+
static cursorAfter = documentId =>
|
|
61
|
+
new Query("cursorAfter", undefined, documentId).toString()
|
|
46
62
|
|
|
47
|
-
static
|
|
48
|
-
|
|
63
|
+
static cursorBefore = documentId =>
|
|
64
|
+
new Query("cursorBefore", undefined, documentId).toString()
|
|
49
65
|
|
|
50
|
-
static
|
|
51
|
-
|
|
66
|
+
static limit = limit =>
|
|
67
|
+
new Query("limit", undefined, limit).toString()
|
|
52
68
|
|
|
53
|
-
static
|
|
54
|
-
|
|
69
|
+
static offset = offset =>
|
|
70
|
+
new Query("offset", undefined, offset).toString()
|
|
55
71
|
|
|
56
|
-
static
|
|
57
|
-
|
|
72
|
+
static contains = (attribute, value) =>
|
|
73
|
+
new Query("contains", attribute, value).toString()
|
|
58
74
|
|
|
59
|
-
static
|
|
60
|
-
|
|
61
|
-
? `${method}("${attribute}", [${value
|
|
62
|
-
.map((v) => Query.parseValues(v))
|
|
63
|
-
.join(",")}])`
|
|
64
|
-
: `${method}("${attribute}", [${Query.parseValues(value)}])`;
|
|
75
|
+
static or = (queries) =>
|
|
76
|
+
new Query("or", undefined, queries.map((query) => JSON.parse(query))).toString()
|
|
65
77
|
|
|
66
|
-
static
|
|
67
|
-
|
|
68
|
-
? `"${value}"`
|
|
69
|
-
: `${value}`;
|
|
78
|
+
static and = (queries) =>
|
|
79
|
+
new Query("and", undefined, queries.map((query) => JSON.parse(query))).toString();
|
|
70
80
|
}
|
|
71
81
|
|
|
82
|
+
Query.prototype.toString = function () {
|
|
83
|
+
return JSON.stringify({
|
|
84
|
+
method: this.method,
|
|
85
|
+
attribute: this.attribute,
|
|
86
|
+
values: this.values
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
72
90
|
module.exports = Query;
|