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
package/index.js
CHANGED
|
@@ -12,9 +12,28 @@ const Functions = require('./lib/services/functions.js');
|
|
|
12
12
|
const Graphql = require('./lib/services/graphql.js');
|
|
13
13
|
const Health = require('./lib/services/health.js');
|
|
14
14
|
const Locale = require('./lib/services/locale.js');
|
|
15
|
+
const Messaging = require('./lib/services/messaging.js');
|
|
15
16
|
const Storage = require('./lib/services/storage.js');
|
|
16
17
|
const Teams = require('./lib/services/teams.js');
|
|
17
18
|
const Users = require('./lib/services/users.js');
|
|
19
|
+
const AuthenticatorType = require("./lib/enums/authenticator-type.js");
|
|
20
|
+
const AuthenticationFactor = require("./lib/enums/authentication-factor.js");
|
|
21
|
+
const OAuthProvider = require("./lib/enums/o-auth-provider.js");
|
|
22
|
+
const Browser = require("./lib/enums/browser.js");
|
|
23
|
+
const CreditCard = require("./lib/enums/credit-card.js");
|
|
24
|
+
const Flag = require("./lib/enums/flag.js");
|
|
25
|
+
const RelationshipType = require("./lib/enums/relationship-type.js");
|
|
26
|
+
const RelationMutate = require("./lib/enums/relation-mutate.js");
|
|
27
|
+
const IndexType = require("./lib/enums/index-type.js");
|
|
28
|
+
const Runtime = require("./lib/enums/runtime.js");
|
|
29
|
+
const ExecutionMethod = require("./lib/enums/execution-method.js");
|
|
30
|
+
const Name = require("./lib/enums/name.js");
|
|
31
|
+
const SmtpEncryption = require("./lib/enums/smtp-encryption.js");
|
|
32
|
+
const Compression = require("./lib/enums/compression.js");
|
|
33
|
+
const ImageGravity = require("./lib/enums/image-gravity.js");
|
|
34
|
+
const ImageFormat = require("./lib/enums/image-format.js");
|
|
35
|
+
const PasswordHash = require("./lib/enums/password-hash.js");
|
|
36
|
+
const MessagingProviderType = require("./lib/enums/messaging-provider-type.js");
|
|
18
37
|
|
|
19
38
|
module.exports = {
|
|
20
39
|
Client,
|
|
@@ -31,7 +50,26 @@ module.exports = {
|
|
|
31
50
|
Graphql,
|
|
32
51
|
Health,
|
|
33
52
|
Locale,
|
|
53
|
+
Messaging,
|
|
34
54
|
Storage,
|
|
35
55
|
Teams,
|
|
36
56
|
Users,
|
|
57
|
+
AuthenticatorType,
|
|
58
|
+
AuthenticationFactor,
|
|
59
|
+
OAuthProvider,
|
|
60
|
+
Browser,
|
|
61
|
+
CreditCard,
|
|
62
|
+
Flag,
|
|
63
|
+
RelationshipType,
|
|
64
|
+
RelationMutate,
|
|
65
|
+
IndexType,
|
|
66
|
+
Runtime,
|
|
67
|
+
ExecutionMethod,
|
|
68
|
+
Name,
|
|
69
|
+
SmtpEncryption,
|
|
70
|
+
Compression,
|
|
71
|
+
ImageGravity,
|
|
72
|
+
ImageFormat,
|
|
73
|
+
PasswordHash,
|
|
74
|
+
MessagingProviderType,
|
|
37
75
|
};
|
package/lib/client.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
const os = require('os');
|
|
2
2
|
const URL = require('url').URL;
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const FormData = require('form-data');
|
|
3
|
+
const Query = require('./query.js');
|
|
4
|
+
const {fetch, FormData, Agent} = require('undici');
|
|
6
5
|
const AppwriteException = require('./exception.js');
|
|
7
6
|
|
|
8
7
|
class Client {
|
|
9
8
|
static CHUNK_SIZE = 5*1024*1024; // 5MB
|
|
10
9
|
|
|
11
10
|
constructor() {
|
|
12
|
-
this.endpoint = 'https://
|
|
11
|
+
this.endpoint = 'https://cloud.appwrite.io/v1';
|
|
13
12
|
this.headers = {
|
|
14
13
|
'accept-encoding': '*',
|
|
15
14
|
'content-type': '',
|
|
16
|
-
'user-agent' : `AppwriteNodeJSSDK/
|
|
15
|
+
'user-agent' : `AppwriteNodeJSSDK/12.0.0 (${os.type()}; ${os.version()}; ${os.arch()})`,
|
|
17
16
|
'x-sdk-name': 'Node.js',
|
|
18
17
|
'x-sdk-platform': 'server',
|
|
19
18
|
'x-sdk-language': 'nodejs',
|
|
20
|
-
'x-sdk-version': '
|
|
21
|
-
'X-Appwrite-Response-Format' : '1.
|
|
19
|
+
'x-sdk-version': '12.0.0',
|
|
20
|
+
'X-Appwrite-Response-Format' : '1.5.0',
|
|
22
21
|
};
|
|
23
22
|
this.selfSigned = false;
|
|
24
23
|
}
|
|
@@ -30,7 +29,7 @@ class Client {
|
|
|
30
29
|
*
|
|
31
30
|
* @param {string} project
|
|
32
31
|
*
|
|
33
|
-
* @return
|
|
32
|
+
* @return Client
|
|
34
33
|
*/
|
|
35
34
|
setProject(project) {
|
|
36
35
|
this.addHeader('X-Appwrite-Project', project);
|
|
@@ -45,7 +44,7 @@ class Client {
|
|
|
45
44
|
*
|
|
46
45
|
* @param {string} key
|
|
47
46
|
*
|
|
48
|
-
* @return
|
|
47
|
+
* @return Client
|
|
49
48
|
*/
|
|
50
49
|
setKey(key) {
|
|
51
50
|
this.addHeader('X-Appwrite-Key', key);
|
|
@@ -60,7 +59,7 @@ class Client {
|
|
|
60
59
|
*
|
|
61
60
|
* @param {string} jwt
|
|
62
61
|
*
|
|
63
|
-
* @return
|
|
62
|
+
* @return Client
|
|
64
63
|
*/
|
|
65
64
|
setJWT(jwt) {
|
|
66
65
|
this.addHeader('X-Appwrite-JWT', jwt);
|
|
@@ -73,7 +72,7 @@ class Client {
|
|
|
73
72
|
*
|
|
74
73
|
* @param {string} locale
|
|
75
74
|
*
|
|
76
|
-
* @return
|
|
75
|
+
* @return Client
|
|
77
76
|
*/
|
|
78
77
|
setLocale(locale) {
|
|
79
78
|
this.addHeader('X-Appwrite-Locale', locale);
|
|
@@ -81,6 +80,36 @@ class Client {
|
|
|
81
80
|
return this;
|
|
82
81
|
}
|
|
83
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Set Session
|
|
85
|
+
*
|
|
86
|
+
* The user session to authenticate with
|
|
87
|
+
*
|
|
88
|
+
* @param {string} session
|
|
89
|
+
*
|
|
90
|
+
* @return Client
|
|
91
|
+
*/
|
|
92
|
+
setSession(session) {
|
|
93
|
+
this.addHeader('X-Appwrite-Session', session);
|
|
94
|
+
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Set ForwardedUserAgent
|
|
100
|
+
*
|
|
101
|
+
* The user agent string of the client that made the request
|
|
102
|
+
*
|
|
103
|
+
* @param {string} forwardeduseragent
|
|
104
|
+
*
|
|
105
|
+
* @return Client
|
|
106
|
+
*/
|
|
107
|
+
setForwardedUserAgent(forwardeduseragent) {
|
|
108
|
+
this.addHeader('X-Forwarded-User-Agent', forwardeduseragent);
|
|
109
|
+
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
|
|
84
113
|
/**
|
|
85
114
|
* Set self signed.
|
|
86
115
|
*
|
|
@@ -109,8 +138,12 @@ class Client {
|
|
|
109
138
|
}
|
|
110
139
|
|
|
111
140
|
/**
|
|
141
|
+
* Sets a header for requests.
|
|
142
|
+
*
|
|
112
143
|
* @param {string} key
|
|
113
144
|
* @param {string} value
|
|
145
|
+
*
|
|
146
|
+
* @return this
|
|
114
147
|
*/
|
|
115
148
|
addHeader(key, value) {
|
|
116
149
|
this.headers[key.toLowerCase()] = value;
|
|
@@ -118,79 +151,88 @@ class Client {
|
|
|
118
151
|
return this;
|
|
119
152
|
}
|
|
120
153
|
|
|
121
|
-
async call(method, path =
|
|
122
|
-
headers =
|
|
154
|
+
async call(method, path = "", headers = {}, params = {}, responseType = "json") {
|
|
155
|
+
headers = {...this.headers, ...headers};
|
|
156
|
+
const url = new URL(this.endpoint + path);
|
|
123
157
|
|
|
124
|
-
let
|
|
158
|
+
let body = undefined;
|
|
125
159
|
|
|
126
|
-
|
|
160
|
+
if (method.toUpperCase() === "GET") {
|
|
161
|
+
url.search = new URLSearchParams(Client.flatten(params)).toString();
|
|
162
|
+
} else if (headers["content-type"]?.toLowerCase().startsWith("multipart/form-data")) {
|
|
163
|
+
delete headers["content-type"];
|
|
164
|
+
const formData = new FormData();
|
|
127
165
|
|
|
128
|
-
|
|
129
|
-
if (contentType.startsWith('multipart/form-data')) {
|
|
130
|
-
const form = new FormData();
|
|
131
|
-
|
|
132
|
-
let flatParams = Client.flatten(params);
|
|
133
|
-
|
|
134
|
-
for (const key in flatParams) {
|
|
135
|
-
const value = flatParams[key];
|
|
166
|
+
const flatParams = Client.flatten(params);
|
|
136
167
|
|
|
137
|
-
|
|
138
|
-
|
|
168
|
+
for (const [key, value] of Object.entries(flatParams)) {
|
|
169
|
+
if (value && value.type && value.type === "file") {
|
|
170
|
+
formData.append(key, value.file, value.filename);
|
|
139
171
|
} else {
|
|
140
|
-
|
|
172
|
+
formData.append(key, value);
|
|
141
173
|
}
|
|
142
174
|
}
|
|
143
175
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
formData = form;
|
|
176
|
+
body = formData;
|
|
177
|
+
} else {
|
|
178
|
+
body = JSON.stringify(params);
|
|
150
179
|
}
|
|
151
180
|
|
|
152
|
-
|
|
181
|
+
let response = undefined;
|
|
182
|
+
try {
|
|
183
|
+
response = await fetch(url.toString(), {
|
|
153
184
|
method: method.toUpperCase(),
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
185
|
+
headers,
|
|
186
|
+
body,
|
|
187
|
+
redirect: responseType === "location" ? "manual" : "follow",
|
|
188
|
+
dispatcher: new Agent({
|
|
189
|
+
connect: {
|
|
190
|
+
rejectUnauthorized: !this.selfSigned,
|
|
191
|
+
},
|
|
192
|
+
}),
|
|
193
|
+
});
|
|
194
|
+
} catch (error) {
|
|
195
|
+
throw new AppwriteException(error.message);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (response.status >= 400) {
|
|
199
|
+
const text = await response.text();
|
|
200
|
+
let json = undefined;
|
|
165
201
|
try {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
if('response' in error && error.response !== undefined) {
|
|
170
|
-
if(error.response && 'data' in error.response) {
|
|
171
|
-
if (typeof(error.response.data) === 'string') {
|
|
172
|
-
throw new AppwriteException(error.response.data, error.response.status, '', error.response.data);
|
|
173
|
-
} else {
|
|
174
|
-
throw new AppwriteException(error.response.data.message, error.response.status, error.response.data.type, error.response.data);
|
|
175
|
-
}
|
|
176
|
-
} else {
|
|
177
|
-
throw new AppwriteException(error.response.statusText, error.response.status, error.response.data);
|
|
178
|
-
}
|
|
179
|
-
} else {
|
|
180
|
-
throw new AppwriteException(error.message);
|
|
181
|
-
}
|
|
202
|
+
json = JSON.parse(text);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
throw new AppwriteException(text, response.status, "", text);
|
|
182
205
|
}
|
|
206
|
+
throw new AppwriteException(json.message, json.code, json.type, json);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (responseType === "arraybuffer") {
|
|
210
|
+
const data = await response.arrayBuffer();
|
|
211
|
+
return data;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (responseType === "location") {
|
|
215
|
+
return response.headers.get("location");
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const text = await response.text();
|
|
219
|
+
let json = undefined;
|
|
220
|
+
try {
|
|
221
|
+
json = JSON.parse(text);
|
|
222
|
+
} catch (error) {
|
|
223
|
+
return text;
|
|
224
|
+
}
|
|
225
|
+
return json;
|
|
183
226
|
}
|
|
184
227
|
|
|
185
|
-
static flatten(data, prefix =
|
|
228
|
+
static flatten(data, prefix = "") {
|
|
186
229
|
let output = {};
|
|
187
230
|
|
|
188
|
-
for (const key
|
|
189
|
-
let
|
|
190
|
-
let finalKey = prefix ? prefix + '[' + key +']' : key;
|
|
231
|
+
for (const [key, value] of Object.entries(data)) {
|
|
232
|
+
let finalKey = prefix ? prefix + "[" + key + "]" : key;
|
|
191
233
|
|
|
192
234
|
if (Array.isArray(value)) {
|
|
193
|
-
output =
|
|
235
|
+
output = { ...output, ...Client.flatten(value, finalKey) };
|
|
194
236
|
} else {
|
|
195
237
|
output[finalKey] = value;
|
|
196
238
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const Browser = Object.freeze({
|
|
2
|
+
AvantBrowser: 'aa' ,
|
|
3
|
+
AndroidWebViewBeta: 'an' ,
|
|
4
|
+
GoogleChrome: 'ch' ,
|
|
5
|
+
GoogleChromeIOS: 'ci' ,
|
|
6
|
+
GoogleChromeMobile: 'cm' ,
|
|
7
|
+
Chromium: 'cr' ,
|
|
8
|
+
MozillaFirefox: 'ff' ,
|
|
9
|
+
Safari: 'sf' ,
|
|
10
|
+
MobileSafari: 'mf' ,
|
|
11
|
+
MicrosoftEdge: 'ps' ,
|
|
12
|
+
MicrosoftEdgeIOS: 'oi' ,
|
|
13
|
+
OperaMini: 'om' ,
|
|
14
|
+
Opera: 'op' ,
|
|
15
|
+
OperaNext: 'on'
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
module.exports = Browser;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const CreditCard = Object.freeze({
|
|
2
|
+
AmericanExpress: 'amex' ,
|
|
3
|
+
Argencard: 'argencard' ,
|
|
4
|
+
Cabal: 'cabal' ,
|
|
5
|
+
Consosud: 'censosud' ,
|
|
6
|
+
DinersClub: 'diners' ,
|
|
7
|
+
Discover: 'discover' ,
|
|
8
|
+
Elo: 'elo' ,
|
|
9
|
+
Hipercard: 'hipercard' ,
|
|
10
|
+
JCB: 'jcb' ,
|
|
11
|
+
Mastercard: 'mastercard' ,
|
|
12
|
+
Naranja: 'naranja' ,
|
|
13
|
+
TarjetaShopping: 'targeta-shopping' ,
|
|
14
|
+
UnionChinaPay: 'union-china-pay' ,
|
|
15
|
+
Visa: 'visa' ,
|
|
16
|
+
MIR: 'mir' ,
|
|
17
|
+
Maestro: 'maestro'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
module.exports = CreditCard;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
const Flag = Object.freeze({
|
|
2
|
+
Afghanistan: 'af' ,
|
|
3
|
+
Angola: 'ao' ,
|
|
4
|
+
Albania: 'al' ,
|
|
5
|
+
Andorra: 'ad' ,
|
|
6
|
+
UnitedArabEmirates: 'ae' ,
|
|
7
|
+
Argentina: 'ar' ,
|
|
8
|
+
Armenia: 'am' ,
|
|
9
|
+
AntiguaAndBarbuda: 'ag' ,
|
|
10
|
+
Australia: 'au' ,
|
|
11
|
+
Austria: 'at' ,
|
|
12
|
+
Azerbaijan: 'az' ,
|
|
13
|
+
Burundi: 'bi' ,
|
|
14
|
+
Belgium: 'be' ,
|
|
15
|
+
Benin: 'bj' ,
|
|
16
|
+
BurkinaFaso: 'bf' ,
|
|
17
|
+
Bangladesh: 'bd' ,
|
|
18
|
+
Bulgaria: 'bg' ,
|
|
19
|
+
Bahrain: 'bh' ,
|
|
20
|
+
Bahamas: 'bs' ,
|
|
21
|
+
BosniaAndHerzegovina: 'ba' ,
|
|
22
|
+
Belarus: 'by' ,
|
|
23
|
+
Belize: 'bz' ,
|
|
24
|
+
Bolivia: 'bo' ,
|
|
25
|
+
Brazil: 'br' ,
|
|
26
|
+
Barbados: 'bb' ,
|
|
27
|
+
BruneiDarussalam: 'bn' ,
|
|
28
|
+
Bhutan: 'bt' ,
|
|
29
|
+
Botswana: 'bw' ,
|
|
30
|
+
CentralAfricanRepublic: 'cf' ,
|
|
31
|
+
Canada: 'ca' ,
|
|
32
|
+
Switzerland: 'ch' ,
|
|
33
|
+
Chile: 'cl' ,
|
|
34
|
+
China: 'cn' ,
|
|
35
|
+
CoteDIvoire: 'ci' ,
|
|
36
|
+
Cameroon: 'cm' ,
|
|
37
|
+
DemocraticRepublicOfTheCongo: 'cd' ,
|
|
38
|
+
RepublicOfTheCongo: 'cg' ,
|
|
39
|
+
Colombia: 'co' ,
|
|
40
|
+
Comoros: 'km' ,
|
|
41
|
+
CapeVerde: 'cv' ,
|
|
42
|
+
CostaRica: 'cr' ,
|
|
43
|
+
Cuba: 'cu' ,
|
|
44
|
+
Cyprus: 'cy' ,
|
|
45
|
+
CzechRepublic: 'cz' ,
|
|
46
|
+
Germany: 'de' ,
|
|
47
|
+
Djibouti: 'dj' ,
|
|
48
|
+
Dominica: 'dm' ,
|
|
49
|
+
Denmark: 'dk' ,
|
|
50
|
+
DominicanRepublic: 'do' ,
|
|
51
|
+
Algeria: 'dz' ,
|
|
52
|
+
Ecuador: 'ec' ,
|
|
53
|
+
Egypt: 'eg' ,
|
|
54
|
+
Eritrea: 'er' ,
|
|
55
|
+
Spain: 'es' ,
|
|
56
|
+
Estonia: 'ee' ,
|
|
57
|
+
Ethiopia: 'et' ,
|
|
58
|
+
Finland: 'fi' ,
|
|
59
|
+
Fiji: 'fj' ,
|
|
60
|
+
France: 'fr' ,
|
|
61
|
+
MicronesiaFederatedStatesOf: 'fm' ,
|
|
62
|
+
Gabon: 'ga' ,
|
|
63
|
+
UnitedKingdom: 'gb' ,
|
|
64
|
+
Georgia: 'ge' ,
|
|
65
|
+
Ghana: 'gh' ,
|
|
66
|
+
Guinea: 'gn' ,
|
|
67
|
+
Gambia: 'gm' ,
|
|
68
|
+
GuineaBissau: 'gw' ,
|
|
69
|
+
EquatorialGuinea: 'gq' ,
|
|
70
|
+
Greece: 'gr' ,
|
|
71
|
+
Grenada: 'gd' ,
|
|
72
|
+
Guatemala: 'gt' ,
|
|
73
|
+
Guyana: 'gy' ,
|
|
74
|
+
Honduras: 'hn' ,
|
|
75
|
+
Croatia: 'hr' ,
|
|
76
|
+
Haiti: 'ht' ,
|
|
77
|
+
Hungary: 'hu' ,
|
|
78
|
+
Indonesia: 'id' ,
|
|
79
|
+
India: 'in' ,
|
|
80
|
+
Ireland: 'ie' ,
|
|
81
|
+
IranIslamicRepublicOf: 'ir' ,
|
|
82
|
+
Iraq: 'iq' ,
|
|
83
|
+
Iceland: 'is' ,
|
|
84
|
+
Israel: 'il' ,
|
|
85
|
+
Italy: 'it' ,
|
|
86
|
+
Jamaica: 'jm' ,
|
|
87
|
+
Jordan: 'jo' ,
|
|
88
|
+
Japan: 'jp' ,
|
|
89
|
+
Kazakhstan: 'kz' ,
|
|
90
|
+
Kenya: 'ke' ,
|
|
91
|
+
Kyrgyzstan: 'kg' ,
|
|
92
|
+
Cambodia: 'kh' ,
|
|
93
|
+
Kiribati: 'ki' ,
|
|
94
|
+
SaintKittsAndNevis: 'kn' ,
|
|
95
|
+
SouthKorea: 'kr' ,
|
|
96
|
+
Kuwait: 'kw' ,
|
|
97
|
+
LaoPeopleSDemocraticRepublic: 'la' ,
|
|
98
|
+
Lebanon: 'lb' ,
|
|
99
|
+
Liberia: 'lr' ,
|
|
100
|
+
Libya: 'ly' ,
|
|
101
|
+
SaintLucia: 'lc' ,
|
|
102
|
+
Liechtenstein: 'li' ,
|
|
103
|
+
SriLanka: 'lk' ,
|
|
104
|
+
Lesotho: 'ls' ,
|
|
105
|
+
Lithuania: 'lt' ,
|
|
106
|
+
Luxembourg: 'lu' ,
|
|
107
|
+
Latvia: 'lv' ,
|
|
108
|
+
Morocco: 'ma' ,
|
|
109
|
+
Monaco: 'mc' ,
|
|
110
|
+
Moldova: 'md' ,
|
|
111
|
+
Madagascar: 'mg' ,
|
|
112
|
+
Maldives: 'mv' ,
|
|
113
|
+
Mexico: 'mx' ,
|
|
114
|
+
MarshallIslands: 'mh' ,
|
|
115
|
+
NorthMacedonia: 'mk' ,
|
|
116
|
+
Mali: 'ml' ,
|
|
117
|
+
Malta: 'mt' ,
|
|
118
|
+
Myanmar: 'mm' ,
|
|
119
|
+
Montenegro: 'me' ,
|
|
120
|
+
Mongolia: 'mn' ,
|
|
121
|
+
Mozambique: 'mz' ,
|
|
122
|
+
Mauritania: 'mr' ,
|
|
123
|
+
Mauritius: 'mu' ,
|
|
124
|
+
Malawi: 'mw' ,
|
|
125
|
+
Malaysia: 'my' ,
|
|
126
|
+
Namibia: 'na' ,
|
|
127
|
+
Niger: 'ne' ,
|
|
128
|
+
Nigeria: 'ng' ,
|
|
129
|
+
Nicaragua: 'ni' ,
|
|
130
|
+
Netherlands: 'nl' ,
|
|
131
|
+
Norway: 'no' ,
|
|
132
|
+
Nepal: 'np' ,
|
|
133
|
+
Nauru: 'nr' ,
|
|
134
|
+
NewZealand: 'nz' ,
|
|
135
|
+
Oman: 'om' ,
|
|
136
|
+
Pakistan: 'pk' ,
|
|
137
|
+
Panama: 'pa' ,
|
|
138
|
+
Peru: 'pe' ,
|
|
139
|
+
Philippines: 'ph' ,
|
|
140
|
+
Palau: 'pw' ,
|
|
141
|
+
PapuaNewGuinea: 'pg' ,
|
|
142
|
+
Poland: 'pl' ,
|
|
143
|
+
NorthKorea: 'kp' ,
|
|
144
|
+
Portugal: 'pt' ,
|
|
145
|
+
Paraguay: 'py' ,
|
|
146
|
+
Qatar: 'qa' ,
|
|
147
|
+
Romania: 'ro' ,
|
|
148
|
+
Russia: 'ru' ,
|
|
149
|
+
Rwanda: 'rw' ,
|
|
150
|
+
SaudiArabia: 'sa' ,
|
|
151
|
+
Sudan: 'sd' ,
|
|
152
|
+
Senegal: 'sn' ,
|
|
153
|
+
Singapore: 'sg' ,
|
|
154
|
+
SolomonIslands: 'sb' ,
|
|
155
|
+
SierraLeone: 'sl' ,
|
|
156
|
+
ElSalvador: 'sv' ,
|
|
157
|
+
SanMarino: 'sm' ,
|
|
158
|
+
Somalia: 'so' ,
|
|
159
|
+
Serbia: 'rs' ,
|
|
160
|
+
SouthSudan: 'ss' ,
|
|
161
|
+
SaoTomeAndPrincipe: 'st' ,
|
|
162
|
+
Suriname: 'sr' ,
|
|
163
|
+
Slovakia: 'sk' ,
|
|
164
|
+
Slovenia: 'si' ,
|
|
165
|
+
Sweden: 'se' ,
|
|
166
|
+
Eswatini: 'sz' ,
|
|
167
|
+
Seychelles: 'sc' ,
|
|
168
|
+
Syria: 'sy' ,
|
|
169
|
+
Chad: 'td' ,
|
|
170
|
+
Togo: 'tg' ,
|
|
171
|
+
Thailand: 'th' ,
|
|
172
|
+
Tajikistan: 'tj' ,
|
|
173
|
+
Turkmenistan: 'tm' ,
|
|
174
|
+
TimorLeste: 'tl' ,
|
|
175
|
+
Tonga: 'to' ,
|
|
176
|
+
TrinidadAndTobago: 'tt' ,
|
|
177
|
+
Tunisia: 'tn' ,
|
|
178
|
+
Turkey: 'tr' ,
|
|
179
|
+
Tuvalu: 'tv' ,
|
|
180
|
+
Tanzania: 'tz' ,
|
|
181
|
+
Uganda: 'ug' ,
|
|
182
|
+
Ukraine: 'ua' ,
|
|
183
|
+
Uruguay: 'uy' ,
|
|
184
|
+
UnitedStates: 'us' ,
|
|
185
|
+
Uzbekistan: 'uz' ,
|
|
186
|
+
VaticanCity: 'va' ,
|
|
187
|
+
SaintVincentAndTheGrenadines: 'vc' ,
|
|
188
|
+
Venezuela: 've' ,
|
|
189
|
+
Vietnam: 'vn' ,
|
|
190
|
+
Vanuatu: 'vu' ,
|
|
191
|
+
Samoa: 'ws' ,
|
|
192
|
+
Yemen: 'ye' ,
|
|
193
|
+
SouthAfrica: 'za' ,
|
|
194
|
+
Zambia: 'zm' ,
|
|
195
|
+
Zimbabwe: 'zw'
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
module.exports = Flag;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const ImageGravity = Object.freeze({
|
|
2
|
+
Center: 'center' ,
|
|
3
|
+
TopLeft: 'top-left' ,
|
|
4
|
+
Top: 'top' ,
|
|
5
|
+
TopRight: 'top-right' ,
|
|
6
|
+
Left: 'left' ,
|
|
7
|
+
Right: 'right' ,
|
|
8
|
+
BottomLeft: 'bottom-left' ,
|
|
9
|
+
Bottom: 'bottom' ,
|
|
10
|
+
BottomRight: 'bottom-right'
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
module.exports = ImageGravity;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const Name = Object.freeze({
|
|
2
|
+
V1Database: 'v1-database' ,
|
|
3
|
+
V1Deletes: 'v1-deletes' ,
|
|
4
|
+
V1Audits: 'v1-audits' ,
|
|
5
|
+
V1Mails: 'v1-mails' ,
|
|
6
|
+
V1Functions: 'v1-functions' ,
|
|
7
|
+
V1Usage: 'v1-usage' ,
|
|
8
|
+
V1UsageDump: 'v1-usage-dump' ,
|
|
9
|
+
Webhooksv1: 'webhooksv1' ,
|
|
10
|
+
V1Certificates: 'v1-certificates' ,
|
|
11
|
+
V1Builds: 'v1-builds' ,
|
|
12
|
+
V1Messaging: 'v1-messaging' ,
|
|
13
|
+
V1Migrations: 'v1-migrations' ,
|
|
14
|
+
Hamsterv1: 'hamsterv1'
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
module.exports = Name;
|