From 8b1c37cb87d3a208c41c06b713667a7854487151 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 14 Oct 2026 12:21:48 +0100 Subject: [PATCH 1/2] feat: Node.js SDK update for version 29.4.0 --- CHANGELOG.md | 20 + .../account/create-email-password-session.md | 1 + .../account/create-email-verification-otp.md | 14 + .../account/create-id-token-session.md | 19 + docs/examples/account/create-recovery-otp.md | 15 + docs/examples/account/delete-sessions.md | 4 +- docs/examples/account/list-sessions.md | 4 +- .../account/update-email-verification-otp.md | 15 + docs/examples/account/update-recovery-otp.md | 16 + docs/examples/avatars/delete-photo.md | 12 + docs/examples/avatars/update-photo.md | 15 + docs/examples/databases/list-transactions.md | 1 + .../examples/documentsdb/list-transactions.md | 1 + .../domains/create-preset-google-workspace.md | 14 + .../examples/domains/create-preset-i-cloud.md | 14 + .../examples/domains/create-preset-mailgun.md | 14 + .../examples/domains/create-preset-outlook.md | 14 + .../domains/create-preset-proton-mail.md | 14 + docs/examples/domains/create-preset-zoho.md | 14 + docs/examples/domains/create-record-a.md | 18 + docs/examples/domains/create-record-aaaa.md | 18 + docs/examples/domains/create-record-alias.md | 18 + docs/examples/domains/create-record-caa.md | 18 + docs/examples/domains/create-record-cname.md | 18 + docs/examples/domains/create-record-https.md | 18 + docs/examples/domains/create-record-mx.md | 19 + docs/examples/domains/create-record-ns.md | 18 + docs/examples/domains/create-record-srv.md | 21 + docs/examples/domains/create-record-txt.md | 18 + docs/examples/domains/create.md | 15 + docs/examples/domains/delete-record.md | 15 + docs/examples/domains/delete.md | 14 + .../domains/get-preset-google-workspace.md | 14 + docs/examples/domains/get-preset-i-cloud.md | 14 + docs/examples/domains/get-preset-mailgun.md | 14 + docs/examples/domains/get-preset-outlook.md | 14 + .../domains/get-preset-proton-mail.md | 14 + docs/examples/domains/get-preset-zoho.md | 14 + docs/examples/domains/get-price.md | 16 + docs/examples/domains/get-record.md | 15 + docs/examples/domains/get-transfer-status.md | 14 + docs/examples/domains/get-zone.md | 14 + docs/examples/domains/get.md | 14 + docs/examples/domains/list-prices.md | 16 + docs/examples/domains/list-records.md | 15 + docs/examples/domains/list.md | 15 + docs/examples/domains/update-nameservers.md | 15 + docs/examples/domains/update-record-a.md | 19 + docs/examples/domains/update-record-aaaa.md | 19 + docs/examples/domains/update-record-alias.md | 19 + docs/examples/domains/update-record-caa.md | 19 + docs/examples/domains/update-record-cname.md | 19 + docs/examples/domains/update-record-https.md | 19 + docs/examples/domains/update-record-mx.md | 20 + docs/examples/domains/update-record-ns.md | 19 + docs/examples/domains/update-record-srv.md | 22 + docs/examples/domains/update-record-txt.md | 19 + docs/examples/domains/update-team.md | 15 + docs/examples/domains/update-zone.md | 15 + docs/examples/domains/verify-nameservers.md | 14 + docs/examples/functions/list-runtimes.md | 4 +- .../examples/functions/list-specifications.md | 1 + docs/examples/locale/list-codes.md | 4 +- docs/examples/locale/list-continents.md | 4 +- docs/examples/locale/list-countries-eu.md | 4 +- docs/examples/locale/list-countries-phones.md | 4 +- docs/examples/locale/list-countries.md | 4 +- docs/examples/locale/list-currencies.md | 4 +- docs/examples/locale/list-languages.md | 4 +- .../messaging/create-appwrite-provider.md | 18 + docs/examples/messaging/create-email.md | 2 + docs/examples/messaging/create-push.md | 1 + docs/examples/messaging/create-topic.md | 2 + .../messaging/update-appwrite-provider.md | 18 + docs/examples/messaging/update-email.md | 2 + docs/examples/messaging/update-push.md | 1 + docs/examples/messaging/update-topic.md | 2 + docs/examples/oauth2/introspect.md | 17 + .../create-ephemeral-project-key.md | 16 + .../organization/delete-project-key.md | 15 + docs/examples/organization/get-project-key.md | 15 + .../organization/list-project-keys.md | 16 + .../organization/update-project-key.md | 18 + .../project/create-android-platform.md | 1 + docs/examples/project/create-environment.md | 15 + docs/examples/project/delete-environment.md | 14 + docs/examples/project/get-environment.md | 14 + docs/examples/project/list-environments.md | 15 + .../project/update-android-platform.md | 1 + docs/examples/project/update-environment.md | 15 + .../examples/project/update-o-auth-2-apple.md | 2 + .../project/update-o-auth-2-auth-0.md | 1 + .../project/update-o-auth-2-discord.md | 1 + .../project/update-o-auth-2-git-hub.md | 1 + .../project/update-o-auth-2-google.md | 2 + .../examples/project/update-o-auth-2-kakao.md | 17 + .../project/update-o-auth-2-microsoft.md | 1 + docs/examples/project/update-o-auth-2-okta.md | 1 + .../project/update-o-auth-2-salesforce.md | 1 + .../project/update-o-auth-2-tik-tok.md | 16 + .../project/update-o-auth-2-webflow.md | 16 + docs/examples/project/update-o-auth-2-zoho.md | 1 + .../project/update-password-pwned-policy.md | 16 + .../update-password-rotation-policy.md | 15 + docs/examples/sites/list-frameworks.md | 4 +- docs/examples/sites/list-specifications.md | 1 + docs/examples/storage/get-file-preview.md | 2 +- docs/examples/tablesdb/list-transactions.md | 1 + docs/examples/teams/create-membership.md | 1 + docs/examples/vectorsdb/list-transactions.md | 1 + docs/examples/waf/create-bypass-rule.md | 21 + docs/examples/waf/create-challenge-rule.md | 24 + docs/examples/waf/create-deny-rule.md | 21 + docs/examples/waf/create-rate-limit-rule.md | 26 + docs/examples/waf/create-redirect-rule.md | 23 + docs/examples/waf/delete-rule.md | 14 + docs/examples/waf/get-rule.md | 14 + docs/examples/waf/list-rules.md | 16 + docs/examples/waf/update-bypass-rule.md | 21 + docs/examples/waf/update-challenge-rule.md | 24 + docs/examples/waf/update-deny-rule.md | 21 + docs/examples/waf/update-rate-limit-rule.md | 25 + docs/examples/waf/update-redirect-rule.md | 23 + package-lock.json | 4 +- package.json | 2 +- src/client.ts | 8 +- src/enums/billing-plan-group.ts | 2 + src/enums/build-runtime.ts | 2 + src/enums/databases-index-type.ts | 1 + src/enums/domain-registration-type.ts | 6 + src/enums/domain-transfer-status-enum.ts | 10 + src/enums/framework.ts | 1 + src/enums/id-token-provider.ts | 4 + src/enums/image-gravity.ts | 1 + src/enums/o-auth-2-auth-0-prompt.ts | 5 + src/enums/o-auth-2-discord-prompt.ts | 4 + src/enums/o-auth-2-github-prompt.ts | 3 + src/enums/o-auth-2-kakao-prompt.ts | 6 + src/enums/o-auth-2-microsoft-prompt.ts | 6 + src/enums/o-auth-2-okta-prompt.ts | 5 + src/enums/o-auth-2-salesforce-prompt.ts | 4 + src/enums/o-auth-2-zoho-prompt.ts | 3 + src/enums/o-auth-provider.ts | 3 + src/enums/project-email-template-id.ts | 2 + src/enums/project-key-scopes.ts | 4 + src/enums/project-o-auth-2-auth-0-prompt.ts | 5 + src/enums/project-o-auth-2-discord-prompt.ts | 4 + src/enums/project-o-auth-2-git-hub-prompt.ts | 3 + src/enums/project-o-auth-2-kakao-prompt.ts | 6 + .../project-o-auth-2-microsoft-prompt.ts | 6 + src/enums/project-o-auth-2-okta-prompt.ts | 5 + .../project-o-auth-2-salesforce-prompt.ts | 4 + src/enums/project-o-auth-2-zoho-prompt.ts | 3 + src/enums/project-o-auth-provider-id.ts | 3 + src/enums/project-policy-id.ts | 2 + .../proxy-rule-deployment-resource-type.ts | 1 + src/enums/runtime.ts | 2 + src/enums/tables-db-index-type.ts | 1 + src/enums/waf-rule-action.ts | 7 + src/index.ts | 22 + src/models.ts | 1025 +++- src/services/account.ts | 550 +- src/services/avatars.ts | 114 +- src/services/databases.ts | 23 +- src/services/documents-db.ts | 23 +- src/services/domains.ts | 4647 +++++++++++++++++ src/services/functions.ts | 57 +- src/services/locale.ts | 240 +- src/services/messaging.ts | 393 +- src/services/oauth-2.ts | 105 + src/services/organization.ts | 446 ++ src/services/project.ts | 1089 +++- src/services/sites.ts | 57 +- src/services/tables-db.ts | 23 +- src/services/teams.ts | 22 +- src/services/vectors-db.ts | 23 +- src/services/waf.ts | 2137 ++++++++ test/services/account.test.js | 118 + test/services/avatars.test.js | 40 + test/services/domains.test.js | 1012 ++++ test/services/messaging.test.js | 42 + test/services/oauth2.test.js | 12 + test/services/organization.test.js | 98 + test/services/project.test.js | 268 +- test/services/waf.test.js | 354 ++ 185 files changed, 14457 insertions(+), 151 deletions(-) create mode 100644 docs/examples/account/create-email-verification-otp.md create mode 100644 docs/examples/account/create-id-token-session.md create mode 100644 docs/examples/account/create-recovery-otp.md create mode 100644 docs/examples/account/update-email-verification-otp.md create mode 100644 docs/examples/account/update-recovery-otp.md create mode 100644 docs/examples/avatars/delete-photo.md create mode 100644 docs/examples/avatars/update-photo.md create mode 100644 docs/examples/domains/create-preset-google-workspace.md create mode 100644 docs/examples/domains/create-preset-i-cloud.md create mode 100644 docs/examples/domains/create-preset-mailgun.md create mode 100644 docs/examples/domains/create-preset-outlook.md create mode 100644 docs/examples/domains/create-preset-proton-mail.md create mode 100644 docs/examples/domains/create-preset-zoho.md create mode 100644 docs/examples/domains/create-record-a.md create mode 100644 docs/examples/domains/create-record-aaaa.md create mode 100644 docs/examples/domains/create-record-alias.md create mode 100644 docs/examples/domains/create-record-caa.md create mode 100644 docs/examples/domains/create-record-cname.md create mode 100644 docs/examples/domains/create-record-https.md create mode 100644 docs/examples/domains/create-record-mx.md create mode 100644 docs/examples/domains/create-record-ns.md create mode 100644 docs/examples/domains/create-record-srv.md create mode 100644 docs/examples/domains/create-record-txt.md create mode 100644 docs/examples/domains/create.md create mode 100644 docs/examples/domains/delete-record.md create mode 100644 docs/examples/domains/delete.md create mode 100644 docs/examples/domains/get-preset-google-workspace.md create mode 100644 docs/examples/domains/get-preset-i-cloud.md create mode 100644 docs/examples/domains/get-preset-mailgun.md create mode 100644 docs/examples/domains/get-preset-outlook.md create mode 100644 docs/examples/domains/get-preset-proton-mail.md create mode 100644 docs/examples/domains/get-preset-zoho.md create mode 100644 docs/examples/domains/get-price.md create mode 100644 docs/examples/domains/get-record.md create mode 100644 docs/examples/domains/get-transfer-status.md create mode 100644 docs/examples/domains/get-zone.md create mode 100644 docs/examples/domains/get.md create mode 100644 docs/examples/domains/list-prices.md create mode 100644 docs/examples/domains/list-records.md create mode 100644 docs/examples/domains/list.md create mode 100644 docs/examples/domains/update-nameservers.md create mode 100644 docs/examples/domains/update-record-a.md create mode 100644 docs/examples/domains/update-record-aaaa.md create mode 100644 docs/examples/domains/update-record-alias.md create mode 100644 docs/examples/domains/update-record-caa.md create mode 100644 docs/examples/domains/update-record-cname.md create mode 100644 docs/examples/domains/update-record-https.md create mode 100644 docs/examples/domains/update-record-mx.md create mode 100644 docs/examples/domains/update-record-ns.md create mode 100644 docs/examples/domains/update-record-srv.md create mode 100644 docs/examples/domains/update-record-txt.md create mode 100644 docs/examples/domains/update-team.md create mode 100644 docs/examples/domains/update-zone.md create mode 100644 docs/examples/domains/verify-nameservers.md create mode 100644 docs/examples/messaging/create-appwrite-provider.md create mode 100644 docs/examples/messaging/update-appwrite-provider.md create mode 100644 docs/examples/oauth2/introspect.md create mode 100644 docs/examples/organization/create-ephemeral-project-key.md create mode 100644 docs/examples/organization/delete-project-key.md create mode 100644 docs/examples/organization/get-project-key.md create mode 100644 docs/examples/organization/list-project-keys.md create mode 100644 docs/examples/organization/update-project-key.md create mode 100644 docs/examples/project/create-environment.md create mode 100644 docs/examples/project/delete-environment.md create mode 100644 docs/examples/project/get-environment.md create mode 100644 docs/examples/project/list-environments.md create mode 100644 docs/examples/project/update-environment.md create mode 100644 docs/examples/project/update-o-auth-2-kakao.md create mode 100644 docs/examples/project/update-o-auth-2-tik-tok.md create mode 100644 docs/examples/project/update-o-auth-2-webflow.md create mode 100644 docs/examples/project/update-password-pwned-policy.md create mode 100644 docs/examples/project/update-password-rotation-policy.md create mode 100644 docs/examples/waf/create-bypass-rule.md create mode 100644 docs/examples/waf/create-challenge-rule.md create mode 100644 docs/examples/waf/create-deny-rule.md create mode 100644 docs/examples/waf/create-rate-limit-rule.md create mode 100644 docs/examples/waf/create-redirect-rule.md create mode 100644 docs/examples/waf/delete-rule.md create mode 100644 docs/examples/waf/get-rule.md create mode 100644 docs/examples/waf/list-rules.md create mode 100644 docs/examples/waf/update-bypass-rule.md create mode 100644 docs/examples/waf/update-challenge-rule.md create mode 100644 docs/examples/waf/update-deny-rule.md create mode 100644 docs/examples/waf/update-rate-limit-rule.md create mode 100644 docs/examples/waf/update-redirect-rule.md create mode 100644 src/enums/domain-registration-type.ts create mode 100644 src/enums/domain-transfer-status-enum.ts create mode 100644 src/enums/id-token-provider.ts create mode 100644 src/enums/o-auth-2-auth-0-prompt.ts create mode 100644 src/enums/o-auth-2-discord-prompt.ts create mode 100644 src/enums/o-auth-2-github-prompt.ts create mode 100644 src/enums/o-auth-2-kakao-prompt.ts create mode 100644 src/enums/o-auth-2-microsoft-prompt.ts create mode 100644 src/enums/o-auth-2-okta-prompt.ts create mode 100644 src/enums/o-auth-2-salesforce-prompt.ts create mode 100644 src/enums/o-auth-2-zoho-prompt.ts create mode 100644 src/enums/project-o-auth-2-auth-0-prompt.ts create mode 100644 src/enums/project-o-auth-2-discord-prompt.ts create mode 100644 src/enums/project-o-auth-2-git-hub-prompt.ts create mode 100644 src/enums/project-o-auth-2-kakao-prompt.ts create mode 100644 src/enums/project-o-auth-2-microsoft-prompt.ts create mode 100644 src/enums/project-o-auth-2-okta-prompt.ts create mode 100644 src/enums/project-o-auth-2-salesforce-prompt.ts create mode 100644 src/enums/project-o-auth-2-zoho-prompt.ts create mode 100644 src/enums/waf-rule-action.ts create mode 100644 src/services/domains.ts create mode 100644 src/services/waf.ts create mode 100644 test/services/domains.test.js create mode 100644 test/services/waf.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c92aafa..81d1ea4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Change Log +## 29.4.0 + +* Added: `domains` service to register, transfer and manage domains, DNS records, email presets and zones +* Added: `waf` service with bypass, challenge, deny, rate-limit and redirect rules +* Added: `account.createEmailVerificationOTP`, `updateEmailVerificationOTP`, `createRecoveryOTP` and `updateRecoveryOTP` +* Added: `account.createIdTokenSession` and `Identity.providerIdToken` +* Added: `oauth2.introspect` +* Added: project environments with `project.createEnvironment`, `getEnvironment`, `listEnvironments`, `updateEnvironment` and `deleteEnvironment` +* Added: `organization.createEphemeralProjectKey`, `listProjectKeys`, `getProjectKey`, `updateProjectKey` and `deleteProjectKey` +* Added: Kakao, TikTok and Webflow OAuth2 providers with `project.updateOAuth2Kakao`, `updateOAuth2TikTok` and `updateOAuth2Webflow` +* Added: optional `prompt` on the Auth0, Discord, GitHub, Microsoft, Okta, Salesforce and Zoho OAuth2 settings, and native client IDs on Apple and Google +* Added: `project.updatePasswordPwnedPolicy`, `project.updatePasswordRotationPolicy` and `User.passwordPwned` +* Added: `messaging.createAppwriteProvider` and `messaging.updateAppwriteProvider` +* Added: optional `replyToEmail` and `replyToName` on email messages, `channelId` on push messages, and `qos` and `expiry` on topics +* Added: `avatars.updatePhoto` and `avatars.deletePhoto` +* Added: optional `duration` on `account.createEmailPasswordSession`, `current` on `account.deleteSessions`, `membershipId` on `teams.createMembership` and `fingerprints` on Android platforms +* Added: optional `total` on the locale, transaction, runtime, specification and framework lists +* Added: `dart-3.13` and `flutter-3.47` runtimes, the `jaspr` framework, the `trigram` index type, `auto` image gravity, the `dedicatedDatabase` proxy rule resource type, OTP email templates and new key scopes +* Added: optional fields on `BillingPlan`, `DedicatedDatabase`, `DedicatedDatabaseSpecification`, `Project` and `Topic`, and `free` and `start` in `BillingPlanGroup` + ## 29.3.1 * Fixed: added `ProjectAuthMethodId.Passkey`, so `project.updateAuthMethod` can enable passkeys diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md index fcc1ff18..f6ce44a1 100644 --- a/docs/examples/account/create-email-password-session.md +++ b/docs/examples/account/create-email-password-session.md @@ -11,5 +11,6 @@ const account = new sdk.Account(client); const result = await account.createEmailPasswordSession({ email: 'email@example.com', password: 'password', + duration: 60, // optional }); ``` diff --git a/docs/examples/account/create-email-verification-otp.md b/docs/examples/account/create-email-verification-otp.md new file mode 100644 index 00000000..07f28610 --- /dev/null +++ b/docs/examples/account/create-email-verification-otp.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createEmailVerificationOTP({ + phrase: false, // optional +}); +``` diff --git a/docs/examples/account/create-id-token-session.md b/docs/examples/account/create-id-token-session.md new file mode 100644 index 00000000..39dcb8d3 --- /dev/null +++ b/docs/examples/account/create-id-token-session.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createIdTokenSession({ + provider: sdk.IdTokenProvider.Apple, + idToken: '', + nonce: '', // optional + accessToken: '', // optional + accessTokenExpiry: 0, // optional + name: '', // optional +}); +``` diff --git a/docs/examples/account/create-recovery-otp.md b/docs/examples/account/create-recovery-otp.md new file mode 100644 index 00000000..6c5d5376 --- /dev/null +++ b/docs/examples/account/create-recovery-otp.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createRecoveryOTP({ + email: 'email@example.com', + phrase: false, // optional +}); +``` diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md index 912575ce..d65f323d 100644 --- a/docs/examples/account/delete-sessions.md +++ b/docs/examples/account/delete-sessions.md @@ -8,5 +8,7 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.deleteSessions(); +const result = await account.deleteSessions({ + current: false, // optional +}); ``` diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md index 0bbd093e..a2d09601 100644 --- a/docs/examples/account/list-sessions.md +++ b/docs/examples/account/list-sessions.md @@ -8,5 +8,7 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.listSessions(); +const result = await account.listSessions({ + total: false, // optional +}); ``` diff --git a/docs/examples/account/update-email-verification-otp.md b/docs/examples/account/update-email-verification-otp.md new file mode 100644 index 00000000..82c8731b --- /dev/null +++ b/docs/examples/account/update-email-verification-otp.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updateEmailVerificationOTP({ + userId: '', + secret: '', +}); +``` diff --git a/docs/examples/account/update-recovery-otp.md b/docs/examples/account/update-recovery-otp.md new file mode 100644 index 00000000..29af5163 --- /dev/null +++ b/docs/examples/account/update-recovery-otp.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updateRecoveryOTP({ + userId: '', + secret: '', + password: 'password', +}); +``` diff --git a/docs/examples/avatars/delete-photo.md b/docs/examples/avatars/delete-photo.md new file mode 100644 index 00000000..7f36a1c3 --- /dev/null +++ b/docs/examples/avatars/delete-photo.md @@ -0,0 +1,12 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const avatars = new sdk.Avatars(client); + +const result = await avatars.deletePhoto(); +``` diff --git a/docs/examples/avatars/update-photo.md b/docs/examples/avatars/update-photo.md new file mode 100644 index 00000000..4e100e19 --- /dev/null +++ b/docs/examples/avatars/update-photo.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); +const { InputFile } = require('node-appwrite/file'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const avatars = new sdk.Avatars(client); + +const result = await avatars.updatePhoto({ + file: InputFile.fromPath('/path/to/file', 'filename'), +}); +``` diff --git a/docs/examples/databases/list-transactions.md b/docs/examples/databases/list-transactions.md index c3356828..2accdeaf 100644 --- a/docs/examples/databases/list-transactions.md +++ b/docs/examples/databases/list-transactions.md @@ -10,5 +10,6 @@ const databases = new sdk.Databases(client); const result = await databases.listTransactions({ queries: [], // optional + total: false, // optional }); ``` diff --git a/docs/examples/documentsdb/list-transactions.md b/docs/examples/documentsdb/list-transactions.md index 8bc66d4b..8ea781a1 100644 --- a/docs/examples/documentsdb/list-transactions.md +++ b/docs/examples/documentsdb/list-transactions.md @@ -10,5 +10,6 @@ const documentsDB = new sdk.DocumentsDB(client); const result = await documentsDB.listTransactions({ queries: [], // optional + total: false, // optional }); ``` diff --git a/docs/examples/domains/create-preset-google-workspace.md b/docs/examples/domains/create-preset-google-workspace.md new file mode 100644 index 00000000..2387d379 --- /dev/null +++ b/docs/examples/domains/create-preset-google-workspace.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createPresetGoogleWorkspace({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/create-preset-i-cloud.md b/docs/examples/domains/create-preset-i-cloud.md new file mode 100644 index 00000000..33e98837 --- /dev/null +++ b/docs/examples/domains/create-preset-i-cloud.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createPresetICloud({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/create-preset-mailgun.md b/docs/examples/domains/create-preset-mailgun.md new file mode 100644 index 00000000..3879a871 --- /dev/null +++ b/docs/examples/domains/create-preset-mailgun.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createPresetMailgun({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/create-preset-outlook.md b/docs/examples/domains/create-preset-outlook.md new file mode 100644 index 00000000..5001f2af --- /dev/null +++ b/docs/examples/domains/create-preset-outlook.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createPresetOutlook({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/create-preset-proton-mail.md b/docs/examples/domains/create-preset-proton-mail.md new file mode 100644 index 00000000..3e7271cf --- /dev/null +++ b/docs/examples/domains/create-preset-proton-mail.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createPresetProtonMail({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/create-preset-zoho.md b/docs/examples/domains/create-preset-zoho.md new file mode 100644 index 00000000..d5c3a9d3 --- /dev/null +++ b/docs/examples/domains/create-preset-zoho.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createPresetZoho({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/create-record-a.md b/docs/examples/domains/create-record-a.md new file mode 100644 index 00000000..79ea1b5a --- /dev/null +++ b/docs/examples/domains/create-record-a.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createRecordA({ + domainId: '', + name: '', + value: '', + ttl: 1, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/create-record-aaaa.md b/docs/examples/domains/create-record-aaaa.md new file mode 100644 index 00000000..67aac220 --- /dev/null +++ b/docs/examples/domains/create-record-aaaa.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createRecordAAAA({ + domainId: '', + name: '', + value: '', + ttl: 1, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/create-record-alias.md b/docs/examples/domains/create-record-alias.md new file mode 100644 index 00000000..c1212f81 --- /dev/null +++ b/docs/examples/domains/create-record-alias.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createRecordAlias({ + domainId: '', + name: '', + value: '', + ttl: 1, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/create-record-caa.md b/docs/examples/domains/create-record-caa.md new file mode 100644 index 00000000..4275ae40 --- /dev/null +++ b/docs/examples/domains/create-record-caa.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createRecordCAA({ + domainId: '', + name: '', + value: '', + ttl: 1, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/create-record-cname.md b/docs/examples/domains/create-record-cname.md new file mode 100644 index 00000000..6e56f1a4 --- /dev/null +++ b/docs/examples/domains/create-record-cname.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createRecordCNAME({ + domainId: '', + name: '', + value: '', + ttl: 1, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/create-record-https.md b/docs/examples/domains/create-record-https.md new file mode 100644 index 00000000..6bd9ed88 --- /dev/null +++ b/docs/examples/domains/create-record-https.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createRecordHTTPS({ + domainId: '', + name: '', + value: '', + ttl: 1, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/create-record-mx.md b/docs/examples/domains/create-record-mx.md new file mode 100644 index 00000000..dd2aabd9 --- /dev/null +++ b/docs/examples/domains/create-record-mx.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createRecordMX({ + domainId: '', + name: '', + value: '', + ttl: 1, + priority: 0, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/create-record-ns.md b/docs/examples/domains/create-record-ns.md new file mode 100644 index 00000000..33d3c969 --- /dev/null +++ b/docs/examples/domains/create-record-ns.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createRecordNS({ + domainId: '', + name: '', + value: '', + ttl: 1, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/create-record-srv.md b/docs/examples/domains/create-record-srv.md new file mode 100644 index 00000000..c1868c77 --- /dev/null +++ b/docs/examples/domains/create-record-srv.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createRecordSRV({ + domainId: '', + name: '', + value: '', + ttl: 1, + priority: 0, + weight: 0, + port: 0, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/create-record-txt.md b/docs/examples/domains/create-record-txt.md new file mode 100644 index 00000000..8cd90560 --- /dev/null +++ b/docs/examples/domains/create-record-txt.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.createRecordTXT({ + domainId: '', + name: '', + ttl: 1, + value: '', // optional + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/create.md b/docs/examples/domains/create.md new file mode 100644 index 00000000..1f99aa75 --- /dev/null +++ b/docs/examples/domains/create.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.create({ + teamId: '', + domain: 'example.com', +}); +``` diff --git a/docs/examples/domains/delete-record.md b/docs/examples/domains/delete-record.md new file mode 100644 index 00000000..86244ac3 --- /dev/null +++ b/docs/examples/domains/delete-record.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.deleteRecord({ + domainId: '', + recordId: '', +}); +``` diff --git a/docs/examples/domains/delete.md b/docs/examples/domains/delete.md new file mode 100644 index 00000000..94094fc0 --- /dev/null +++ b/docs/examples/domains/delete.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.delete({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/get-preset-google-workspace.md b/docs/examples/domains/get-preset-google-workspace.md new file mode 100644 index 00000000..c6fc1290 --- /dev/null +++ b/docs/examples/domains/get-preset-google-workspace.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.getPresetGoogleWorkspace({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/get-preset-i-cloud.md b/docs/examples/domains/get-preset-i-cloud.md new file mode 100644 index 00000000..354b5330 --- /dev/null +++ b/docs/examples/domains/get-preset-i-cloud.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.getPresetICloud({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/get-preset-mailgun.md b/docs/examples/domains/get-preset-mailgun.md new file mode 100644 index 00000000..fd12cb67 --- /dev/null +++ b/docs/examples/domains/get-preset-mailgun.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.getPresetMailgun({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/get-preset-outlook.md b/docs/examples/domains/get-preset-outlook.md new file mode 100644 index 00000000..ccfc1f4d --- /dev/null +++ b/docs/examples/domains/get-preset-outlook.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.getPresetOutlook({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/get-preset-proton-mail.md b/docs/examples/domains/get-preset-proton-mail.md new file mode 100644 index 00000000..0861b017 --- /dev/null +++ b/docs/examples/domains/get-preset-proton-mail.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.getPresetProtonMail({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/get-preset-zoho.md b/docs/examples/domains/get-preset-zoho.md new file mode 100644 index 00000000..7e02f27d --- /dev/null +++ b/docs/examples/domains/get-preset-zoho.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.getPresetZoho({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/get-price.md b/docs/examples/domains/get-price.md new file mode 100644 index 00000000..ff776755 --- /dev/null +++ b/docs/examples/domains/get-price.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.getPrice({ + domain: 'example.com', + periodYears: null, // optional + registrationType: sdk.DomainRegistrationType.New, // optional +}); +``` diff --git a/docs/examples/domains/get-record.md b/docs/examples/domains/get-record.md new file mode 100644 index 00000000..79d55e83 --- /dev/null +++ b/docs/examples/domains/get-record.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.getRecord({ + domainId: '', + recordId: '', +}); +``` diff --git a/docs/examples/domains/get-transfer-status.md b/docs/examples/domains/get-transfer-status.md new file mode 100644 index 00000000..288d6b96 --- /dev/null +++ b/docs/examples/domains/get-transfer-status.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.getTransferStatus({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/get-zone.md b/docs/examples/domains/get-zone.md new file mode 100644 index 00000000..f05ee246 --- /dev/null +++ b/docs/examples/domains/get-zone.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.getZone({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/get.md b/docs/examples/domains/get.md new file mode 100644 index 00000000..3b73d8f8 --- /dev/null +++ b/docs/examples/domains/get.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.get({ + domainId: '', +}); +``` diff --git a/docs/examples/domains/list-prices.md b/docs/examples/domains/list-prices.md new file mode 100644 index 00000000..bcf35720 --- /dev/null +++ b/docs/examples/domains/list-prices.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.listPrices({ + domains: [], + periodYears: null, // optional + registrationType: sdk.DomainRegistrationType.New, // optional +}); +``` diff --git a/docs/examples/domains/list-records.md b/docs/examples/domains/list-records.md new file mode 100644 index 00000000..5cbab516 --- /dev/null +++ b/docs/examples/domains/list-records.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.listRecords({ + domainId: '', + queries: [], // optional +}); +``` diff --git a/docs/examples/domains/list.md b/docs/examples/domains/list.md new file mode 100644 index 00000000..8974554f --- /dev/null +++ b/docs/examples/domains/list.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.list({ + queries: [], // optional + search: '', // optional +}); +``` diff --git a/docs/examples/domains/update-nameservers.md b/docs/examples/domains/update-nameservers.md new file mode 100644 index 00000000..0f13aa57 --- /dev/null +++ b/docs/examples/domains/update-nameservers.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.updateNameservers({ + domainId: '', + nameservers: [], // optional +}); +``` diff --git a/docs/examples/domains/update-record-a.md b/docs/examples/domains/update-record-a.md new file mode 100644 index 00000000..b7fe113a --- /dev/null +++ b/docs/examples/domains/update-record-a.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.updateRecordA({ + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/update-record-aaaa.md b/docs/examples/domains/update-record-aaaa.md new file mode 100644 index 00000000..2fbd89a3 --- /dev/null +++ b/docs/examples/domains/update-record-aaaa.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.updateRecordAAAA({ + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/update-record-alias.md b/docs/examples/domains/update-record-alias.md new file mode 100644 index 00000000..9ecc5b0c --- /dev/null +++ b/docs/examples/domains/update-record-alias.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.updateRecordAlias({ + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/update-record-caa.md b/docs/examples/domains/update-record-caa.md new file mode 100644 index 00000000..3c260306 --- /dev/null +++ b/docs/examples/domains/update-record-caa.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.updateRecordCAA({ + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/update-record-cname.md b/docs/examples/domains/update-record-cname.md new file mode 100644 index 00000000..ba8de6a2 --- /dev/null +++ b/docs/examples/domains/update-record-cname.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.updateRecordCNAME({ + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/update-record-https.md b/docs/examples/domains/update-record-https.md new file mode 100644 index 00000000..66ce4ac3 --- /dev/null +++ b/docs/examples/domains/update-record-https.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.updateRecordHTTPS({ + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/update-record-mx.md b/docs/examples/domains/update-record-mx.md new file mode 100644 index 00000000..5d4383ea --- /dev/null +++ b/docs/examples/domains/update-record-mx.md @@ -0,0 +1,20 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.updateRecordMX({ + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + priority: 0, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/update-record-ns.md b/docs/examples/domains/update-record-ns.md new file mode 100644 index 00000000..3317ce0a --- /dev/null +++ b/docs/examples/domains/update-record-ns.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.updateRecordNS({ + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/update-record-srv.md b/docs/examples/domains/update-record-srv.md new file mode 100644 index 00000000..d81b1a89 --- /dev/null +++ b/docs/examples/domains/update-record-srv.md @@ -0,0 +1,22 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.updateRecordSRV({ + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + priority: 0, + weight: 0, + port: 0, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/update-record-txt.md b/docs/examples/domains/update-record-txt.md new file mode 100644 index 00000000..8417f85b --- /dev/null +++ b/docs/examples/domains/update-record-txt.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.updateRecordTXT({ + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // optional +}); +``` diff --git a/docs/examples/domains/update-team.md b/docs/examples/domains/update-team.md new file mode 100644 index 00000000..8193b7f4 --- /dev/null +++ b/docs/examples/domains/update-team.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.updateTeam({ + domainId: '', + teamId: '', +}); +``` diff --git a/docs/examples/domains/update-zone.md b/docs/examples/domains/update-zone.md new file mode 100644 index 00000000..e146266a --- /dev/null +++ b/docs/examples/domains/update-zone.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.updateZone({ + domainId: '', + content: '', +}); +``` diff --git a/docs/examples/domains/verify-nameservers.md b/docs/examples/domains/verify-nameservers.md new file mode 100644 index 00000000..d6cd0e2c --- /dev/null +++ b/docs/examples/domains/verify-nameservers.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const domains = new sdk.Domains(client); + +const result = await domains.verifyNameservers({ + domainId: '', +}); +``` diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md index fdaefd3a..4989aef0 100644 --- a/docs/examples/functions/list-runtimes.md +++ b/docs/examples/functions/list-runtimes.md @@ -8,5 +8,7 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.listRuntimes(); +const result = await functions.listRuntimes({ + total: false, // optional +}); ``` diff --git a/docs/examples/functions/list-specifications.md b/docs/examples/functions/list-specifications.md index f779206d..f2205c09 100644 --- a/docs/examples/functions/list-specifications.md +++ b/docs/examples/functions/list-specifications.md @@ -10,5 +10,6 @@ const functions = new sdk.Functions(client); const result = await functions.listSpecifications({ type: 'runtimes', // optional + total: false, // optional }); ``` diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md index 136992f4..0d173beb 100644 --- a/docs/examples/locale/list-codes.md +++ b/docs/examples/locale/list-codes.md @@ -8,5 +8,7 @@ const client = new sdk.Client() const locale = new sdk.Locale(client); -const result = await locale.listCodes(); +const result = await locale.listCodes({ + total: false, // optional +}); ``` diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md index aa58ec57..13a33454 100644 --- a/docs/examples/locale/list-continents.md +++ b/docs/examples/locale/list-continents.md @@ -8,5 +8,7 @@ const client = new sdk.Client() const locale = new sdk.Locale(client); -const result = await locale.listContinents(); +const result = await locale.listContinents({ + total: false, // optional +}); ``` diff --git a/docs/examples/locale/list-countries-eu.md b/docs/examples/locale/list-countries-eu.md index 538b4927..dbd873c4 100644 --- a/docs/examples/locale/list-countries-eu.md +++ b/docs/examples/locale/list-countries-eu.md @@ -8,5 +8,7 @@ const client = new sdk.Client() const locale = new sdk.Locale(client); -const result = await locale.listCountriesEU(); +const result = await locale.listCountriesEU({ + total: false, // optional +}); ``` diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md index c2701418..dee00d08 100644 --- a/docs/examples/locale/list-countries-phones.md +++ b/docs/examples/locale/list-countries-phones.md @@ -8,5 +8,7 @@ const client = new sdk.Client() const locale = new sdk.Locale(client); -const result = await locale.listCountriesPhones(); +const result = await locale.listCountriesPhones({ + total: false, // optional +}); ``` diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md index 99ee2d35..0b2bd5b8 100644 --- a/docs/examples/locale/list-countries.md +++ b/docs/examples/locale/list-countries.md @@ -8,5 +8,7 @@ const client = new sdk.Client() const locale = new sdk.Locale(client); -const result = await locale.listCountries(); +const result = await locale.listCountries({ + total: false, // optional +}); ``` diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md index c381774d..07ae165a 100644 --- a/docs/examples/locale/list-currencies.md +++ b/docs/examples/locale/list-currencies.md @@ -8,5 +8,7 @@ const client = new sdk.Client() const locale = new sdk.Locale(client); -const result = await locale.listCurrencies(); +const result = await locale.listCurrencies({ + total: false, // optional +}); ``` diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md index cfd522c6..9f48ffb4 100644 --- a/docs/examples/locale/list-languages.md +++ b/docs/examples/locale/list-languages.md @@ -8,5 +8,7 @@ const client = new sdk.Client() const locale = new sdk.Locale(client); -const result = await locale.listLanguages(); +const result = await locale.listLanguages({ + total: false, // optional +}); ``` diff --git a/docs/examples/messaging/create-appwrite-provider.md b/docs/examples/messaging/create-appwrite-provider.md new file mode 100644 index 00000000..0ad3b75d --- /dev/null +++ b/docs/examples/messaging/create-appwrite-provider.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const messaging = new sdk.Messaging(client); + +const result = await messaging.createAppwriteProvider({ + providerId: '', + name: '', + enabled: false, // optional + qos: 0, // optional + expiry: 0, // optional +}); +``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index c979b47c..256234c8 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -21,5 +21,7 @@ const result = await messaging.createEmail({ draft: false, // optional html: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional + replyToEmail: 'email@example.com', // optional + replyToName: '', // optional }); ``` diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index 6e2fd140..46436b33 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -28,5 +28,6 @@ const result = await messaging.createPush({ contentAvailable: false, // optional critical: false, // optional priority: sdk.MessagePriority.Normal, // optional + channelId: '', // optional }); ``` diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md index 5a05064e..0a4b2926 100644 --- a/docs/examples/messaging/create-topic.md +++ b/docs/examples/messaging/create-topic.md @@ -12,5 +12,7 @@ const result = await messaging.createTopic({ topicId: '', name: '', subscribe: ['any'], // optional + qos: 0, // optional + expiry: 0, // optional }); ``` diff --git a/docs/examples/messaging/update-appwrite-provider.md b/docs/examples/messaging/update-appwrite-provider.md new file mode 100644 index 00000000..b41d18f0 --- /dev/null +++ b/docs/examples/messaging/update-appwrite-provider.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const messaging = new sdk.Messaging(client); + +const result = await messaging.updateAppwriteProvider({ + providerId: '', + name: '', // optional + enabled: false, // optional + qos: 0, // optional + expiry: 0, // optional +}); +``` diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index aaf9d751..0fc7a9a2 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -21,5 +21,7 @@ const result = await messaging.updateEmail({ bcc: [], // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional attachments: [], // optional + replyToEmail: 'email@example.com', // optional + replyToName: '', // optional }); ``` diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index cf8f6f1b..5d0e6b73 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -28,5 +28,6 @@ const result = await messaging.updatePush({ contentAvailable: false, // optional critical: false, // optional priority: sdk.MessagePriority.Normal, // optional + channelId: '', // optional }); ``` diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md index 2397220a..292b3b6a 100644 --- a/docs/examples/messaging/update-topic.md +++ b/docs/examples/messaging/update-topic.md @@ -12,5 +12,7 @@ const result = await messaging.updateTopic({ topicId: '', name: '', // optional subscribe: ['any'], // optional + qos: 0, // optional + expiry: 0, // optional }); ``` diff --git a/docs/examples/oauth2/introspect.md b/docs/examples/oauth2/introspect.md new file mode 100644 index 00000000..5845699b --- /dev/null +++ b/docs/examples/oauth2/introspect.md @@ -0,0 +1,17 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const oauth2 = new sdk.Oauth2(client); + +const result = await oauth2.introspect({ + token: '', + tokenTypeHint: 'access_token', // optional + clientId: '', // optional + clientSecret: '', // optional +}); +``` diff --git a/docs/examples/organization/create-ephemeral-project-key.md b/docs/examples/organization/create-ephemeral-project-key.md new file mode 100644 index 00000000..cf080c77 --- /dev/null +++ b/docs/examples/organization/create-ephemeral-project-key.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const organization = new sdk.Organization(client); + +const result = await organization.createEphemeralProjectKey({ + projectId: '', + scopes: [sdk.ProjectKeyScopes.UsersRead], + duration: 600, +}); +``` diff --git a/docs/examples/organization/delete-project-key.md b/docs/examples/organization/delete-project-key.md new file mode 100644 index 00000000..1e6db3c7 --- /dev/null +++ b/docs/examples/organization/delete-project-key.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const organization = new sdk.Organization(client); + +const result = await organization.deleteProjectKey({ + projectId: '', + keyId: '', +}); +``` diff --git a/docs/examples/organization/get-project-key.md b/docs/examples/organization/get-project-key.md new file mode 100644 index 00000000..23171a6a --- /dev/null +++ b/docs/examples/organization/get-project-key.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const organization = new sdk.Organization(client); + +const result = await organization.getProjectKey({ + projectId: '', + keyId: '', +}); +``` diff --git a/docs/examples/organization/list-project-keys.md b/docs/examples/organization/list-project-keys.md new file mode 100644 index 00000000..74487441 --- /dev/null +++ b/docs/examples/organization/list-project-keys.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const organization = new sdk.Organization(client); + +const result = await organization.listProjectKeys({ + projectId: '', + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/organization/update-project-key.md b/docs/examples/organization/update-project-key.md new file mode 100644 index 00000000..07440b6e --- /dev/null +++ b/docs/examples/organization/update-project-key.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const organization = new sdk.Organization(client); + +const result = await organization.updateProjectKey({ + projectId: '', + keyId: '', + name: '', + scopes: [sdk.ProjectKeyScopes.UsersRead], + expire: '2020-10-15T06:38:00.000+00:00', // optional +}); +``` diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md index 083eee14..8e0d6f77 100644 --- a/docs/examples/project/create-android-platform.md +++ b/docs/examples/project/create-android-platform.md @@ -12,5 +12,6 @@ const result = await project.createAndroidPlatform({ platformId: '', name: '', applicationId: '', + fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/create-environment.md b/docs/examples/project/create-environment.md new file mode 100644 index 00000000..c0add3b7 --- /dev/null +++ b/docs/examples/project/create-environment.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.createEnvironment({ + environmentId: '', + name: '', +}); +``` diff --git a/docs/examples/project/delete-environment.md b/docs/examples/project/delete-environment.md new file mode 100644 index 00000000..5400831f --- /dev/null +++ b/docs/examples/project/delete-environment.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.deleteEnvironment({ + environmentId: '', +}); +``` diff --git a/docs/examples/project/get-environment.md b/docs/examples/project/get-environment.md new file mode 100644 index 00000000..417f5c88 --- /dev/null +++ b/docs/examples/project/get-environment.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.getEnvironment({ + environmentId: '', +}); +``` diff --git a/docs/examples/project/list-environments.md b/docs/examples/project/list-environments.md new file mode 100644 index 00000000..88d3d57a --- /dev/null +++ b/docs/examples/project/list-environments.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.listEnvironments({ + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md index ad0d3d28..83d4d651 100644 --- a/docs/examples/project/update-android-platform.md +++ b/docs/examples/project/update-android-platform.md @@ -12,5 +12,6 @@ const result = await project.updateAndroidPlatform({ platformId: '', name: '', applicationId: '', + fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/update-environment.md b/docs/examples/project/update-environment.md new file mode 100644 index 00000000..14bb9a80 --- /dev/null +++ b/docs/examples/project/update-environment.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateEnvironment({ + environmentId: '', + name: '', +}); +``` diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md index 7c6f5590..e1392e05 100644 --- a/docs/examples/project/update-o-auth-2-apple.md +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -14,5 +14,7 @@ const result = await project.updateOAuth2Apple({ teamId: '', // optional p8File: '', // optional enabled: false, // optional + nativeClientIds: [], // optional + nativeEnabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md index d23fb2c5..79ba89df 100644 --- a/docs/examples/project/update-o-auth-2-auth-0.md +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -13,5 +13,6 @@ const result = await project.updateOAuth2Auth0({ clientSecret: '', // optional endpoint: '', // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2Auth0Prompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md index 151b93c1..a8d5282e 100644 --- a/docs/examples/project/update-o-auth-2-discord.md +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -12,5 +12,6 @@ const result = await project.updateOAuth2Discord({ clientId: '', // optional clientSecret: '', // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2DiscordPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md index 0a7a757d..8d3fbdd8 100644 --- a/docs/examples/project/update-o-auth-2-git-hub.md +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -12,5 +12,6 @@ const result = await project.updateOAuth2GitHub({ clientId: '', // optional clientSecret: '', // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2GitHubPrompt.SelectAccount], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md index 17696bf7..fc081aa3 100644 --- a/docs/examples/project/update-o-auth-2-google.md +++ b/docs/examples/project/update-o-auth-2-google.md @@ -13,5 +13,7 @@ const result = await project.updateOAuth2Google({ clientSecret: '', // optional prompt: [sdk.ProjectOAuth2GooglePrompt.None], // optional enabled: false, // optional + nativeClientIds: [], // optional + nativeEnabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md new file mode 100644 index 00000000..cb310ae3 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -0,0 +1,17 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateOAuth2Kakao({ + clientId: '', // optional + clientSecret: '', // optional + prompt: [sdk.ProjectOAuth2KakaoPrompt.None], // optional + enabled: false, // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md index 29e18697..2cb3efe1 100644 --- a/docs/examples/project/update-o-auth-2-microsoft.md +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -13,5 +13,6 @@ const result = await project.updateOAuth2Microsoft({ applicationSecret: '', // optional tenant: '', // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2MicrosoftPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md index 519f0265..7f0052b3 100644 --- a/docs/examples/project/update-o-auth-2-okta.md +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -14,5 +14,6 @@ const result = await project.updateOAuth2Okta({ domain: 'example.com', // optional authorizationServerId: '', // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2OktaPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md index 642249f1..ffd57c0d 100644 --- a/docs/examples/project/update-o-auth-2-salesforce.md +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -12,5 +12,6 @@ const result = await project.updateOAuth2Salesforce({ customerKey: '', // optional customerSecret: '', // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2SalesforcePrompt.Login], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-tik-tok.md b/docs/examples/project/update-o-auth-2-tik-tok.md new file mode 100644 index 00000000..dd7d2e8d --- /dev/null +++ b/docs/examples/project/update-o-auth-2-tik-tok.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateOAuth2TikTok({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false, // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-webflow.md b/docs/examples/project/update-o-auth-2-webflow.md new file mode 100644 index 00000000..daf2e307 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-webflow.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateOAuth2Webflow({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false, // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md index 8b623cd8..2ccc10d7 100644 --- a/docs/examples/project/update-o-auth-2-zoho.md +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -12,5 +12,6 @@ const result = await project.updateOAuth2Zoho({ clientId: '', // optional clientSecret: '', // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2ZohoPrompt.Consent], // optional }); ``` diff --git a/docs/examples/project/update-password-pwned-policy.md b/docs/examples/project/update-password-pwned-policy.md new file mode 100644 index 00000000..df89b350 --- /dev/null +++ b/docs/examples/project/update-password-pwned-policy.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updatePasswordPwnedPolicy({ + enabled: false, // optional + sessions: false, // optional + users: false, // optional +}); +``` diff --git a/docs/examples/project/update-password-rotation-policy.md b/docs/examples/project/update-password-rotation-policy.md new file mode 100644 index 00000000..b6d281e6 --- /dev/null +++ b/docs/examples/project/update-password-rotation-policy.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updatePasswordRotationPolicy({ + enabled: false, // optional + maxAge: 86400, // optional +}); +``` diff --git a/docs/examples/sites/list-frameworks.md b/docs/examples/sites/list-frameworks.md index 9a417bfd..774d280f 100644 --- a/docs/examples/sites/list-frameworks.md +++ b/docs/examples/sites/list-frameworks.md @@ -8,5 +8,7 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.listFrameworks(); +const result = await sites.listFrameworks({ + total: false, // optional +}); ``` diff --git a/docs/examples/sites/list-specifications.md b/docs/examples/sites/list-specifications.md index 85a1a84f..87575708 100644 --- a/docs/examples/sites/list-specifications.md +++ b/docs/examples/sites/list-specifications.md @@ -10,5 +10,6 @@ const sites = new sdk.Sites(client); const result = await sites.listSpecifications({ type: 'runtimes', // optional + total: false, // optional }); ``` diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index 5e13a0ba..d3447ea2 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -13,7 +13,7 @@ const result = await storage.getFilePreview({ fileId: '', width: 0, // optional height: 0, // optional - gravity: sdk.ImageGravity.Center, // optional + gravity: sdk.ImageGravity.Auto, // optional quality: -1, // optional borderWidth: 0, // optional borderColor: 'FFFFFF', // optional diff --git a/docs/examples/tablesdb/list-transactions.md b/docs/examples/tablesdb/list-transactions.md index 51a3fc45..9a3778bd 100644 --- a/docs/examples/tablesdb/list-transactions.md +++ b/docs/examples/tablesdb/list-transactions.md @@ -10,5 +10,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.listTransactions({ queries: [], // optional + total: false, // optional }); ``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 3aa45e3b..b447dc44 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -16,5 +16,6 @@ const result = await teams.createMembership({ phone: '+12065550100', // optional url: 'https://example.com', // optional name: '', // optional + membershipId: '', // optional }); ``` diff --git a/docs/examples/vectorsdb/list-transactions.md b/docs/examples/vectorsdb/list-transactions.md index 3dfb2732..330f8eec 100644 --- a/docs/examples/vectorsdb/list-transactions.md +++ b/docs/examples/vectorsdb/list-transactions.md @@ -10,5 +10,6 @@ const vectorsDB = new sdk.VectorsDB(client); const result = await vectorsDB.listTransactions({ queries: [], // optional + total: false, // optional }); ``` diff --git a/docs/examples/waf/create-bypass-rule.md b/docs/examples/waf/create-bypass-rule.md new file mode 100644 index 00000000..36ac2369 --- /dev/null +++ b/docs/examples/waf/create-bypass-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createBypassRule({ + ruleId: '', + resourceType: 'api', + name: '', + resourceId: '', // optional + description: '', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md new file mode 100644 index 00000000..8a52e554 --- /dev/null +++ b/docs/examples/waf/create-challenge-rule.md @@ -0,0 +1,24 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createChallengeRule({ + ruleId: '', + resourceType: 'api', + name: '', + resourceId: '', // optional + description: '', // optional + challengeType: 'compute', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional + difficulty: 1, // optional + ttl: 900, // optional +}); +``` diff --git a/docs/examples/waf/create-deny-rule.md b/docs/examples/waf/create-deny-rule.md new file mode 100644 index 00000000..2fd6fdc3 --- /dev/null +++ b/docs/examples/waf/create-deny-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createDenyRule({ + ruleId: '', + resourceType: 'api', + name: '', + resourceId: '', // optional + description: '', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-rate-limit-rule.md b/docs/examples/waf/create-rate-limit-rule.md new file mode 100644 index 00000000..d40cd0be --- /dev/null +++ b/docs/examples/waf/create-rate-limit-rule.md @@ -0,0 +1,26 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createRateLimitRule({ + ruleId: '', + resourceType: 'api', + name: '', + limit: 1, + interval: 1, + resourceId: '', // optional + description: '', // optional + key: 'ip', // optional + strategy: 'fixedWindow', // optional + maxBucketSize: 1, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-redirect-rule.md b/docs/examples/waf/create-redirect-rule.md new file mode 100644 index 00000000..d606bc94 --- /dev/null +++ b/docs/examples/waf/create-redirect-rule.md @@ -0,0 +1,23 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createRedirectRule({ + ruleId: '', + resourceType: 'api', + name: '', + location: '', + statusCode: 300, + resourceId: '', // optional + description: '', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/delete-rule.md b/docs/examples/waf/delete-rule.md new file mode 100644 index 00000000..3b080632 --- /dev/null +++ b/docs/examples/waf/delete-rule.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.deleteRule({ + ruleId: '', +}); +``` diff --git a/docs/examples/waf/get-rule.md b/docs/examples/waf/get-rule.md new file mode 100644 index 00000000..5d4bbe14 --- /dev/null +++ b/docs/examples/waf/get-rule.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.getRule({ + ruleId: '', +}); +``` diff --git a/docs/examples/waf/list-rules.md b/docs/examples/waf/list-rules.md new file mode 100644 index 00000000..eef8e174 --- /dev/null +++ b/docs/examples/waf/list-rules.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.listRules({ + queries: [], // optional + search: '', // optional + total: false, // optional +}); +``` diff --git a/docs/examples/waf/update-bypass-rule.md b/docs/examples/waf/update-bypass-rule.md new file mode 100644 index 00000000..9fa71c1b --- /dev/null +++ b/docs/examples/waf/update-bypass-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateBypassRule({ + ruleId: '', + resourceType: 'api', // optional + resourceId: '', // optional + name: '', // optional + description: '', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-challenge-rule.md b/docs/examples/waf/update-challenge-rule.md new file mode 100644 index 00000000..a5f85ba0 --- /dev/null +++ b/docs/examples/waf/update-challenge-rule.md @@ -0,0 +1,24 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateChallengeRule({ + ruleId: '', + resourceType: 'api', // optional + resourceId: '', // optional + name: '', // optional + description: '', // optional + challengeType: 'compute', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional + difficulty: 1, // optional + ttl: 900, // optional +}); +``` diff --git a/docs/examples/waf/update-deny-rule.md b/docs/examples/waf/update-deny-rule.md new file mode 100644 index 00000000..2764b4c9 --- /dev/null +++ b/docs/examples/waf/update-deny-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateDenyRule({ + ruleId: '', + resourceType: 'api', // optional + resourceId: '', // optional + name: '', // optional + description: '', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-rate-limit-rule.md b/docs/examples/waf/update-rate-limit-rule.md new file mode 100644 index 00000000..f7810bdf --- /dev/null +++ b/docs/examples/waf/update-rate-limit-rule.md @@ -0,0 +1,25 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateRateLimitRule({ + ruleId: '', + resourceType: 'api', // optional + resourceId: '', // optional + name: '', // optional + description: '', // optional + limit: 1, // optional + interval: 1, // optional + key: 'ip', // optional + maxBucketSize: 1, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-redirect-rule.md b/docs/examples/waf/update-redirect-rule.md new file mode 100644 index 00000000..7355421a --- /dev/null +++ b/docs/examples/waf/update-redirect-rule.md @@ -0,0 +1,23 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateRedirectRule({ + ruleId: '', + resourceType: 'api', // optional + resourceId: '', // optional + name: '', // optional + description: '', // optional + location: '', // optional + statusCode: 300, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/package-lock.json b/package-lock.json index 88ab12f3..a16b8cdd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-appwrite", - "version": "29.3.1", + "version": "29.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-appwrite", - "version": "29.3.1", + "version": "29.4.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0", diff --git a/package.json b/package.json index 37c0ee27..852c8b66 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "29.3.1", + "version": "29.4.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 05cfcee8..491e1a43 100644 --- a/src/client.ts +++ b/src/client.ts @@ -80,7 +80,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/29.3.1'; + let ua = 'AppwriteNodeJSSDK/29.4.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -142,7 +142,7 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '29.3.1', + 'x-sdk-version': '29.4.0', 'user-agent': getUserAgent(), 'X-Appwrite-Response-Format': '2.0.0', }; @@ -811,7 +811,9 @@ class Client { ); } - if ( + if (responseType === 'text' && response.status < 400) { + data = await response.text(); + } else if ( response.headers.get('content-type')?.includes('application/json') ) { data = JSONbig.parse(await response.text()); diff --git a/src/enums/billing-plan-group.ts b/src/enums/billing-plan-group.ts index e8cd15d8..83157aed 100644 --- a/src/enums/billing-plan-group.ts +++ b/src/enums/billing-plan-group.ts @@ -1,5 +1,7 @@ export enum BillingPlanGroup { Starter = 'starter', + Free = 'free', + Start = 'start', Pro = 'pro', Scale = 'scale', } diff --git a/src/enums/build-runtime.ts b/src/enums/build-runtime.ts index cad34c11..2dfd9c61 100644 --- a/src/enums/build-runtime.ts +++ b/src/enums/build-runtime.ts @@ -50,6 +50,7 @@ export enum BuildRuntime { Dart310 = 'dart-3.10', Dart311 = 'dart-3.11', Dart312 = 'dart-3.12', + Dart313 = 'dart-3.13', Dotnet60 = 'dotnet-6.0', Dotnet70 = 'dotnet-7.0', Dotnet80 = 'dotnet-8.0', @@ -92,4 +93,5 @@ export enum BuildRuntime { Flutter338 = 'flutter-3.38', Flutter341 = 'flutter-3.41', Flutter344 = 'flutter-3.44', + Flutter347 = 'flutter-3.47', } diff --git a/src/enums/databases-index-type.ts b/src/enums/databases-index-type.ts index e849833d..275668eb 100644 --- a/src/enums/databases-index-type.ts +++ b/src/enums/databases-index-type.ts @@ -3,4 +3,5 @@ export enum DatabasesIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', + Trigram = 'trigram', } diff --git a/src/enums/domain-registration-type.ts b/src/enums/domain-registration-type.ts new file mode 100644 index 00000000..4ef7f07a --- /dev/null +++ b/src/enums/domain-registration-type.ts @@ -0,0 +1,6 @@ +export enum DomainRegistrationType { + New = 'new', + Transfer = 'transfer', + Renewal = 'renewal', + Trade = 'trade', +} diff --git a/src/enums/domain-transfer-status-enum.ts b/src/enums/domain-transfer-status-enum.ts new file mode 100644 index 00000000..a9dbdd89 --- /dev/null +++ b/src/enums/domain-transfer-status-enum.ts @@ -0,0 +1,10 @@ +export enum DomainTransferStatusEnum { + Transferrable = 'transferrable', + NotTransferrable = 'not_transferrable', + PendingOwner = 'pending_owner', + PendingAdmin = 'pending_admin', + PendingRegistry = 'pending_registry', + Completed = 'completed', + Cancelled = 'cancelled', + ServiceUnavailable = 'service_unavailable', +} diff --git a/src/enums/framework.ts b/src/enums/framework.ts index 6173a0ef..65f4a87e 100644 --- a/src/enums/framework.ts +++ b/src/enums/framework.ts @@ -11,6 +11,7 @@ export enum Framework { Remix = 'remix', Lynx = 'lynx', Flutter = 'flutter', + Jaspr = 'jaspr', Reactnative = 'react-native', Vite = 'vite', Other = 'other', diff --git a/src/enums/id-token-provider.ts b/src/enums/id-token-provider.ts new file mode 100644 index 00000000..4f99708a --- /dev/null +++ b/src/enums/id-token-provider.ts @@ -0,0 +1,4 @@ +export enum IdTokenProvider { + Apple = 'apple', + Google = 'google', +} diff --git a/src/enums/image-gravity.ts b/src/enums/image-gravity.ts index a115f3a2..7b269c31 100644 --- a/src/enums/image-gravity.ts +++ b/src/enums/image-gravity.ts @@ -1,4 +1,5 @@ export enum ImageGravity { + Auto = 'auto', Center = 'center', Topleft = 'top-left', Top = 'top', diff --git a/src/enums/o-auth-2-auth-0-prompt.ts b/src/enums/o-auth-2-auth-0-prompt.ts new file mode 100644 index 00000000..e015cae0 --- /dev/null +++ b/src/enums/o-auth-2-auth-0-prompt.ts @@ -0,0 +1,5 @@ +export enum OAuth2Auth0Prompt { + None = 'none', + Login = 'login', + Consent = 'consent', +} diff --git a/src/enums/o-auth-2-discord-prompt.ts b/src/enums/o-auth-2-discord-prompt.ts new file mode 100644 index 00000000..ece22e48 --- /dev/null +++ b/src/enums/o-auth-2-discord-prompt.ts @@ -0,0 +1,4 @@ +export enum OAuth2DiscordPrompt { + None = 'none', + Consent = 'consent', +} diff --git a/src/enums/o-auth-2-github-prompt.ts b/src/enums/o-auth-2-github-prompt.ts new file mode 100644 index 00000000..0519185f --- /dev/null +++ b/src/enums/o-auth-2-github-prompt.ts @@ -0,0 +1,3 @@ +export enum OAuth2GithubPrompt { + SelectAccount = 'select_account', +} diff --git a/src/enums/o-auth-2-kakao-prompt.ts b/src/enums/o-auth-2-kakao-prompt.ts new file mode 100644 index 00000000..2b5713a5 --- /dev/null +++ b/src/enums/o-auth-2-kakao-prompt.ts @@ -0,0 +1,6 @@ +export enum OAuth2KakaoPrompt { + None = 'none', + Login = 'login', + Create = 'create', + SelectAccount = 'select_account', +} diff --git a/src/enums/o-auth-2-microsoft-prompt.ts b/src/enums/o-auth-2-microsoft-prompt.ts new file mode 100644 index 00000000..53689659 --- /dev/null +++ b/src/enums/o-auth-2-microsoft-prompt.ts @@ -0,0 +1,6 @@ +export enum OAuth2MicrosoftPrompt { + None = 'none', + Login = 'login', + Consent = 'consent', + SelectAccount = 'select_account', +} diff --git a/src/enums/o-auth-2-okta-prompt.ts b/src/enums/o-auth-2-okta-prompt.ts new file mode 100644 index 00000000..8e279048 --- /dev/null +++ b/src/enums/o-auth-2-okta-prompt.ts @@ -0,0 +1,5 @@ +export enum OAuth2OktaPrompt { + None = 'none', + Login = 'login', + Consent = 'consent', +} diff --git a/src/enums/o-auth-2-salesforce-prompt.ts b/src/enums/o-auth-2-salesforce-prompt.ts new file mode 100644 index 00000000..131dd107 --- /dev/null +++ b/src/enums/o-auth-2-salesforce-prompt.ts @@ -0,0 +1,4 @@ +export enum OAuth2SalesforcePrompt { + Login = 'login', + Consent = 'consent', +} diff --git a/src/enums/o-auth-2-zoho-prompt.ts b/src/enums/o-auth-2-zoho-prompt.ts new file mode 100644 index 00000000..22ac9540 --- /dev/null +++ b/src/enums/o-auth-2-zoho-prompt.ts @@ -0,0 +1,3 @@ +export enum OAuth2ZohoPrompt { + Consent = 'consent', +} diff --git a/src/enums/o-auth-provider.ts b/src/enums/o-auth-provider.ts index 2d838dd4..3dab5fb3 100644 --- a/src/enums/o-auth-provider.ts +++ b/src/enums/o-auth-provider.ts @@ -21,6 +21,7 @@ export enum OAuthProvider { Gitlab = 'gitlab', Google = 'google', Huggingface = 'huggingface', + Kakao = 'kakao', Keycloak = 'keycloak', Kick = 'kick', Linkedin = 'linkedin', @@ -36,9 +37,11 @@ export enum OAuthProvider { Slack = 'slack', Spotify = 'spotify', Stripe = 'stripe', + Tiktok = 'tiktok', Tradeshift = 'tradeshift', TradeshiftBox = 'tradeshiftBox', Twitch = 'twitch', + Webflow = 'webflow', Wordpress = 'wordpress', X = 'x', Yahoo = 'yahoo', diff --git a/src/enums/project-email-template-id.ts b/src/enums/project-email-template-id.ts index c8ecbec4..be742ea3 100644 --- a/src/enums/project-email-template-id.ts +++ b/src/enums/project-email-template-id.ts @@ -6,4 +6,6 @@ export enum ProjectEmailTemplateId { MfaChallenge = 'mfaChallenge', SessionAlert = 'sessionAlert', OtpSession = 'otpSession', + OtpVerification = 'otpVerification', + OtpRecovery = 'otpRecovery', } diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts index e17dffdb..3cb8cc4f 100644 --- a/src/enums/project-key-scopes.ts +++ b/src/enums/project-key-scopes.ts @@ -89,6 +89,7 @@ export enum ProjectKeyScopes { WebhooksWrite = 'webhooks.write', LocaleRead = 'locale.read', AvatarsRead = 'avatars.read', + AvatarsWrite = 'avatars.write', HealthRead = 'health.read', AssistantRead = 'assistant.read', MigrationsRead = 'migrations.read', @@ -103,6 +104,7 @@ export enum ProjectKeyScopes { ReportsWrite = 'reports.write', PresencesRead = 'presences.read', PresencesWrite = 'presences.write', + DedicatedDatabasesExecute = 'dedicatedDatabases.execute', BackupsPoliciesRead = 'backups.policies.read', BackupsPoliciesWrite = 'backups.policies.write', ArchivesRead = 'archives.read', @@ -120,4 +122,6 @@ export enum ProjectKeyScopes { Oauth2Read = 'oauth2.read', Oauth2Write = 'oauth2.write', Oauth2Introspect = 'oauth2.introspect', + AnalyticsRead = 'analytics.read', + AnalyticsWrite = 'analytics.write', } diff --git a/src/enums/project-o-auth-2-auth-0-prompt.ts b/src/enums/project-o-auth-2-auth-0-prompt.ts new file mode 100644 index 00000000..a09f94f7 --- /dev/null +++ b/src/enums/project-o-auth-2-auth-0-prompt.ts @@ -0,0 +1,5 @@ +export enum ProjectOAuth2Auth0Prompt { + None = 'none', + Login = 'login', + Consent = 'consent', +} diff --git a/src/enums/project-o-auth-2-discord-prompt.ts b/src/enums/project-o-auth-2-discord-prompt.ts new file mode 100644 index 00000000..ec81b72b --- /dev/null +++ b/src/enums/project-o-auth-2-discord-prompt.ts @@ -0,0 +1,4 @@ +export enum ProjectOAuth2DiscordPrompt { + None = 'none', + Consent = 'consent', +} diff --git a/src/enums/project-o-auth-2-git-hub-prompt.ts b/src/enums/project-o-auth-2-git-hub-prompt.ts new file mode 100644 index 00000000..9abd5121 --- /dev/null +++ b/src/enums/project-o-auth-2-git-hub-prompt.ts @@ -0,0 +1,3 @@ +export enum ProjectOAuth2GitHubPrompt { + SelectAccount = 'select_account', +} diff --git a/src/enums/project-o-auth-2-kakao-prompt.ts b/src/enums/project-o-auth-2-kakao-prompt.ts new file mode 100644 index 00000000..6eae8b29 --- /dev/null +++ b/src/enums/project-o-auth-2-kakao-prompt.ts @@ -0,0 +1,6 @@ +export enum ProjectOAuth2KakaoPrompt { + None = 'none', + Login = 'login', + Create = 'create', + SelectAccount = 'select_account', +} diff --git a/src/enums/project-o-auth-2-microsoft-prompt.ts b/src/enums/project-o-auth-2-microsoft-prompt.ts new file mode 100644 index 00000000..27ff7b26 --- /dev/null +++ b/src/enums/project-o-auth-2-microsoft-prompt.ts @@ -0,0 +1,6 @@ +export enum ProjectOAuth2MicrosoftPrompt { + None = 'none', + Login = 'login', + Consent = 'consent', + SelectAccount = 'select_account', +} diff --git a/src/enums/project-o-auth-2-okta-prompt.ts b/src/enums/project-o-auth-2-okta-prompt.ts new file mode 100644 index 00000000..eedf1a01 --- /dev/null +++ b/src/enums/project-o-auth-2-okta-prompt.ts @@ -0,0 +1,5 @@ +export enum ProjectOAuth2OktaPrompt { + None = 'none', + Login = 'login', + Consent = 'consent', +} diff --git a/src/enums/project-o-auth-2-salesforce-prompt.ts b/src/enums/project-o-auth-2-salesforce-prompt.ts new file mode 100644 index 00000000..777d4a91 --- /dev/null +++ b/src/enums/project-o-auth-2-salesforce-prompt.ts @@ -0,0 +1,4 @@ +export enum ProjectOAuth2SalesforcePrompt { + Login = 'login', + Consent = 'consent', +} diff --git a/src/enums/project-o-auth-2-zoho-prompt.ts b/src/enums/project-o-auth-2-zoho-prompt.ts new file mode 100644 index 00000000..6f67a617 --- /dev/null +++ b/src/enums/project-o-auth-2-zoho-prompt.ts @@ -0,0 +1,3 @@ +export enum ProjectOAuth2ZohoPrompt { + Consent = 'consent', +} diff --git a/src/enums/project-o-auth-provider-id.ts b/src/enums/project-o-auth-provider-id.ts index f7cd133c..ddfc17c3 100644 --- a/src/enums/project-o-auth-provider-id.ts +++ b/src/enums/project-o-auth-provider-id.ts @@ -21,6 +21,7 @@ export enum ProjectOAuthProviderId { Gitlab = 'gitlab', Google = 'google', Huggingface = 'huggingface', + Kakao = 'kakao', Keycloak = 'keycloak', Kick = 'kick', Linkedin = 'linkedin', @@ -36,9 +37,11 @@ export enum ProjectOAuthProviderId { Slack = 'slack', Spotify = 'spotify', Stripe = 'stripe', + Tiktok = 'tiktok', Tradeshift = 'tradeshift', TradeshiftBox = 'tradeshiftBox', Twitch = 'twitch', + Webflow = 'webflow', Wordpress = 'wordpress', X = 'x', Yahoo = 'yahoo', diff --git a/src/enums/project-policy-id.ts b/src/enums/project-policy-id.ts index 79fccbfe..67fc5fe3 100644 --- a/src/enums/project-policy-id.ts +++ b/src/enums/project-policy-id.ts @@ -3,6 +3,8 @@ export enum ProjectPolicyId { Passwordhistory = 'password-history', Passwordstrength = 'password-strength', Passwordpersonaldata = 'password-personal-data', + Passwordpwned = 'password-pwned', + Passwordrotation = 'password-rotation', Sessionalert = 'session-alert', Sessionduration = 'session-duration', Sessioninvalidation = 'session-invalidation', diff --git a/src/enums/proxy-rule-deployment-resource-type.ts b/src/enums/proxy-rule-deployment-resource-type.ts index ef695072..2b1c942c 100644 --- a/src/enums/proxy-rule-deployment-resource-type.ts +++ b/src/enums/proxy-rule-deployment-resource-type.ts @@ -1,4 +1,5 @@ export enum ProxyRuleDeploymentResourceType { Function = 'function', Site = 'site', + DedicatedDatabase = 'dedicatedDatabase', } diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts index ecc4e827..7bbcbb6f 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -50,6 +50,7 @@ export enum Runtime { Dart310 = 'dart-3.10', Dart311 = 'dart-3.11', Dart312 = 'dart-3.12', + Dart313 = 'dart-3.13', Dotnet60 = 'dotnet-6.0', Dotnet70 = 'dotnet-7.0', Dotnet80 = 'dotnet-8.0', @@ -92,4 +93,5 @@ export enum Runtime { Flutter338 = 'flutter-3.38', Flutter341 = 'flutter-3.41', Flutter344 = 'flutter-3.44', + Flutter347 = 'flutter-3.47', } diff --git a/src/enums/tables-db-index-type.ts b/src/enums/tables-db-index-type.ts index 246bfc4a..09fd95c2 100644 --- a/src/enums/tables-db-index-type.ts +++ b/src/enums/tables-db-index-type.ts @@ -3,4 +3,5 @@ export enum TablesDBIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', + Trigram = 'trigram', } diff --git a/src/enums/waf-rule-action.ts b/src/enums/waf-rule-action.ts new file mode 100644 index 00000000..38534a93 --- /dev/null +++ b/src/enums/waf-rule-action.ts @@ -0,0 +1,7 @@ +export enum WafRuleAction { + Bypass = 'bypass', + Deny = 'deny', + Challenge = 'challenge', + RateLimit = 'rateLimit', + Redirect = 'redirect', +} diff --git a/src/index.ts b/src/index.ts index d63a2efc..bb482406 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,7 @@ export { Avatars } from './services/avatars'; export { Backups } from './services/backups'; export { Databases } from './services/databases'; export { DocumentsDB } from './services/documents-db'; +export { Domains } from './services/domains'; export { Embeddings } from './services/embeddings'; export { Functions } from './services/functions'; export { Graphql } from './services/graphql'; @@ -27,6 +28,7 @@ export { Teams } from './services/teams'; export { Tokens } from './services/tokens'; export { Users } from './services/users'; export { VectorsDB } from './services/vectors-db'; +export { Waf } from './services/waf'; export { Webhooks } from './services/webhooks'; export type { Models, Payload, UploadProgress } from './client'; export type { QueryTypes, QueryTypesList } from './query'; @@ -36,6 +38,7 @@ export { ID } from './id'; export { Operator, Condition } from './operator'; export { AuthenticatorType } from './enums/authenticator-type'; export { AuthenticationFactor } from './enums/authentication-factor'; +export { IdTokenProvider } from './enums/id-token-provider'; export { OAuthProvider } from './enums/o-auth-provider'; export { Browser } from './enums/browser'; export { CreditCard } from './enums/credit-card'; @@ -50,6 +53,7 @@ export { RelationMutate } from './enums/relation-mutate'; export { DatabasesIndexType } from './enums/databases-index-type'; export { OrderBy } from './enums/order-by'; export { DocumentsDBIndexType } from './enums/documents-db-index-type'; +export { DomainRegistrationType } from './enums/domain-registration-type'; export { EmbeddingModel } from './enums/embedding-model'; export { Runtime } from './enums/runtime'; export { ProjectKeyScopes } from './enums/project-key-scopes'; @@ -62,8 +66,16 @@ export { SmtpEncryption } from './enums/smtp-encryption'; export { OrganizationKeyScopes } from './enums/organization-key-scopes'; export { Region } from './enums/region'; export { ProjectAuthMethodId } from './enums/project-auth-method-id'; +export { ProjectOAuth2Auth0Prompt } from './enums/project-o-auth-2-auth-0-prompt'; +export { ProjectOAuth2DiscordPrompt } from './enums/project-o-auth-2-discord-prompt'; +export { ProjectOAuth2GitHubPrompt } from './enums/project-o-auth-2-git-hub-prompt'; export { ProjectOAuth2GooglePrompt } from './enums/project-o-auth-2-google-prompt'; +export { ProjectOAuth2KakaoPrompt } from './enums/project-o-auth-2-kakao-prompt'; +export { ProjectOAuth2MicrosoftPrompt } from './enums/project-o-auth-2-microsoft-prompt'; export { ProjectOAuth2OidcPrompt } from './enums/project-o-auth-2-oidc-prompt'; +export { ProjectOAuth2OktaPrompt } from './enums/project-o-auth-2-okta-prompt'; +export { ProjectOAuth2SalesforcePrompt } from './enums/project-o-auth-2-salesforce-prompt'; +export { ProjectOAuth2ZohoPrompt } from './enums/project-o-auth-2-zoho-prompt'; export { ProjectOAuthProviderId } from './enums/project-o-auth-provider-id'; export { ProjectPolicyId } from './enums/project-policy-id'; export { ProjectProtocolId } from './enums/project-protocol-id'; @@ -92,10 +104,20 @@ export { DeploymentStatus } from './enums/deployment-status'; export { ExecutionResourceType } from './enums/execution-resource-type'; export { ExecutionTrigger } from './enums/execution-trigger'; export { ExecutionStatus } from './enums/execution-status'; +export { OAuth2GithubPrompt } from './enums/o-auth-2-github-prompt'; +export { OAuth2DiscordPrompt } from './enums/o-auth-2-discord-prompt'; export { OAuth2GooglePrompt } from './enums/o-auth-2-google-prompt'; +export { OAuth2ZohoPrompt } from './enums/o-auth-2-zoho-prompt'; +export { OAuth2SalesforcePrompt } from './enums/o-auth-2-salesforce-prompt'; +export { OAuth2Auth0Prompt } from './enums/o-auth-2-auth-0-prompt'; export { OAuth2OidcPrompt } from './enums/o-auth-2-oidc-prompt'; +export { OAuth2OktaPrompt } from './enums/o-auth-2-okta-prompt'; +export { OAuth2MicrosoftPrompt } from './enums/o-auth-2-microsoft-prompt'; +export { OAuth2KakaoPrompt } from './enums/o-auth-2-kakao-prompt'; export { PlatformType } from './enums/platform-type'; export { ProxyRuleDeploymentResourceType } from './enums/proxy-rule-deployment-resource-type'; export { ProxyRuleStatus } from './enums/proxy-rule-status'; export { MessageStatus } from './enums/message-status'; export { BillingPlanGroup } from './enums/billing-plan-group'; +export { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; +export { WafRuleAction } from './enums/waf-rule-action'; diff --git a/src/models.ts b/src/models.ts index 26cbcfab..bd530f64 100644 --- a/src/models.ts +++ b/src/models.ts @@ -9,13 +9,23 @@ import { ExecutionStatus } from './enums/execution-status'; import { ProjectAuthMethodId } from './enums/project-auth-method-id'; import { ProjectServiceId } from './enums/project-service-id'; import { ProjectProtocolId } from './enums/project-protocol-id'; +import { OAuth2GithubPrompt } from './enums/o-auth-2-github-prompt'; +import { OAuth2DiscordPrompt } from './enums/o-auth-2-discord-prompt'; import { OAuth2GooglePrompt } from './enums/o-auth-2-google-prompt'; +import { OAuth2ZohoPrompt } from './enums/o-auth-2-zoho-prompt'; +import { OAuth2SalesforcePrompt } from './enums/o-auth-2-salesforce-prompt'; +import { OAuth2Auth0Prompt } from './enums/o-auth-2-auth-0-prompt'; import { OAuth2OidcPrompt } from './enums/o-auth-2-oidc-prompt'; +import { OAuth2OktaPrompt } from './enums/o-auth-2-okta-prompt'; +import { OAuth2MicrosoftPrompt } from './enums/o-auth-2-microsoft-prompt'; +import { OAuth2KakaoPrompt } from './enums/o-auth-2-kakao-prompt'; import { PlatformType } from './enums/platform-type'; import { ProxyRuleDeploymentResourceType } from './enums/proxy-rule-deployment-resource-type'; import { ProxyRuleStatus } from './enums/proxy-rule-status'; import { MessageStatus } from './enums/message-status'; import { BillingPlanGroup } from './enums/billing-plan-group'; +import { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; +import { WafRuleAction } from './enums/waf-rule-action'; /** * Appwrite Models @@ -507,6 +517,8 @@ export namespace Models { | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData + | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -3248,6 +3260,10 @@ export namespace Models { * Whether the user email is in its canonical form. */ emailIsCanonical?: boolean; + /** + * Whether the password was found in a known data breach the last time it was checked. Null when the password has never been checked. + */ + passwordPwned?: boolean | null; /** * Phone verification status. */ @@ -3388,6 +3404,110 @@ export namespace Models { threads: number; }; + /** + * Account + */ + export type Account< + Preferences extends Models.Preferences = Models.DefaultPreferences, + > = { + /** + * User ID. + */ + $id: string; + /** + * User creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * User update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * User name. + */ + name: string; + /** + * User registration date in ISO 8601 format. + */ + registration: string; + /** + * User status. Pass `true` for enabled and `false` for disabled. + */ + status: boolean; + /** + * Labels for the user. + */ + labels: string[]; + /** + * Password update time in ISO 8601 format. + */ + passwordUpdate: string; + /** + * User email address. + */ + email: string; + /** + * User phone number in E.164 format. + */ + phone: string; + /** + * Email verification status. + */ + emailVerification: boolean; + /** + * Canonical form of the user email address. + */ + emailCanonical?: string | null; + /** + * Whether the user email is from a free email provider. + */ + emailIsFree?: boolean | null; + /** + * Whether the user email is from a disposable email provider. + */ + emailIsDisposable?: boolean | null; + /** + * Whether the user email is from a corporate domain. + */ + emailIsCorporate?: boolean | null; + /** + * Whether the user email is in its canonical form. + */ + emailIsCanonical?: boolean | null; + /** + * Whether the password was found in a known data breach the last time it was checked. Null when the password has never been checked. + */ + passwordPwned?: boolean | null; + /** + * Phone verification status. + */ + phoneVerification: boolean; + /** + * Multi factor authentication status. + */ + mfa: boolean; + /** + * User preferences as a key-value object + */ + prefs: Preferences; + /** + * A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + */ + targets: Target[]; + /** + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + */ + accessedAt: string; + /** + * Whether the user can impersonate other users. + */ + impersonator?: boolean | null; + /** + * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + */ + impersonatorUserId?: string | null; + }; + /** * Preferences */ @@ -3564,6 +3684,10 @@ export namespace Models { * Identity Provider Refresh Token. */ providerRefreshToken: string; + /** + * Identity Provider ID token (JWT) from the most recent native sign-in. Empty for identities created through the browser OAuth2 flow. + */ + providerIdToken?: string; }; /** @@ -4648,10 +4772,22 @@ export namespace Models { * Whether WAF enforcement is enabled for the project. */ wafEnabled?: boolean; + /** + * ID of the project this environment belongs to. Null when the project is not an environment. + */ + parentId?: string | null; /** * Billing limits reached */ billingLimits?: BillingLimits; + /** + * First time the project received a non-console API request. Empty until the project is used. + */ + firstAccessedAt?: string | null; + /** + * Last time the project was accessed through the MCP server. Empty if it was never accessed via MCP. + */ + mcpAccessedAt?: string | null; /** * OAuth2 server status */ @@ -4986,6 +5122,10 @@ export namespace Models { * GitHub OAuth2 client secret. */ clientSecret: string; + /** + * GitHub OAuth2 prompt values. + */ + prompt?: OAuth2GithubPrompt[]; }; /** @@ -5008,6 +5148,10 @@ export namespace Models { * Discord OAuth2 client secret. */ clientSecret: string; + /** + * Discord OAuth2 prompt values. + */ + prompt?: OAuth2DiscordPrompt[]; }; /** @@ -5188,6 +5332,14 @@ export namespace Models { * Google OAuth2 prompt values. */ prompt: OAuth2GooglePrompt[]; + /** + * Native Google sign-in is active and can be used to create sessions from an ID token. Independent of enabled, which only controls the browser-based flow. + */ + nativeEnabled?: boolean; + /** + * Additional OAuth2 client IDs accepted as ID token audiences for native sign-in, next to the client ID. + */ + nativeClientIds?: string[]; }; /** @@ -5232,6 +5384,10 @@ export namespace Models { * Zoho OAuth2 client secret. */ clientSecret: string; + /** + * Zoho OAuth2 prompt values. + */ + prompt?: OAuth2ZohoPrompt[]; }; /** @@ -5300,6 +5456,28 @@ export namespace Models { clientSecret: string; }; + /** + * OAuth2Webflow + */ + export type OAuth2Webflow = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Webflow OAuth2 client ID. + */ + clientId: string; + /** + * Webflow OAuth2 client secret. + */ + clientSecret: string; + }; + /** * OAuth2Twitch */ @@ -5452,6 +5630,10 @@ export namespace Models { * Salesforce OAuth2 consumer secret. */ customerSecret: string; + /** + * Salesforce OAuth2 prompt values. + */ + prompt?: OAuth2SalesforcePrompt[]; }; /** @@ -5768,6 +5950,10 @@ export namespace Models { * Auth0 OAuth2 client secret. */ clientSecret: string; + /** + * Auth0 OAuth2 prompt values. + */ + prompt?: OAuth2Auth0Prompt[]; /** * Auth0 OAuth2 endpoint domain. */ @@ -5896,6 +6082,10 @@ export namespace Models { * Okta OAuth2 client secret. */ clientSecret: string; + /** + * Okta OAuth2 prompt values. + */ + prompt?: OAuth2OktaPrompt[]; /** * Okta OAuth2 domain. */ @@ -5956,6 +6146,14 @@ export namespace Models { * Apple OAuth2 .p8 private key file contents. The secret key wrapped by the PEM markers is 200 characters long. */ p8File: string; + /** + * Native Sign in with Apple is active and can be used to create sessions from an ID token. Independent of enabled, which only controls the browser-based flow. + */ + nativeEnabled?: boolean; + /** + * App bundle IDs accepted as ID token audiences for native Sign in with Apple, next to the Services ID. + */ + nativeClientIds?: string[]; }; /** @@ -5978,6 +6176,10 @@ export namespace Models { * Microsoft OAuth2 application secret. */ applicationSecret: string; + /** + * Microsoft OAuth2 prompt values. + */ + prompt?: OAuth2MicrosoftPrompt[]; /** * Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. */ @@ -6006,6 +6208,54 @@ export namespace Models { clientSecret: string; }; + /** + * OAuth2TikTok + */ + export type OAuth2TikTok = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * TikTok OAuth2 client key. + */ + clientId: string; + /** + * TikTok OAuth2 client secret. + */ + clientSecret: string; + }; + + /** + * OAuth2Kakao + */ + export type OAuth2Kakao = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Kakao OAuth2 REST API key. + */ + clientId: string; + /** + * Kakao OAuth2 client secret. + */ + clientSecret: string; + /** + * Kakao OAuth2 prompt values. + */ + prompt: OAuth2KakaoPrompt[]; + }; + /** * OAuth2 Providers List */ @@ -6033,6 +6283,7 @@ export namespace Models { | Models.OAuth2Yandex | Models.OAuth2X | Models.OAuth2WordPress + | Models.OAuth2Webflow | Models.OAuth2Twitch | Models.OAuth2Stripe | Models.OAuth2Spotify @@ -6062,6 +6313,8 @@ export namespace Models { | Models.OAuth2HuggingFace | Models.OAuth2Resend | Models.OAuth2Cloudflare + | Models.OAuth2TikTok + | Models.OAuth2Kakao )[]; }; @@ -6137,6 +6390,46 @@ export namespace Models { enabled: boolean; }; + /** + * Policy Password Pwned + */ + export type PolicyPasswordPwned = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether passwords are checked against known data breaches and the result recorded on the user. + */ + enabled: boolean; + /** + * Whether a sign-in with a breached password is refused until the password is reset. + */ + sessions: boolean; + /** + * Whether a breached password is rejected when a user signs up or sets a new password. + */ + users: boolean; + }; + + /** + * Policy Password Rotation + */ + export type PolicyPasswordRotation = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether expired passwords require a reset before email/password sign-in. + */ + enabled: boolean; + /** + * Maximum password age in seconds. + */ + maxAge: number; + }; + /** * Policy Session Alert */ @@ -6373,6 +6666,10 @@ export namespace Models { * Android application ID. */ applicationId: string; + /** + * SHA-256 fingerprints of the certificates the app is signed with. Passkeys created in the app are accepted when its signature matches one. + */ + fingerprints?: string[]; }; /** @@ -7061,6 +7358,14 @@ export namespace Models { * Subscribe permissions. */ subscribe: string[]; + /** + * MQTT QoS for delivery on this topic. Null lets the subscriber choose their level. + */ + qos?: number | null; + /** + * Message retention in seconds for offline delivery. + */ + expiry?: number | null; }; /** @@ -7741,6 +8046,10 @@ export namespace Models { * Maximum WAF rules per project */ wafRules: number; + /** + * Maximum environments per project. 0 when the plan does not offer environments. + */ + environments?: number; /** * Projects */ @@ -7877,6 +8186,10 @@ export namespace Models { * Does plan require billing address */ requiresBillingAddress: boolean; + /** + * ISO country codes eligible for this regional plan. Empty means no restriction. + */ + eligibleCountries?: string[] | null; /** * Is the billing plan available */ @@ -8449,6 +8762,18 @@ export namespace Models { * Storage allocated in GB. */ storage: number; + /** + * Storage resize status. Possible values: idle (no resize in flight), resizing (the volume is growing towards storageTargetGb). + */ + storageStatus?: string; + /** + * Size in GB the volume is growing towards while storageStatus is resizing. 0 when no resize is in flight. + */ + storageTargetGb?: number; + /** + * Time the in-flight storage resize started, in ISO 8601 format. + */ + storageResizeStartedAt?: string | null; /** * Storage class. Currently always 'ssd'; DigitalOcean exposes a single block-storage class. */ @@ -8704,48 +9029,216 @@ export namespace Models { }; /** - * Extensions + * DNSRecord */ - export type DedicatedDatabaseExtensions = { + export type DnsRecord = { /** - * List of installed extensions. + * DNS Record ID. */ - installed: string[]; + $id: string; /** - * List of available extensions that can be installed. + * DNS Record creation time in ISO 8601 format. */ - available: string[]; + $createdAt: string; /** - * Curated metadata (display name, description, category) for each available extension. + * DNS Record update date in ISO 8601 format. */ - metadata: PostgresExtension[]; - }; - - /** - * Member - */ - export type DedicatedDatabaseMember = { + $updatedAt: string; /** - * Member identifier. + * DNS record type (e.g. A, CNAME, MX). */ - $id: string; + type: string; /** - * Member role. Possible values: primary (accepts reads and writes), replica (read-only follower), unknown (placement not established; reported while a transition is moving or restarting the topology and this member has not been probed, so no member can be named the write target). + * Record name or subdomain. */ - role: string; + name: string; /** - * Member pod status. Possible values: pending (configured but absent from the backend topology, so nothing is bringing it up), provisioning (pod missing or Pending), starting (Running but not Ready), active (Running and Ready), failed (Failed phase or CrashLoopBackOff container), or the lowercased pod phase reported by the cluster. + * Value of the record (IP address, domain, etc.). */ - status: string; + value: string; /** - * Whether the engine reports this member's replication stream as up. Null when no reading was taken: a primary has no stream to report, and a member that is not active, or whose probe did not answer, has none yet. False is a reading and null is the absence of one, so the two are not interchangeable. Read it beside lagSeconds before expecting a failover that names no target to find a promotable standby: a member streaming at a known lag is one, and a member reporting null is not evidence either way. + * Time to live (in seconds). */ - replicating?: boolean; + ttl: number; /** - * Replication lag in seconds. Null when the lag is not known: a primary has none to report, and a member the backend has not probed has none yet. Also null against `replicating: true`, for a member that is streaming but whose engine printed no numeric lag. + * Record priority (commonly used for MX). */ - lagSeconds?: number; - }; + priority: number; + /** + * Whether this record is locked (read-only). + */ + lock: boolean; + /** + * Record weight (used for SRV records). + */ + weight: number; + /** + * Target port (used for SRV records). + */ + port: number; + /** + * Comment for the DNS record. + */ + comment: string; + }; + + /** + * Domain + */ + export type Domain = { + /** + * Domain ID. + */ + $id: string; + /** + * Domain creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Domain update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Domain name. + */ + domain: string; + /** + * Domain registrar (e.g. "appwrite" or "third_party"). + */ + registrar: string; + /** + * Nameservers setting. "Appwrite" or empty string. + */ + nameservers: string; + /** + * Domain expiry date in ISO 8601 format. + */ + expire: string; + /** + * Domain renewal date in ISO 8601 format. + */ + renewal: string; + /** + * If set to true, the domain will automatically renew. + */ + autoRenewal: boolean; + /** + * Renewal price (in cents). + */ + renewalPrice: number; + /** + * Transfer status for domains being transferred in. Null when the domain is not being transferred. + */ + transferStatus?: DomainTransferStatusEnum | null; + /** + * Team ID. + */ + teamId: string; + /** + * Dns records + */ + dnsRecords: DnsRecord[]; + }; + + /** + * DomainPrice + */ + export type DomainPrice = { + /** + * Domain name. + */ + domain: string; + /** + * Top-level domain for the requested domain. + */ + tld: string; + /** + * Whether the domain is currently available for registration. + */ + available: boolean; + /** + * Domain registration price. Null when the price could not be resolved, for example for an unsupported TLD. + */ + price?: number | null; + /** + * Price period in years. + */ + periodYears: number; + /** + * Whether the domain is a premium domain. + */ + premium: boolean; + /** + * Domain renewal price for the same period. Null when the domain was not priced or the registrar has no renewal price for it. + */ + renewalPrice?: number | null; + /** + * Renewal price period in years. + */ + renewalPeriodYears: number; + }; + + /** + * domainTransferStatus + */ + export type DomainTransferStatus = { + /** + * Transfer status. + */ + status: DomainTransferStatusEnum; + /** + * Additional transfer status information. + */ + reason: string; + /** + * Transfer status timestamp in ISO 8601 format. + */ + timestamp: string; + }; + + /** + * Extensions + */ + export type DedicatedDatabaseExtensions = { + /** + * List of installed extensions. + */ + installed: string[]; + /** + * List of available extensions that can be installed. + */ + available: string[]; + /** + * Curated metadata (display name, description, category) for each available extension. + */ + metadata: PostgresExtension[]; + }; + + /** + * Member + */ + export type DedicatedDatabaseMember = { + /** + * Member identifier. + */ + $id: string; + /** + * Member role. Possible values: primary (accepts reads and writes), replica (read-only follower), unknown (placement not established; reported while a transition is moving or restarting the topology and this member has not been probed, so no member can be named the write target). + */ + role: string; + /** + * Member pod status. Possible values: pending (configured but absent from the backend topology, so nothing is bringing it up), provisioning (pod missing or Pending), starting (Running but not Ready), active (Running and Ready), failed (Failed phase or CrashLoopBackOff container), or the lowercased pod phase reported by the cluster. + */ + status: string; + /** + * Whether the engine reports this member's replication stream as up. Null when no reading was taken: a primary has no stream to report, and a member that is not active, or whose probe did not answer, has none yet. False is a reading and null is the absence of one, so the two are not interchangeable. Read it beside lagSeconds before expecting a failover that names no target to find a promotable standby: a member streaming at a known lag is one, and a member reporting null is not evidence either way. + */ + replicating?: boolean; + /** + * Replication lag in seconds. Null when the lag is not known: a primary has none to report, and a member the backend has not probed has none yet. Also null against `replicating: true`, for a member that is streaming but whose engine printed no numeric lag. + */ + lagSeconds?: number; + }; /** * Operation @@ -9333,6 +9826,22 @@ export namespace Models { * Monthly price of the specification in USD. */ price: number; + /** + * Price per GB of storage above the included amount, per month, in USD. + */ + storageOverageRate?: number; + /** + * Price per GB of bandwidth above the included amount, per month, in USD. + */ + bandwidthOverageRate?: number; + /** + * High availability replica price as a fraction of the specification price. + */ + replicaRate?: number; + /** + * Point-in-time recovery price as a fraction of the specification price. + */ + pitrRate?: number; /** * Allocated CPU in millicores. */ @@ -9985,6 +10494,60 @@ export namespace Models { id_token?: string; }; + /** + * OAuth2 Introspection + */ + export type Oauth2Introspection = { + /** + * Whether the token is currently active. An inactive token carries no other claims (RFC 7662). + */ + active: boolean; + /** + * Kind of token that was introspected. Can be one of: `access_token` or `refresh_token`. + */ + token_use?: string | null; + /** + * OAuth2 token type. + */ + token_type?: string | null; + /** + * Space-separated scopes granted to the token. + */ + scope?: string | null; + /** + * OAuth2 client ID the token was issued to. + */ + client_id?: string | null; + /** + * ID of the user who authorized the token. + */ + sub?: string | null; + /** + * Audiences the token is intended for. The first entry is the project API base URL; any further entries are the resource indicators requested at authorization time (RFC 8707). + */ + aud?: string[] | null; + /** + * Issuer URL of the token. + */ + iss?: string | null; + /** + * Expiration time as a Unix timestamp in seconds. + */ + exp?: number | null; + /** + * Issued-at time as a Unix timestamp in seconds. + */ + iat?: number | null; + /** + * Unique identifier of the token. + */ + jti?: string | null; + /** + * Granted RFC 9396 authorization details, restricted to what the user can currently access. + */ + authorization_details?: Record[] | null; + }; + /** * OAuth2 Consent */ @@ -10081,6 +10644,376 @@ export namespace Models { expire: string; }; + /** + * WafRuleBypass + */ + export type WafRuleBypass = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record[]; + /** + * Action specific configuration. + */ + config: object; + }; + + /** + * WafRuleDeny + */ + export type WafRuleDeny = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record[]; + /** + * Action specific configuration. + */ + config: object; + }; + + /** + * WafRuleChallenge + */ + export type WafRuleChallenge = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Challenge type enforced when the rule matches. + */ + challengeType: string; + /** + * Challenge difficulty from 1 (easiest) to 5 (hardest) enforced when the rule matches. + */ + difficulty: number; + /** + * Seconds a visitor stays cleared after passing the challenge before being challenged again. + */ + ttl: number; + }; + + /** + * WafRuleRateLimit + */ + export type WafRuleRateLimit = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Maximum number of matching requests allowed for the given interval. + */ + limit: number; + /** + * Interval in seconds for the rate limit window. + */ + interval: number; + /** + * Rate limit key: `ip` limits per client IP, `userId` limits per authenticated user. + */ + key: string; + /** + * Rate limit strategy: `fixedWindow`, `slidingWindow`, or `tokenBucket`. + */ + strategy: string; + /** + * Maximum burst capacity in tokens, applied by the `tokenBucket` strategy. The sustained refill rate is `limit / interval`. Defaults to `limit`. + */ + maxBucketSize: number; + }; + + /** + * WafRuleRedirect + */ + export type WafRuleRedirect = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Target location for the redirect. + */ + location: string; + /** + * HTTP status code used for the redirect. + */ + statusCode: number; + }; + + /** + * WAF rule list + */ + export type WafRuleList = { + /** + * Total number of rules that matched your query. + */ + total: number; + /** + * List of rules. + */ + rules: ( + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + )[]; + }; + /** * OAuth2 Project */ @@ -10249,6 +11182,48 @@ export namespace Models { databases: DedicatedDatabase[]; }; + /** + * DNS records list + */ + export type DnsRecordsList = { + /** + * Total number of dnsRecords that matched your query. + */ + total: number; + /** + * List of dnsRecords. + */ + dnsRecords: DnsRecord[]; + }; + + /** + * Domain prices list + */ + export type DomainPricesList = { + /** + * Total number of prices that matched your query. + */ + total: number; + /** + * List of prices. + */ + prices: DomainPrice[]; + }; + + /** + * Domains list + */ + export type DomainsList = { + /** + * Total number of domains that matched your query. + */ + total: number; + /** + * List of domains. + */ + domains: Domain[]; + }; + /** * Apps list */ diff --git a/src/services/account.ts b/src/services/account.ts index 73519d12..c9574778 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -3,6 +3,7 @@ import type { Models } from '../models'; import { AuthenticatorType } from '../enums/authenticator-type'; import { AuthenticationFactor } from '../enums/authentication-factor'; +import { IdTokenProvider } from '../enums/id-token-provider'; import { OAuthProvider } from '../enums/o-auth-provider'; export class Account { client: Client; @@ -2551,15 +2552,213 @@ export class Account { return this.client.call('put', uri, apiHeaders, apiPayload); } + /** + * Use this endpoint to send a 6-digit password recovery code to the user's email address. Unlike [createRecovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery), this method requires no redirect URL, which makes it suitable for mobile and desktop apps that cannot host a recovery page. Learn more about how to [complete the recovery process](https://appwrite.io/docs/references/cloud/client-web/account#updateRecoveryOTP). The code sent to the user's email address is valid for 15 minutes. + * + * Enable the **phrase** parameter to include a randomly generated security phrase in both the email and the response. Showing that phrase in your app lets the user confirm the email genuinely came from your request, which helps protect against phishing. + * + * + * @param {string} params.email - User email. + * @param {boolean} params.phrase - Toggle for security phrase. If enabled, email will be sent with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRecoveryOTP(params: { + email: string; + phrase?: boolean; + }): Promise; + /** + * Use this endpoint to send a 6-digit password recovery code to the user's email address. Unlike [createRecovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery), this method requires no redirect URL, which makes it suitable for mobile and desktop apps that cannot host a recovery page. Learn more about how to [complete the recovery process](https://appwrite.io/docs/references/cloud/client-web/account#updateRecoveryOTP). The code sent to the user's email address is valid for 15 minutes. + * + * Enable the **phrase** parameter to include a randomly generated security phrase in both the email and the response. Showing that phrase in your app lets the user confirm the email genuinely came from your request, which helps protect against phishing. + * + * + * @param {string} email - User email. + * @param {boolean} phrase - Toggle for security phrase. If enabled, email will be sent with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRecoveryOTP(email: string, phrase?: boolean): Promise; + createRecoveryOTP( + paramsOrFirst: { email: string; phrase?: boolean } | string, + ...rest: [boolean?] + ): Promise { + let params: { email: string; phrase?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + email: string; + phrase?: boolean; + }; + } else { + params = { + email: paramsOrFirst as string, + phrase: rest[0] as boolean, + }; + } + + const email = params.email; + const phrase = params.phrase; + if (typeof email === 'undefined') { + throw new AppwriteException('Missing required parameter: "email"'); + } + const apiPath = '/account/recovery/otp'; + const apiPayload: Payload = {}; + if (typeof email !== 'undefined') { + apiPayload['email'] = email; + } + if (typeof phrase !== 'undefined') { + apiPayload['phrase'] = phrase; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Use this endpoint to complete the user password recovery process using the 6-digit code that was emailed by [createRecoveryOTP](https://appwrite.io/docs/references/cloud/client-web/account#createRecoveryOTP). Pass the **userId** of the user along with the **secret** code from the email and the new **password** to set. If confirmed, this route will return a 200 status code, the code is consumed and the user's password is updated. + * + * + * @param {string} params.userId - User ID. + * @param {string} params.secret - Valid recovery OTP code. + * @param {string} params.password - New user password. Must be between 8 and 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRecoveryOTP(params: { + userId: string; + secret: string; + password: string; + }): Promise; + /** + * Use this endpoint to complete the user password recovery process using the 6-digit code that was emailed by [createRecoveryOTP](https://appwrite.io/docs/references/cloud/client-web/account#createRecoveryOTP). Pass the **userId** of the user along with the **secret** code from the email and the new **password** to set. If confirmed, this route will return a 200 status code, the code is consumed and the user's password is updated. + * + * + * @param {string} userId - User ID. + * @param {string} secret - Valid recovery OTP code. + * @param {string} password - New user password. Must be between 8 and 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRecoveryOTP( + userId: string, + secret: string, + password: string, + ): Promise; + updateRecoveryOTP( + paramsOrFirst: + { userId: string; secret: string; password: string } | string, + ...rest: [string?, string?] + ): Promise { + let params: { userId: string; secret: string; password: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + secret: string; + password: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + secret: rest[0] as string, + password: rest[1] as string, + }; + } + + const userId = params.userId; + const secret = params.secret; + const password = params.password; + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof secret === 'undefined') { + throw new AppwriteException('Missing required parameter: "secret"'); + } + if (typeof password === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "password"', + ); + } + const apiPath = '/account/recovery/otp'; + const apiPayload: Payload = {}; + if (typeof userId !== 'undefined') { + apiPayload['userId'] = userId; + } + if (typeof secret !== 'undefined') { + apiPayload['secret'] = secret; + } + if (typeof password !== 'undefined') { + apiPayload['password'] = password; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, apiPayload); + } + /** * Get the list of active sessions across different devices for the currently logged in user. * + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ - listSessions(): Promise { + listSessions(params?: { total?: boolean }): Promise; + /** + * Get the list of active sessions across different devices for the currently logged in user. + * + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listSessions(total?: boolean): Promise; + listSessions( + paramsOrFirst?: { total?: boolean } | boolean, + ): Promise { + let params: { total?: boolean }; + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { total?: boolean }; + } else { + params = { + total: paramsOrFirst as boolean, + }; + } + + const total = params.total; const apiPath = '/account/sessions'; const apiPayload: Payload = {}; + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2573,12 +2772,44 @@ export class Account { /** * Delete all sessions from the user account and remove any sessions cookies from the end client. * + * @param {boolean} params.current - Delete the current session too. Use false to sign out of every other session while staying signed in on this one. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteSessions(params?: { current?: boolean }): Promise<{}>; + /** + * Delete all sessions from the user account and remove any sessions cookies from the end client. Pass `current` as false to keep the session making the request and sign out of every other session. + * + * @param {boolean} current - Delete the current session too. Use false to sign out of every other session while staying signed in on this one. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteSessions(): Promise<{}> { + deleteSessions(current?: boolean): Promise<{}>; + deleteSessions( + paramsOrFirst?: { current?: boolean } | boolean, + ): Promise<{}> { + let params: { current?: boolean }; + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { current?: boolean }; + } else { + params = { + current: paramsOrFirst as boolean, + }; + } + + const current = params.current; const apiPath = '/account/sessions'; const apiPayload: Payload = {}; + if (typeof current !== 'undefined') { + apiPayload['current'] = current; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2616,12 +2847,14 @@ export class Account { * * @param {string} params.email - User email. * @param {string} params.password - User password. Must be at least 8 chars. + * @param {number} params.duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. * @throws {AppwriteException} * @returns {Promise} */ createEmailPasswordSession(params: { email: string; password: string; + duration?: number; }): Promise; /** * Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. @@ -2630,6 +2863,7 @@ export class Account { * * @param {string} email - User email. * @param {string} password - User password. Must be at least 8 chars. + * @param {number} duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -2637,12 +2871,14 @@ export class Account { createEmailPasswordSession( email: string, password: string, + duration?: number, ): Promise; createEmailPasswordSession( - paramsOrFirst: { email: string; password: string } | string, - ...rest: [string?] + paramsOrFirst: + { email: string; password: string; duration?: number } | string, + ...rest: [string?, number?] ): Promise { - let params: { email: string; password: string }; + let params: { email: string; password: string; duration?: number }; if ( paramsOrFirst && @@ -2652,16 +2888,19 @@ export class Account { params = (paramsOrFirst || {}) as { email: string; password: string; + duration?: number; }; } else { params = { email: paramsOrFirst as string, password: rest[0] as string, + duration: rest[1] as number, }; } const email = params.email; const password = params.password; + const duration = params.duration; if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } @@ -2678,6 +2917,171 @@ export class Account { if (typeof password !== 'undefined') { apiPayload['password'] = password; } + if (typeof duration !== 'undefined') { + apiPayload['duration'] = duration; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Allow the user to login to their account using an OpenID Connect ID token obtained natively from the OAuth2 provider, for example via Google Credential Manager on Android or Sign in with Apple on iOS. No browser or redirect is involved: the ID token is verified against the provider's published signing keys and a session is created in a single request. + * + * Native sign-in is switched on per provider with its nativeEnabled setting. It is independent of the browser-based flow's enabled setting, which has no effect on this endpoint. The token's audience must match the provider's configured client ID or one of its native client IDs; tokens issued for any other client ID are rejected. For Sign in with Apple, register your app's bundle ID as a native client ID. For Google, the web client ID used by Credential Manager is usually the configured client ID; add your Android and iOS client IDs as native client IDs if your app requests tokens for them. + * + * Pass the raw nonce used when requesting the ID token so it can be validated against the token's nonce claim. When signing in with Apple, the nonce is required: hash it with SHA-256 before passing it to the Apple SDK, and send the raw value here - Apple tokens requested without a nonce are rejected. For Google the nonce is optional: it is validated whenever the token carries one, and ignored when the provider issued the token without one. Apple only returns the user's name on the first authorization, and never inside the ID token - capture it on the client and pass it via the name parameter. + * + * If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the verified email received from the provider and attach the new session to the existing user. If no matching user is found - the server will create a new user. + * + * This flow does not return provider refresh tokens. You may pass an access token the provider handed your client, along with its lifetime, to store it on the session - but Appwrite cannot renew it once it expires. If your app needs long-lived access to provider APIs, use the browser-based OAuth2 flow instead. + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * + * @param {IdTokenProvider} params.provider - OAuth2 provider that issued the ID token. Currently, supported providers are: apple, google. + * @param {string} params.idToken - OpenID Connect ID token (JWT) obtained natively from the provider, for example via Google Credential Manager or Sign in with Apple. + * @param {string} params.nonce - Raw nonce used when requesting the ID token. Required for Apple, and whenever the token carries a nonce claim, which must match it. Ignored when the provider issued the token without a nonce. + * @param {string} params.accessToken - Provider access token to store alongside the session for calling provider APIs. Never used for authentication. + * @param {number} params.accessTokenExpiry - Seconds until the provider access token expires, as reported by the provider. Stored so clients can tell when the stored token goes stale. + * @param {string} params.name - User name. Only used when creating a new user and the ID token has no name claim, such as on the first Sign in with Apple authorization. + * @throws {AppwriteException} + * @returns {Promise} + */ + createIdTokenSession(params: { + provider: IdTokenProvider; + idToken: string; + nonce?: string; + accessToken?: string; + accessTokenExpiry?: number; + name?: string; + }): Promise; + /** + * Allow the user to login to their account using an OpenID Connect ID token obtained natively from the OAuth2 provider, for example via Google Credential Manager on Android or Sign in with Apple on iOS. No browser or redirect is involved: the ID token is verified against the provider's published signing keys and a session is created in a single request. + * + * Native sign-in is switched on per provider with its nativeEnabled setting. It is independent of the browser-based flow's enabled setting, which has no effect on this endpoint. The token's audience must match the provider's configured client ID or one of its native client IDs; tokens issued for any other client ID are rejected. For Sign in with Apple, register your app's bundle ID as a native client ID. For Google, the web client ID used by Credential Manager is usually the configured client ID; add your Android and iOS client IDs as native client IDs if your app requests tokens for them. + * + * Pass the raw nonce used when requesting the ID token so it can be validated against the token's nonce claim. When signing in with Apple, the nonce is required: hash it with SHA-256 before passing it to the Apple SDK, and send the raw value here - Apple tokens requested without a nonce are rejected. For Google the nonce is optional: it is validated whenever the token carries one, and ignored when the provider issued the token without one. Apple only returns the user's name on the first authorization, and never inside the ID token - capture it on the client and pass it via the name parameter. + * + * If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the verified email received from the provider and attach the new session to the existing user. If no matching user is found - the server will create a new user. + * + * This flow does not return provider refresh tokens. You may pass an access token the provider handed your client, along with its lifetime, to store it on the session - but Appwrite cannot renew it once it expires. If your app needs long-lived access to provider APIs, use the browser-based OAuth2 flow instead. + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * + * @param {IdTokenProvider} provider - OAuth2 provider that issued the ID token. Currently, supported providers are: apple, google. + * @param {string} idToken - OpenID Connect ID token (JWT) obtained natively from the provider, for example via Google Credential Manager or Sign in with Apple. + * @param {string} nonce - Raw nonce used when requesting the ID token. Required for Apple, and whenever the token carries a nonce claim, which must match it. Ignored when the provider issued the token without a nonce. + * @param {string} accessToken - Provider access token to store alongside the session for calling provider APIs. Never used for authentication. + * @param {number} accessTokenExpiry - Seconds until the provider access token expires, as reported by the provider. Stored so clients can tell when the stored token goes stale. + * @param {string} name - User name. Only used when creating a new user and the ID token has no name claim, such as on the first Sign in with Apple authorization. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIdTokenSession( + provider: IdTokenProvider, + idToken: string, + nonce?: string, + accessToken?: string, + accessTokenExpiry?: number, + name?: string, + ): Promise; + createIdTokenSession( + paramsOrFirst: + | { + provider: IdTokenProvider; + idToken: string; + nonce?: string; + accessToken?: string; + accessTokenExpiry?: number; + name?: string; + } + | IdTokenProvider, + ...rest: [string?, string?, string?, number?, string?] + ): Promise { + let params: { + provider: IdTokenProvider; + idToken: string; + nonce?: string; + accessToken?: string; + accessTokenExpiry?: number; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('provider' in paramsOrFirst || + 'idToken' in paramsOrFirst || + 'nonce' in paramsOrFirst || + 'accessToken' in paramsOrFirst || + 'accessTokenExpiry' in paramsOrFirst || + 'name' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + provider: IdTokenProvider; + idToken: string; + nonce?: string; + accessToken?: string; + accessTokenExpiry?: number; + name?: string; + }; + } else { + params = { + provider: paramsOrFirst as IdTokenProvider, + idToken: rest[0] as string, + nonce: rest[1] as string, + accessToken: rest[2] as string, + accessTokenExpiry: rest[3] as number, + name: rest[4] as string, + }; + } + + const provider = params.provider; + const idToken = params.idToken; + const nonce = params.nonce; + const accessToken = params.accessToken; + const accessTokenExpiry = params.accessTokenExpiry; + const name = params.name; + if (typeof provider === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "provider"', + ); + } + if (typeof idToken === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "idToken"', + ); + } + const apiPath = '/account/sessions/id-token'; + const apiPayload: Payload = {}; + if (typeof provider !== 'undefined') { + apiPayload['provider'] = provider; + } + if (typeof idToken !== 'undefined') { + apiPayload['idToken'] = idToken; + } + if (typeof nonce !== 'undefined') { + apiPayload['nonce'] = nonce; + } + if (typeof accessToken !== 'undefined') { + apiPayload['accessToken'] = accessToken; + } + if (typeof accessTokenExpiry !== 'undefined') { + apiPayload['accessTokenExpiry'] = accessTokenExpiry; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3857,6 +4261,142 @@ export class Account { return this.client.call('put', uri, apiHeaders, apiPayload); } + /** + * Use this endpoint to send a 6-digit verification code to the currently logged in user's email address. Unlike [createEmailVerification](https://appwrite.io/docs/references/cloud/client-web/account#createEmailVerification), this method requires no redirect URL, which makes it suitable for mobile and desktop apps that cannot host a verification page. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateEmailVerificationOTP). The code sent to the user's email address is valid for 15 minutes. + * + * Enable the **phrase** parameter to include a randomly generated security phrase in both the email and the response. Showing that phrase in your app lets the user confirm the email genuinely came from your request, which helps protect against phishing. + * + * + * @param {boolean} params.phrase - Toggle for security phrase. If enabled, email will be sent with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + * @throws {AppwriteException} + * @returns {Promise} + */ + createEmailVerificationOTP(params?: { + phrase?: boolean; + }): Promise; + /** + * Use this endpoint to send a 6-digit verification code to the currently logged in user's email address. Unlike [createEmailVerification](https://appwrite.io/docs/references/cloud/client-web/account#createEmailVerification), this method requires no redirect URL, which makes it suitable for mobile and desktop apps that cannot host a verification page. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateEmailVerificationOTP). The code sent to the user's email address is valid for 15 minutes. + * + * Enable the **phrase** parameter to include a randomly generated security phrase in both the email and the response. Showing that phrase in your app lets the user confirm the email genuinely came from your request, which helps protect against phishing. + * + * + * @param {boolean} phrase - Toggle for security phrase. If enabled, email will be sent with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEmailVerificationOTP(phrase?: boolean): Promise; + createEmailVerificationOTP( + paramsOrFirst?: { phrase?: boolean } | boolean, + ): Promise { + let params: { phrase?: boolean }; + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { phrase?: boolean }; + } else { + params = { + phrase: paramsOrFirst as boolean, + }; + } + + const phrase = params.phrase; + const apiPath = '/account/verifications/email/otp'; + const apiPayload: Payload = {}; + if (typeof phrase !== 'undefined') { + apiPayload['phrase'] = phrase; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Use this endpoint to complete the user email verification process using the 6-digit code that was emailed by [createEmailVerificationOTP](https://appwrite.io/docs/references/cloud/client-web/account#createEmailVerificationOTP). Pass the **userId** of the user being verified along with the **secret** code from the email. If confirmed, this route will return a 200 status code and the code is consumed. + * + * + * @param {string} params.userId - User ID. + * @param {string} params.secret - Valid verification OTP code. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateEmailVerificationOTP(params: { + userId: string; + secret: string; + }): Promise; + /** + * Use this endpoint to complete the user email verification process using the 6-digit code that was emailed by [createEmailVerificationOTP](https://appwrite.io/docs/references/cloud/client-web/account#createEmailVerificationOTP). Pass the **userId** of the user being verified along with the **secret** code from the email. If confirmed, this route will return a 200 status code and the code is consumed. + * + * + * @param {string} userId - User ID. + * @param {string} secret - Valid verification OTP code. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEmailVerificationOTP( + userId: string, + secret: string, + ): Promise; + updateEmailVerificationOTP( + paramsOrFirst: { userId: string; secret: string } | string, + ...rest: [string?] + ): Promise { + let params: { userId: string; secret: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + secret: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + secret: rest[0] as string, + }; + } + + const userId = params.userId; + const secret = params.secret; + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof secret === 'undefined') { + throw new AppwriteException('Missing required parameter: "secret"'); + } + const apiPath = '/account/verifications/email/otp'; + const apiPayload: Payload = {}; + if (typeof userId !== 'undefined') { + apiPayload['userId'] = userId; + } + if (typeof secret !== 'undefined') { + apiPayload['secret'] = secret; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, apiPayload); + } + /** * Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. * diff --git a/src/services/avatars.ts b/src/services/avatars.ts index e2f4afd3..5fca4b8c 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -1,4 +1,11 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + UploadProgress, +} from '../client'; +import type { Models } from '../models'; +import { InputFile } from '../inputFile'; import { Browser } from '../enums/browser'; import { CreditCard } from '../enums/credit-card'; @@ -791,6 +798,111 @@ export class Avatars { ); } + /** + * Update the profile photo of the currently authenticated user. The uploaded image takes priority over every other photo source, including OAuth2 identity photos, Gravatar, and Libravatar. Updating an already customized photo replaces it. The image must be at most 5MB and is sent in a single request. + * + * @param {File | InputFile} params.file - Binary image file of at most 5MB. Allowed file types are png, jpg, jpeg, and webp. + * @throws {AppwriteException} + * @returns {Promise>} + */ + updatePhoto< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + file: File | InputFile; + onProgress?: (progress: UploadProgress) => void; + }): Promise>; + /** + * Update the profile photo of the currently authenticated user. The uploaded image takes priority over every other photo source, including OAuth2 identity photos, Gravatar, and Libravatar. Updating an already customized photo replaces it. The image must be at most 5MB and is sent in a single request. + * + * @param {File | InputFile} file - Binary image file of at most 5MB. Allowed file types are png, jpg, jpeg, and webp. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePhoto< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + file: File | InputFile, + onProgress?: (progress: UploadProgress) => void, + ): Promise>; + updatePhoto< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { + file: File | InputFile; + onProgress?: (progress: UploadProgress) => void; + } + | File + | InputFile, + ...rest: [((progress: UploadProgress) => void)?] + ): Promise> { + let params: { file: File | InputFile }; + let onProgress: (progress: UploadProgress) => void; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('file' in paramsOrFirst || 'onProgress' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { file: File | InputFile }; + onProgress = paramsOrFirst?.onProgress as ( + progress: UploadProgress, + ) => void; + } else { + params = { + file: paramsOrFirst as File | InputFile, + }; + onProgress = rest[0] as (progress: UploadProgress) => void; + } + + const file = params.file; + if (typeof file === 'undefined') { + throw new AppwriteException('Missing required parameter: "file"'); + } + const apiPath = '/avatars/photo'; + const apiPayload: Payload = {}; + if (typeof file !== 'undefined') { + apiPayload['file'] = file; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'multipart/form-data', + accept: 'application/json', + }; + + return this.client.chunkedUpload( + 'put', + uri, + apiHeaders, + apiPayload, + onProgress, + ); + } + + /** + * Delete the profile photo of the currently authenticated user and store the built-in static placeholder in its place. The placeholder is the user's photo from then on, so it takes priority over every other photo source — OAuth2 identity photos, Gravatar, Libravatar, and initials — until a new photo is uploaded with avatars.updatePhoto. + * + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePhoto(): Promise<{}> { + const apiPath = '/avatars/photo'; + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } + /** * Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image. * diff --git a/src/services/databases.ts b/src/services/databases.ts index 5d06492c..382475a3 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -186,26 +186,33 @@ export class Databases { * List transactions across all databases. * * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead. */ listTransactions(params?: { queries?: string[]; + total?: boolean; }): Promise; /** * List transactions across all databases. * * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTransactions(queries?: string[]): Promise; listTransactions( - paramsOrFirst?: { queries?: string[] } | string[], + queries?: string[], + total?: boolean, + ): Promise; + listTransactions( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[] }; + let params: { queries?: string[]; total?: boolean }; if ( !paramsOrFirst || @@ -213,19 +220,27 @@ export class Databases { typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst)) ) { - params = (paramsOrFirst || {}) as { queries?: string[] }; + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; } else { params = { queries: paramsOrFirst as string[], + total: rest[0] as boolean, }; } const queries = params.queries; + const total = params.total; const apiPath = '/databases/transactions'; const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { apiPayload['queries'] = queries; } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts index 8a9eec0d..9ae7ca31 100644 --- a/src/services/documents-db.ts +++ b/src/services/documents-db.ts @@ -232,25 +232,32 @@ export class DocumentsDB { * List transactions across all databases. * * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ listTransactions(params?: { queries?: string[]; + total?: boolean; }): Promise; /** * List transactions across all databases. * * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTransactions(queries?: string[]): Promise; listTransactions( - paramsOrFirst?: { queries?: string[] } | string[], + queries?: string[], + total?: boolean, + ): Promise; + listTransactions( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[] }; + let params: { queries?: string[]; total?: boolean }; if ( !paramsOrFirst || @@ -258,19 +265,27 @@ export class DocumentsDB { typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst)) ) { - params = (paramsOrFirst || {}) as { queries?: string[] }; + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; } else { params = { queries: paramsOrFirst as string[], + total: rest[0] as boolean, }; } const queries = params.queries; + const total = params.total; const apiPath = '/documentsdb/transactions'; const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { apiPayload['queries'] = queries; } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/domains.ts b/src/services/domains.ts new file mode 100644 index 00000000..7550437a --- /dev/null +++ b/src/services/domains.ts @@ -0,0 +1,4647 @@ +import { AppwriteException, Client, type Payload } from '../client'; +import type { Models } from '../models'; + +import { DomainRegistrationType } from '../enums/domain-registration-type'; +export class Domains { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List all domains registered for this project. This endpoint supports pagination. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as domain name, teamInternalId, expiration, etc. + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + list(params?: { + queries?: string[]; + search?: string; + }): Promise; + /** + * List all domains registered for this project. This endpoint supports pagination. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as domain name, teamInternalId, expiration, etc. + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(queries?: string[], search?: string): Promise; + list( + paramsOrFirst?: { queries?: string[]; search?: string } | string[], + ...rest: [string?] + ): Promise { + let params: { queries?: string[]; search?: string }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + search?: string; + }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + }; + } + + const queries = params.queries; + const search = params.search; + const apiPath = '/domains'; + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof search !== 'undefined') { + apiPayload['search'] = search; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Create a new domain. Before creating a domain, you need to ensure that your DNS provider is properly configured. After creating the domain, you can use the verification endpoint to check if the domain is ready to be used. + * + * @param {string} params.teamId - Team unique ID. + * @param {string} params.domain - Domain name (e.g. "example.com"). + * @throws {AppwriteException} + * @returns {Promise} + */ + create(params: { teamId: string; domain: string }): Promise; + /** + * Create a new domain. Before creating a domain, you need to ensure that your DNS provider is properly configured. After creating the domain, you can use the verification endpoint to check if the domain is ready to be used. + * + * @param {string} teamId - Team unique ID. + * @param {string} domain - Domain name (e.g. "example.com"). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create(teamId: string, domain: string): Promise; + create( + paramsOrFirst: { teamId: string; domain: string } | string, + ...rest: [string?] + ): Promise { + let params: { teamId: string; domain: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + domain: string; + }; + } else { + params = { + teamId: paramsOrFirst as string, + domain: rest[0] as string, + }; + } + + const teamId = params.teamId; + const domain = params.domain; + if (typeof teamId === 'undefined') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + if (typeof domain === 'undefined') { + throw new AppwriteException('Missing required parameter: "domain"'); + } + const apiPath = '/domains'; + const apiPayload: Payload = {}; + if (typeof teamId !== 'undefined') { + apiPayload['teamId'] = teamId; + } + if (typeof domain !== 'undefined') { + apiPayload['domain'] = domain; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Get the registration price for a domain name. + * + * @param {string} params.domain - Domain name to get price for. + * @param {number} params.periodYears - Number of years to calculate the domain price for. Must be at least 1. + * @param {DomainRegistrationType} params.registrationType - Type of registration pricing to fetch. Allowed values: new, transfer, renewal, trade. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated This API has been deprecated since 2.0.0. Please use `Domains.listPrices` instead. + */ + getPrice(params: { + domain: string; + periodYears?: number; + registrationType?: DomainRegistrationType; + }): Promise; + /** + * Get the registration price for a domain name. + * + * @param {string} domain - Domain name to get price for. + * @param {number} periodYears - Number of years to calculate the domain price for. Must be at least 1. + * @param {DomainRegistrationType} registrationType - Type of registration pricing to fetch. Allowed values: new, transfer, renewal, trade. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPrice( + domain: string, + periodYears?: number, + registrationType?: DomainRegistrationType, + ): Promise; + getPrice( + paramsOrFirst: + | { + domain: string; + periodYears?: number; + registrationType?: DomainRegistrationType; + } + | string, + ...rest: [number?, DomainRegistrationType?] + ): Promise { + let params: { + domain: string; + periodYears?: number; + registrationType?: DomainRegistrationType; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domain: string; + periodYears?: number; + registrationType?: DomainRegistrationType; + }; + } else { + params = { + domain: paramsOrFirst as string, + periodYears: rest[0] as number, + registrationType: rest[1] as DomainRegistrationType, + }; + } + + const domain = params.domain; + const periodYears = params.periodYears; + const registrationType = params.registrationType; + if (typeof domain === 'undefined') { + throw new AppwriteException('Missing required parameter: "domain"'); + } + const apiPath = '/domains/price'; + const apiPayload: Payload = {}; + if (typeof domain !== 'undefined') { + apiPayload['domain'] = domain; + } + if (typeof periodYears !== 'undefined') { + apiPayload['periodYears'] = periodYears; + } + if (typeof registrationType !== 'undefined') { + apiPayload['registrationType'] = registrationType; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Check availability and get the requested registration price for one or more domain names. Availability is resolved for all domains in a single registrar lookup. Unavailable domains have a null price for new registrations, but can still be priced for renewal, transfer, or trade. Every priced domain also carries its renewal price for the same period, so a separate renewal lookup is not needed. A domain whose price could not be resolved, for example because its TLD is not supported, is returned with a null price. + * + * @param {string[]} params.domains - Domain names to check availability and price for. Maximum of 50 domains per request. + * @param {number} params.periodYears - Number of years to calculate the domain price for. Must be at least 1. + * @param {DomainRegistrationType} params.registrationType - Type of registration pricing to fetch. Allowed values: new, transfer, renewal, trade. + * @throws {AppwriteException} + * @returns {Promise} + */ + listPrices(params: { + domains: string[]; + periodYears?: number; + registrationType?: DomainRegistrationType; + }): Promise; + /** + * Check availability and get the requested registration price for one or more domain names. Availability is resolved for all domains in a single registrar lookup. Unavailable domains have a null price for new registrations, but can still be priced for renewal, transfer, or trade. Every priced domain also carries its renewal price for the same period, so a separate renewal lookup is not needed. A domain whose price could not be resolved, for example because its TLD is not supported, is returned with a null price. + * + * @param {string[]} domains - Domain names to check availability and price for. Maximum of 50 domains per request. + * @param {number} periodYears - Number of years to calculate the domain price for. Must be at least 1. + * @param {DomainRegistrationType} registrationType - Type of registration pricing to fetch. Allowed values: new, transfer, renewal, trade. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPrices( + domains: string[], + periodYears?: number, + registrationType?: DomainRegistrationType, + ): Promise; + listPrices( + paramsOrFirst: + | { + domains: string[]; + periodYears?: number; + registrationType?: DomainRegistrationType; + } + | string[], + ...rest: [number?, DomainRegistrationType?] + ): Promise { + let params: { + domains: string[]; + periodYears?: number; + registrationType?: DomainRegistrationType; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domains: string[]; + periodYears?: number; + registrationType?: DomainRegistrationType; + }; + } else { + params = { + domains: paramsOrFirst as string[], + periodYears: rest[0] as number, + registrationType: rest[1] as DomainRegistrationType, + }; + } + + const domains = params.domains; + const periodYears = params.periodYears; + const registrationType = params.registrationType; + if (typeof domains === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "domains"', + ); + } + const apiPath = '/domains/prices'; + const apiPayload: Payload = {}; + if (typeof domains !== 'undefined') { + apiPayload['domains'] = domains; + } + if (typeof periodYears !== 'undefined') { + apiPayload['periodYears'] = periodYears; + } + if (typeof registrationType !== 'undefined') { + apiPayload['registrationType'] = registrationType; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Get a domain by its unique ID. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + get(params: { domainId: string }): Promise; + /** + * Get a domain by its unique ID. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(domainId: string): Promise; + get(paramsOrFirst: { domainId: string } | string): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Delete a domain by its unique ID. This endpoint can be used to delete a domain from your project. + * Once deleted, the domain will no longer be available for use and all associated resources will be removed. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { domainId: string }): Promise<{}>; + /** + * Delete a domain by its unique ID. This endpoint can be used to delete a domain from your project. + * Once deleted, the domain will no longer be available for use and all associated resources will be removed. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(domainId: string): Promise<{}>; + delete(paramsOrFirst: { domainId: string } | string): Promise<{}> { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } + + /** + * Update the registrar nameservers for the given domain. When nameservers are not provided, + * the domain will be updated to use Appwrite nameservers. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string[]} params.nameservers - Nameservers to set for the domain. Defaults to Appwrite nameservers when omitted. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateNameservers(params: { + domainId: string; + nameservers?: string[]; + }): Promise; + /** + * Update the registrar nameservers for the given domain. When nameservers are not provided, + * the domain will be updated to use Appwrite nameservers. + * + * @param {string} domainId - Domain unique ID. + * @param {string[]} nameservers - Nameservers to set for the domain. Defaults to Appwrite nameservers when omitted. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateNameservers( + domainId: string, + nameservers?: string[], + ): Promise; + updateNameservers( + paramsOrFirst: { domainId: string; nameservers?: string[] } | string, + ...rest: [string[]?] + ): Promise { + let params: { domainId: string; nameservers?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + nameservers?: string[]; + }; + } else { + params = { + domainId: paramsOrFirst as string, + nameservers: rest[0] as string[], + }; + } + + const domainId = params.domainId; + const nameservers = params.nameservers; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/nameservers'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + if (typeof nameservers !== 'undefined') { + apiPayload['nameservers'] = nameservers; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + + /** + * Verify which NS records are used and update the domain accordingly. This will check the domain's + * nameservers and update the domain's status based on whether the nameservers match the expected + * Appwrite nameservers. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + verifyNameservers(params: { domainId: string }): Promise; + /** + * Verify which NS records are used and update the domain accordingly. This will check the domain's + * nameservers and update the domain's status based on whether the nameservers match the expected + * Appwrite nameservers. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + verifyNameservers(domainId: string): Promise; + verifyNameservers( + paramsOrFirst: { domainId: string } | string, + ): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/nameservers/verification'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + + /** + * List Google Workspace DNS records. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPresetGoogleWorkspace(params: { + domainId: string; + }): Promise; + /** + * List Google Workspace DNS records. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPresetGoogleWorkspace(domainId: string): Promise; + getPresetGoogleWorkspace( + paramsOrFirst: { domainId: string } | string, + ): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/presets/google-workspace'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Add Google Workspace DNS records to the domain. This will create the required MX records + * for Google Workspace email hosting. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + createPresetGoogleWorkspace(params: { + domainId: string; + }): Promise; + /** + * Add Google Workspace DNS records to the domain. This will create the required MX records + * for Google Workspace email hosting. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPresetGoogleWorkspace( + domainId: string, + ): Promise; + createPresetGoogleWorkspace( + paramsOrFirst: { domainId: string } | string, + ): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/presets/google-workspace'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * List iCloud DNS records. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPresetICloud(params: { + domainId: string; + }): Promise; + /** + * List iCloud DNS records. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPresetICloud(domainId: string): Promise; + getPresetICloud( + paramsOrFirst: { domainId: string } | string, + ): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/presets/icloud'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Add iCloud DNS records to the domain. This will create the required MX and SPF records + * for using iCloud email services with your domain. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + createPresetICloud(params: { + domainId: string; + }): Promise; + /** + * Add iCloud DNS records to the domain. This will create the required MX and SPF records + * for using iCloud email services with your domain. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPresetICloud(domainId: string): Promise; + createPresetICloud( + paramsOrFirst: { domainId: string } | string, + ): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/presets/icloud'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * List Mailgun DNS records. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPresetMailgun(params: { + domainId: string; + }): Promise; + /** + * List Mailgun DNS records. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPresetMailgun(domainId: string): Promise; + getPresetMailgun( + paramsOrFirst: { domainId: string } | string, + ): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/presets/mailgun'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Add Mailgun DNS records to the domain. This endpoint will create the required DNS records + * for Mailgun in the specified domain. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + createPresetMailgun(params: { + domainId: string; + }): Promise; + /** + * Add Mailgun DNS records to the domain. This endpoint will create the required DNS records + * for Mailgun in the specified domain. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPresetMailgun(domainId: string): Promise; + createPresetMailgun( + paramsOrFirst: { domainId: string } | string, + ): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/presets/mailgun'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * List Outlook DNS records. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPresetOutlook(params: { + domainId: string; + }): Promise; + /** + * List Outlook DNS records. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPresetOutlook(domainId: string): Promise; + getPresetOutlook( + paramsOrFirst: { domainId: string } | string, + ): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/presets/outlook'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Add Outlook DNS records to the domain. This will create the required MX records + * for setting up Outlook email hosting for your domain. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + createPresetOutlook(params: { + domainId: string; + }): Promise; + /** + * Add Outlook DNS records to the domain. This will create the required MX records + * for setting up Outlook email hosting for your domain. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPresetOutlook(domainId: string): Promise; + createPresetOutlook( + paramsOrFirst: { domainId: string } | string, + ): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/presets/outlook'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * List ProtonMail DNS records. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPresetProtonMail(params: { + domainId: string; + }): Promise; + /** + * List ProtonMail DNS records. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPresetProtonMail(domainId: string): Promise; + getPresetProtonMail( + paramsOrFirst: { domainId: string } | string, + ): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/presets/proton-mail'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Add ProtonMail DNS records to the domain. This will create the required MX records + * for using ProtonMail with your custom domain. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + createPresetProtonMail(params: { + domainId: string; + }): Promise; + /** + * Add ProtonMail DNS records to the domain. This will create the required MX records + * for using ProtonMail with your custom domain. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPresetProtonMail(domainId: string): Promise; + createPresetProtonMail( + paramsOrFirst: { domainId: string } | string, + ): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/presets/proton-mail'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * List Zoho DNS records. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPresetZoho(params: { domainId: string }): Promise; + /** + * List Zoho DNS records. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPresetZoho(domainId: string): Promise; + getPresetZoho( + paramsOrFirst: { domainId: string } | string, + ): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/presets/zoho'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Add Zoho Mail DNS records to the domain. This will create the required MX records + * for setting up Zoho Mail on your domain. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + createPresetZoho(params: { + domainId: string; + }): Promise; + /** + * Add Zoho Mail DNS records to the domain. This will create the required MX records + * for setting up Zoho Mail on your domain. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPresetZoho(domainId: string): Promise; + createPresetZoho( + paramsOrFirst: { domainId: string } | string, + ): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/presets/zoho'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * List DNS records for a given domain. You can use this endpoint to list all the DNS records + * associated with your domain. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. You may filter on attributes such as type, name, value, etc. Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + listRecords(params: { + domainId: string; + queries?: string[]; + }): Promise; + /** + * List DNS records for a given domain. You can use this endpoint to list all the DNS records + * associated with your domain. + * + * @param {string} domainId - Domain unique ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. You may filter on attributes such as type, name, value, etc. Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRecords( + domainId: string, + queries?: string[], + ): Promise; + listRecords( + paramsOrFirst: { domainId: string; queries?: string[] } | string, + ...rest: [string[]?] + ): Promise { + let params: { domainId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + queries?: string[]; + }; + } else { + params = { + domainId: paramsOrFirst as string, + queries: rest[0] as string[], + }; + } + + const domainId = params.domainId; + const queries = params.queries; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/records'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Create a new A record for the given domain. A records are used to point a domain name + * to an IPv4 address. The record value should be a valid IPv4 address. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.name - Record name (subdomain). + * @param {string} params.value - IPv4 address for this A record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.comment - A comment explaining what this record is for. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRecordA(params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; + /** + * Create a new A record for the given domain. A records are used to point a domain name + * to an IPv4 address. The record value should be a valid IPv4 address. + * + * @param {string} domainId - Domain unique ID. + * @param {string} name - Record name (subdomain). + * @param {string} value - IPv4 address for this A record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} comment - A comment explaining what this record is for. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRecordA( + domainId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + createRecordA( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, string?] + ): Promise { + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + name: rest[0] as string, + value: rest[1] as string, + ttl: rest[2] as number, + comment: rest[3] as string, + }; + } + + const domainId = params.domainId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/a'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update an existing A record for the given domain. This endpoint allows you to modify + * the properties of an A record including its name (subdomain), IPv4 address, TTL, + * and optional comment. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.recordId - DNS record unique ID. + * @param {string} params.name - Record name (subdomain). + * @param {string} params.value - IPv4 address for this A record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.comment - A comment explaining what this record is for. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRecordA(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; + /** + * Update an existing A record for the given domain. This endpoint allows you to modify + * the properties of an A record including its name (subdomain), IPv4 address, TTL, + * and optional comment. + * + * @param {string} domainId - Domain unique ID. + * @param {string} recordId - DNS record unique ID. + * @param {string} name - Record name (subdomain). + * @param {string} value - IPv4 address for this A record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} comment - A comment explaining what this record is for. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRecordA( + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordA( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] + ): Promise { + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + recordId: rest[0] as string, + name: rest[1] as string, + value: rest[2] as string, + ttl: rest[3] as number, + comment: rest[4] as string, + }; + } + + const domainId = params.domainId; + const recordId = params.recordId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/a/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, apiPayload); + } + + /** + * Create a new AAAA record for the given domain. This endpoint allows you to add a new IPv6 DNS record + * to your domain. The record will be used to point a hostname to an IPv6 address. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.name - Record name (subdomain). + * @param {string} params.value - IPv6 address for this AAAA record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.comment - A comment explaining what this record is for. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRecordAAAA(params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; + /** + * Create a new AAAA record for the given domain. This endpoint allows you to add a new IPv6 DNS record + * to your domain. The record will be used to point a hostname to an IPv6 address. + * + * @param {string} domainId - Domain unique ID. + * @param {string} name - Record name (subdomain). + * @param {string} value - IPv6 address for this AAAA record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} comment - A comment explaining what this record is for. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRecordAAAA( + domainId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + createRecordAAAA( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, string?] + ): Promise { + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + name: rest[0] as string, + value: rest[1] as string, + ttl: rest[2] as number, + comment: rest[3] as string, + }; + } + + const domainId = params.domainId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/aaaa'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update an existing AAAA record for the given domain. This endpoint allows you to modify + * the properties of an existing AAAA record, including its name (subdomain), IPv6 address, + * TTL, and optional comment. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.recordId - DNS record unique ID. + * @param {string} params.name - Record name (subdomain). + * @param {string} params.value - IPv6 address for this AAAA record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRecordAAAA(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; + /** + * Update an existing AAAA record for the given domain. This endpoint allows you to modify + * the properties of an existing AAAA record, including its name (subdomain), IPv6 address, + * TTL, and optional comment. + * + * @param {string} domainId - Domain unique ID. + * @param {string} recordId - DNS record unique ID. + * @param {string} name - Record name (subdomain). + * @param {string} value - IPv6 address for this AAAA record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRecordAAAA( + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordAAAA( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] + ): Promise { + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + recordId: rest[0] as string, + name: rest[1] as string, + value: rest[2] as string, + ttl: rest[3] as number, + comment: rest[4] as string, + }; + } + + const domainId = params.domainId; + const recordId = params.recordId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/aaaa/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, apiPayload); + } + + /** + * Create a new ALIAS record for the given domain. This record type can be used to point your domain + * to another domain name that will serve as an alias. This is particularly useful when you want to + * map your domain to a target domain that may change its IP address. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.name - Record name. + * @param {string} params.value - Target domain for this ALIAS record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRecordAlias(params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; + /** + * Create a new ALIAS record for the given domain. This record type can be used to point your domain + * to another domain name that will serve as an alias. This is particularly useful when you want to + * map your domain to a target domain that may change its IP address. + * + * @param {string} domainId - Domain unique ID. + * @param {string} name - Record name. + * @param {string} value - Target domain for this ALIAS record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRecordAlias( + domainId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + createRecordAlias( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, string?] + ): Promise { + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + name: rest[0] as string, + value: rest[1] as string, + ttl: rest[2] as number, + comment: rest[3] as string, + }; + } + + const domainId = params.domainId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/alias'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update an existing ALIAS record for the specified domain. This endpoint allows you to modify + * the properties of an existing ALIAS record including its name, target domain, TTL, and comment. + * + * The ALIAS record type is similar to a CNAME record but can be used at the zone apex (root domain). + * It provides a way to map one domain name to another. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.recordId - DNS record unique ID. + * @param {string} params.name - Record name. + * @param {string} params.value - Target domain for this ALIAS record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRecordAlias(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; + /** + * Update an existing ALIAS record for the specified domain. This endpoint allows you to modify + * the properties of an existing ALIAS record including its name, target domain, TTL, and comment. + * + * The ALIAS record type is similar to a CNAME record but can be used at the zone apex (root domain). + * It provides a way to map one domain name to another. + * + * @param {string} domainId - Domain unique ID. + * @param {string} recordId - DNS record unique ID. + * @param {string} name - Record name. + * @param {string} value - Target domain for this ALIAS record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRecordAlias( + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordAlias( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] + ): Promise { + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + recordId: rest[0] as string, + name: rest[1] as string, + value: rest[2] as string, + ttl: rest[3] as number, + comment: rest[4] as string, + }; + } + + const domainId = params.domainId; + const recordId = params.recordId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/alias/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, apiPayload); + } + + /** + * Create a new CAA record for the given domain. CAA records are used to specify which + * Certificate Authorities (CAs) are allowed to issue SSL/TLS certificates for your domain. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.name - Record name. + * @param {string} params.value - CAA value (e.g. issuer domain). + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRecordCAA(params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; + /** + * Create a new CAA record for the given domain. CAA records are used to specify which + * Certificate Authorities (CAs) are allowed to issue SSL/TLS certificates for your domain. + * + * @param {string} domainId - Domain unique ID. + * @param {string} name - Record name. + * @param {string} value - CAA value (e.g. issuer domain). + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRecordCAA( + domainId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + createRecordCAA( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, string?] + ): Promise { + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + name: rest[0] as string, + value: rest[1] as string, + ttl: rest[2] as number, + comment: rest[3] as string, + }; + } + + const domainId = params.domainId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/caa'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update an existing CAA record for the given domain. A CAA (Certification Authority Authorization) + * record is used to specify which certificate authorities (CAs) are authorized to issue certificates + * for a domain. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.recordId - DNS record unique ID. + * @param {string} params.name - Record name. + * @param {string} params.value - CAA value (e.g. issuer domain). + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRecordCAA(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; + /** + * Update an existing CAA record for the given domain. A CAA (Certification Authority Authorization) + * record is used to specify which certificate authorities (CAs) are authorized to issue certificates + * for a domain. + * + * @param {string} domainId - Domain unique ID. + * @param {string} recordId - DNS record unique ID. + * @param {string} name - Record name. + * @param {string} value - CAA value (e.g. issuer domain). + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRecordCAA( + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordCAA( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] + ): Promise { + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + recordId: rest[0] as string, + name: rest[1] as string, + value: rest[2] as string, + ttl: rest[3] as number, + comment: rest[4] as string, + }; + } + + const domainId = params.domainId; + const recordId = params.recordId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/caa/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, apiPayload); + } + + /** + * Create a new CNAME record for the given domain. + * + * A CNAME record maps a subdomain to another domain name, allowing you to create aliases + * for your domain. For example, you can create a CNAME record to point 'blog.example.com' + * to 'example.wordpress.com'. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.name - Record name (subdomain). + * @param {string} params.value - Canonical target for this CNAME record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRecordCNAME(params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; + /** + * Create a new CNAME record for the given domain. + * + * A CNAME record maps a subdomain to another domain name, allowing you to create aliases + * for your domain. For example, you can create a CNAME record to point 'blog.example.com' + * to 'example.wordpress.com'. + * + * @param {string} domainId - Domain unique ID. + * @param {string} name - Record name (subdomain). + * @param {string} value - Canonical target for this CNAME record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRecordCNAME( + domainId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + createRecordCNAME( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, string?] + ): Promise { + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + name: rest[0] as string, + value: rest[1] as string, + ttl: rest[2] as number, + comment: rest[3] as string, + }; + } + + const domainId = params.domainId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/cname'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update an existing CNAME record for the given domain. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.recordId - DNS record unique ID. + * @param {string} params.name - Record name (subdomain). + * @param {string} params.value - Canonical target for this CNAME record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRecordCNAME(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; + /** + * Update an existing CNAME record for the given domain. + * + * @param {string} domainId - Domain unique ID. + * @param {string} recordId - DNS record unique ID. + * @param {string} name - Record name (subdomain). + * @param {string} value - Canonical target for this CNAME record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRecordCNAME( + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordCNAME( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] + ): Promise { + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + recordId: rest[0] as string, + name: rest[1] as string, + value: rest[2] as string, + ttl: rest[3] as number, + comment: rest[4] as string, + }; + } + + const domainId = params.domainId; + const recordId = params.recordId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/cname/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, apiPayload); + } + + /** + * Create a new HTTPS record for the given domain. This record is used to configure HTTPS + * settings for your domain, enabling secure communication over SSL/TLS. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.name - Record name (subdomain). + * @param {string} params.value - Target for the HTTPS record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRecordHTTPS(params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; + /** + * Create a new HTTPS record for the given domain. This record is used to configure HTTPS + * settings for your domain, enabling secure communication over SSL/TLS. + * + * @param {string} domainId - Domain unique ID. + * @param {string} name - Record name (subdomain). + * @param {string} value - Target for the HTTPS record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRecordHTTPS( + domainId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + createRecordHTTPS( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, string?] + ): Promise { + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + name: rest[0] as string, + value: rest[1] as string, + ttl: rest[2] as number, + comment: rest[3] as string, + }; + } + + const domainId = params.domainId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/https'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update an existing HTTPS record for the given domain. This endpoint allows you to modify + * the properties of an HTTPS record associated with your domain, including the name (subdomain), + * target value, TTL, and optional comment. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.recordId - DNS record unique ID. + * @param {string} params.name - Record name (subdomain). + * @param {string} params.value - Target for the HTTPS record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRecordHTTPS(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; + /** + * Update an existing HTTPS record for the given domain. This endpoint allows you to modify + * the properties of an HTTPS record associated with your domain, including the name (subdomain), + * target value, TTL, and optional comment. + * + * @param {string} domainId - Domain unique ID. + * @param {string} recordId - DNS record unique ID. + * @param {string} name - Record name (subdomain). + * @param {string} value - Target for the HTTPS record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRecordHTTPS( + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordHTTPS( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] + ): Promise { + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + recordId: rest[0] as string, + name: rest[1] as string, + value: rest[2] as string, + ttl: rest[3] as number, + comment: rest[4] as string, + }; + } + + const domainId = params.domainId; + const recordId = params.recordId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/https/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, apiPayload); + } + + /** + * Create a new MX record for the given domain. MX records are used to define the mail servers responsible + * for accepting email messages for the domain. Multiple MX records can be created with different priorities. + * The priority parameter determines the order in which mail servers are used, with lower values indicating + * higher priority. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.name - Record name (subdomain). + * @param {string} params.value - Mail server domain for this MX record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} params.priority - MX priority. Lower values are tried first. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRecordMX(params: { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + }): Promise; + /** + * Create a new MX record for the given domain. MX records are used to define the mail servers responsible + * for accepting email messages for the domain. Multiple MX records can be created with different priorities. + * The priority parameter determines the order in which mail servers are used, with lower values indicating + * higher priority. + * + * @param {string} domainId - Domain unique ID. + * @param {string} name - Record name (subdomain). + * @param {string} value - Mail server domain for this MX record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} priority - MX priority. Lower values are tried first. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRecordMX( + domainId: string, + name: string, + value: string, + ttl: number, + priority: number, + comment?: string, + ): Promise; + createRecordMX( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, number?, string?] + ): Promise { + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + name: rest[0] as string, + value: rest[1] as string, + ttl: rest[2] as number, + priority: rest[3] as number, + comment: rest[4] as string, + }; + } + + const domainId = params.domainId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const priority = params.priority; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + if (typeof priority === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "priority"', + ); + } + const apiPath = '/domains/{domainId}/records/mx'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update an existing MX record for the given domain. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.recordId - DNS record unique ID. + * @param {string} params.name - Record name (subdomain). + * @param {string} params.value - Mail server domain for this MX record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} params.priority - MX priority. Lower values are tried first. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRecordMX(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + }): Promise; + /** + * Update an existing MX record for the given domain. + * + * @param {string} domainId - Domain unique ID. + * @param {string} recordId - DNS record unique ID. + * @param {string} name - Record name (subdomain). + * @param {string} value - Mail server domain for this MX record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} priority - MX priority. Lower values are tried first. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRecordMX( + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + priority: number, + comment?: string, + ): Promise; + updateRecordMX( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, number?, string?] + ): Promise { + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + recordId: rest[0] as string, + name: rest[1] as string, + value: rest[2] as string, + ttl: rest[3] as number, + priority: rest[4] as number, + comment: rest[5] as string, + }; + } + + const domainId = params.domainId; + const recordId = params.recordId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const priority = params.priority; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + if (typeof priority === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "priority"', + ); + } + const apiPath = '/domains/{domainId}/records/mx/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, apiPayload); + } + + /** + * Create a new NS record for the given domain. NS records specify the nameservers that are used + * to resolve the domain name to IP addresses. Each domain can have multiple NS records. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.name - Record name (subdomain). + * @param {string} params.value - Nameserver target for this NS record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRecordNS(params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; + /** + * Create a new NS record for the given domain. NS records specify the nameservers that are used + * to resolve the domain name to IP addresses. Each domain can have multiple NS records. + * + * @param {string} domainId - Domain unique ID. + * @param {string} name - Record name (subdomain). + * @param {string} value - Nameserver target for this NS record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRecordNS( + domainId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + createRecordNS( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, string?] + ): Promise { + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + name: rest[0] as string, + value: rest[1] as string, + ttl: rest[2] as number, + comment: rest[3] as string, + }; + } + + const domainId = params.domainId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/ns'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update an existing NS record for the given domain. This endpoint allows you to modify + * the properties of an NS (nameserver) record associated with your domain. You can update + * the record name (subdomain), target nameserver value, TTL, and add or modify comments + * for better record management. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.recordId - DNS record unique ID. + * @param {string} params.name - Record name (subdomain). + * @param {string} params.value - Nameserver target for this NS record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRecordNS(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; + /** + * Update an existing NS record for the given domain. This endpoint allows you to modify + * the properties of an NS (nameserver) record associated with your domain. You can update + * the record name (subdomain), target nameserver value, TTL, and add or modify comments + * for better record management. + * + * @param {string} domainId - Domain unique ID. + * @param {string} recordId - DNS record unique ID. + * @param {string} name - Record name (subdomain). + * @param {string} value - Nameserver target for this NS record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRecordNS( + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordNS( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] + ): Promise { + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + recordId: rest[0] as string, + name: rest[1] as string, + value: rest[2] as string, + ttl: rest[3] as number, + comment: rest[4] as string, + }; + } + + const domainId = params.domainId; + const recordId = params.recordId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/ns/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, apiPayload); + } + + /** + * Create a new SRV record for the given domain. SRV records are used to define the location + * of servers for specific services. For example, they can be used to specify which server + * handles a specific service like SIP or XMPP for the domain. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.name - Record name (service name). + * @param {string} params.value - Target hostname for this SRV record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} params.priority - Record priority. Lower values are tried first. + * @param {number} params.weight - Record weight, used to share load between targets of equal priority. + * @param {number} params.port - Port number for the service. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRecordSRV(params: { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + }): Promise; + /** + * Create a new SRV record for the given domain. SRV records are used to define the location + * of servers for specific services. For example, they can be used to specify which server + * handles a specific service like SIP or XMPP for the domain. + * + * @param {string} domainId - Domain unique ID. + * @param {string} name - Record name (service name). + * @param {string} value - Target hostname for this SRV record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} priority - Record priority. Lower values are tried first. + * @param {number} weight - Record weight, used to share load between targets of equal priority. + * @param {number} port - Port number for the service. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRecordSRV( + domainId: string, + name: string, + value: string, + ttl: number, + priority: number, + weight: number, + port: number, + comment?: string, + ): Promise; + createRecordSRV( + paramsOrFirst: + | { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + } + | string, + ...rest: [string?, string?, number?, number?, number?, number?, string?] + ): Promise { + let params: { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + name: rest[0] as string, + value: rest[1] as string, + ttl: rest[2] as number, + priority: rest[3] as number, + weight: rest[4] as number, + port: rest[5] as number, + comment: rest[6] as string, + }; + } + + const domainId = params.domainId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const priority = params.priority; + const weight = params.weight; + const port = params.port; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + if (typeof priority === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "priority"', + ); + } + if (typeof weight === 'undefined') { + throw new AppwriteException('Missing required parameter: "weight"'); + } + if (typeof port === 'undefined') { + throw new AppwriteException('Missing required parameter: "port"'); + } + const apiPath = '/domains/{domainId}/records/srv'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof weight !== 'undefined') { + apiPayload['weight'] = weight; + } + if (typeof port !== 'undefined') { + apiPayload['port'] = port; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update an existing SRV record for the given domain. + * + * Required parameters: + * - domainId: Domain unique ID + * - recordId: DNS record unique ID + * - name: Record name (service name) + * - value: Target hostname for this SRV record + * - ttl: Time to live, in seconds + * - priority: Record priority + * - weight: Record weight + * - port: Port number for the service + * + * Optional parameters: + * - comment: A comment for this record + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.recordId - DNS record unique ID. + * @param {string} params.name - Record name (service name). + * @param {string} params.value - Target hostname for this SRV record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} params.priority - Record priority. Lower values are tried first. + * @param {number} params.weight - Record weight, used to share load between targets of equal priority. + * @param {number} params.port - Port number for the service. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRecordSRV(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + }): Promise; + /** + * Update an existing SRV record for the given domain. + * + * Required parameters: + * - domainId: Domain unique ID + * - recordId: DNS record unique ID + * - name: Record name (service name) + * - value: Target hostname for this SRV record + * - ttl: Time to live, in seconds + * - priority: Record priority + * - weight: Record weight + * - port: Port number for the service + * + * Optional parameters: + * - comment: A comment for this record + * + * @param {string} domainId - Domain unique ID. + * @param {string} recordId - DNS record unique ID. + * @param {string} name - Record name (service name). + * @param {string} value - Target hostname for this SRV record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {number} priority - Record priority. Lower values are tried first. + * @param {number} weight - Record weight, used to share load between targets of equal priority. + * @param {number} port - Port number for the service. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRecordSRV( + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + priority: number, + weight: number, + port: number, + comment?: string, + ): Promise; + updateRecordSRV( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + number?, + number?, + number?, + string?, + ] + ): Promise { + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + priority: number; + weight: number; + port: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + recordId: rest[0] as string, + name: rest[1] as string, + value: rest[2] as string, + ttl: rest[3] as number, + priority: rest[4] as number, + weight: rest[5] as number, + port: rest[6] as number, + comment: rest[7] as string, + }; + } + + const domainId = params.domainId; + const recordId = params.recordId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const priority = params.priority; + const weight = params.weight; + const port = params.port; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + if (typeof priority === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "priority"', + ); + } + if (typeof weight === 'undefined') { + throw new AppwriteException('Missing required parameter: "weight"'); + } + if (typeof port === 'undefined') { + throw new AppwriteException('Missing required parameter: "port"'); + } + const apiPath = '/domains/{domainId}/records/srv/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof weight !== 'undefined') { + apiPayload['weight'] = weight; + } + if (typeof port !== 'undefined') { + apiPayload['port'] = port; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, apiPayload); + } + + /** + * Create a new TXT record for the given domain. TXT records can be used + * to provide additional information about your domain, such as domain + * verification records, SPF records, or DKIM records. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.name - Record name (subdomain) for the TXT record. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.value - TXT record value. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRecordTXT(params: { + domainId: string; + name: string; + ttl: number; + value?: string; + comment?: string; + }): Promise; + /** + * Create a new TXT record for the given domain. TXT records can be used + * to provide additional information about your domain, such as domain + * verification records, SPF records, or DKIM records. + * + * @param {string} domainId - Domain unique ID. + * @param {string} name - Record name (subdomain) for the TXT record. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} value - TXT record value. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRecordTXT( + domainId: string, + name: string, + ttl: number, + value?: string, + comment?: string, + ): Promise; + createRecordTXT( + paramsOrFirst: + | { + domainId: string; + name: string; + ttl: number; + value?: string; + comment?: string; + } + | string, + ...rest: [string?, number?, string?, string?] + ): Promise { + let params: { + domainId: string; + name: string; + ttl: number; + value?: string; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + name: string; + ttl: number; + value?: string; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + name: rest[0] as string, + ttl: rest[1] as number, + value: rest[2] as string, + comment: rest[3] as string, + }; + } + + const domainId = params.domainId; + const name = params.name; + const ttl = params.ttl; + const value = params.value; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/txt'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update an existing TXT record for the given domain. + * + * Update the TXT record details for a specific domain by providing the domain ID, + * record ID, and the new record configuration including name, value, TTL, and an optional comment. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.recordId - DNS record unique ID. + * @param {string} params.name - Record name (subdomain) for the TXT record. + * @param {string} params.value - TXT record value. + * @param {number} params.ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} params.comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRecordTXT(params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }): Promise; + /** + * Update an existing TXT record for the given domain. + * + * Update the TXT record details for a specific domain by providing the domain ID, + * record ID, and the new record configuration including name, value, TTL, and an optional comment. + * + * @param {string} domainId - Domain unique ID. + * @param {string} recordId - DNS record unique ID. + * @param {string} name - Record name (subdomain) for the TXT record. + * @param {string} value - TXT record value. + * @param {number} ttl - Time to live, in seconds. Must be between 1 and 2147483647. + * @param {string} comment - A comment for this record. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRecordTXT( + domainId: string, + recordId: string, + name: string, + value: string, + ttl: number, + comment?: string, + ): Promise; + updateRecordTXT( + paramsOrFirst: + | { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + } + | string, + ...rest: [string?, string?, string?, number?, string?] + ): Promise { + let params: { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + name: string; + value: string; + ttl: number; + comment?: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + recordId: rest[0] as string, + name: rest[1] as string, + value: rest[2] as string, + ttl: rest[3] as number, + comment: rest[4] as string, + }; + } + + const domainId = params.domainId; + const recordId = params.recordId; + const name = params.name; + const value = params.value; + const ttl = params.ttl; + const comment = params.comment; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + if (typeof ttl === 'undefined') { + throw new AppwriteException('Missing required parameter: "ttl"'); + } + const apiPath = '/domains/{domainId}/records/txt/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + if (typeof comment !== 'undefined') { + apiPayload['comment'] = comment; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, apiPayload); + } + + /** + * Get a single DNS record for a given domain by record ID. + * + * This endpoint allows you to retrieve a specific DNS record associated with a domain + * using its unique identifier. The record contains information about the DNS configuration + * such as type, value, and TTL settings. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.recordId - DNS record unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getRecord(params: { + domainId: string; + recordId: string; + }): Promise; + /** + * Get a single DNS record for a given domain by record ID. + * + * This endpoint allows you to retrieve a specific DNS record associated with a domain + * using its unique identifier. The record contains information about the DNS configuration + * such as type, value, and TTL settings. + * + * @param {string} domainId - Domain unique ID. + * @param {string} recordId - DNS record unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRecord(domainId: string, recordId: string): Promise; + getRecord( + paramsOrFirst: { domainId: string; recordId: string } | string, + ...rest: [string?] + ): Promise { + let params: { domainId: string; recordId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + recordId: rest[0] as string, + }; + } + + const domainId = params.domainId; + const recordId = params.recordId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + const apiPath = '/domains/{domainId}/records/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Delete a DNS record for the given domain. This endpoint allows you to delete an existing DNS record + * from a specific domain. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.recordId - DNS record unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteRecord(params: { domainId: string; recordId: string }): Promise<{}>; + /** + * Delete a DNS record for the given domain. This endpoint allows you to delete an existing DNS record + * from a specific domain. + * + * @param {string} domainId - Domain unique ID. + * @param {string} recordId - DNS record unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteRecord(domainId: string, recordId: string): Promise<{}>; + deleteRecord( + paramsOrFirst: { domainId: string; recordId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { domainId: string; recordId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + recordId: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + recordId: rest[0] as string, + }; + } + + const domainId = params.domainId; + const recordId = params.recordId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof recordId === 'undefined' || recordId === '') { + throw new AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + const apiPath = '/domains/{domainId}/records/{recordId}' + .replace('{domainId}', encodeURIComponent(String(domainId))) + .replace('{recordId}', encodeURIComponent(String(recordId))); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } + + /** + * Update the team ID for a specific domain. The caller must administer the current + * team and be an owner of the destination team. + * + * Updating the team ID will transfer ownership and access control of the domain + * and all its DNS records to the new team. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.teamId - New team unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateTeam(params: { + domainId: string; + teamId: string; + }): Promise; + /** + * Update the team ID for a specific domain. The caller must administer the current + * team and be an owner of the destination team. + * + * Updating the team ID will transfer ownership and access control of the domain + * and all its DNS records to the new team. + * + * @param {string} domainId - Domain unique ID. + * @param {string} teamId - New team unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTeam(domainId: string, teamId: string): Promise; + updateTeam( + paramsOrFirst: { domainId: string; teamId: string } | string, + ...rest: [string?] + ): Promise { + let params: { domainId: string; teamId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + teamId: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + teamId: rest[0] as string, + }; + } + + const domainId = params.domainId; + const teamId = params.teamId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof teamId === 'undefined') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + const apiPath = '/domains/{domainId}/team'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + if (typeof teamId !== 'undefined') { + apiPayload['teamId'] = teamId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + + /** + * Retrieve the current transfer status for a domain. Returns the status, an optional reason, and a timestamp of the last status change. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getTransferStatus(params: { + domainId: string; + }): Promise; + /** + * Retrieve the current transfer status for a domain. Returns the status, an optional reason, and a timestamp of the last status change. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getTransferStatus(domainId: string): Promise; + getTransferStatus( + paramsOrFirst: { domainId: string } | string, + ): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/transfers/status'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Retrieve the DNS zone file for the given domain. This endpoint will return the DNS + * zone file in a standardized format that can be used to configure DNS servers. + * + * @param {string} params.domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getZone(params: { domainId: string }): Promise; + /** + * Retrieve the DNS zone file for the given domain. This endpoint will return the DNS + * zone file in a standardized format that can be used to configure DNS servers. + * + * @param {string} domainId - Domain unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getZone(domainId: string): Promise; + getZone(paramsOrFirst: { domainId: string } | string): Promise { + let params: { domainId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { domainId: string }; + } else { + params = { + domainId: paramsOrFirst as string, + }; + } + + const domainId = params.domainId; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + const apiPath = '/domains/{domainId}/zone'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'text/plain', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload, 'text'); + } + + /** + * Update the DNS zone for the given domain using the provided zone file content. + * All parsed records are imported and then the main domain document is returned. + * + * @param {string} params.domainId - Domain unique ID. + * @param {string} params.content - DNS zone file content as a string. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateZone(params: { + domainId: string; + content: string; + }): Promise; + /** + * Update the DNS zone for the given domain using the provided zone file content. + * All parsed records are imported and then the main domain document is returned. + * + * @param {string} domainId - Domain unique ID. + * @param {string} content - DNS zone file content as a string. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateZone(domainId: string, content: string): Promise; + updateZone( + paramsOrFirst: { domainId: string; content: string } | string, + ...rest: [string?] + ): Promise { + let params: { domainId: string; content: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domainId: string; + content: string; + }; + } else { + params = { + domainId: paramsOrFirst as string, + content: rest[0] as string, + }; + } + + const domainId = params.domainId; + const content = params.content; + if (typeof domainId === 'undefined' || domainId === '') { + throw new AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + if (typeof content === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "content"', + ); + } + const apiPath = '/domains/{domainId}/zone'.replace( + '{domainId}', + encodeURIComponent(String(domainId)), + ); + const apiPayload: Payload = {}; + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, apiPayload); + } +} diff --git a/src/services/functions.ts b/src/services/functions.ts index 03d49dca..633ad32a 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -466,12 +466,44 @@ export class Functions { /** * Get a list of all runtimes that are currently active on your instance. * + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ - listRuntimes(): Promise { + listRuntimes(params?: { total?: boolean }): Promise; + /** + * Get a list of all runtimes that are currently active on your instance. + * + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRuntimes(total?: boolean): Promise; + listRuntimes( + paramsOrFirst?: { total?: boolean } | boolean, + ): Promise { + let params: { total?: boolean }; + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { total?: boolean }; + } else { + params = { + total: paramsOrFirst as boolean, + }; + } + + const total = params.total; const apiPath = '/functions/runtimes'; const apiPayload: Payload = {}; + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -486,25 +518,32 @@ export class Functions { * List allowed function specifications for this instance. * * @param {string} params.type - Specification type to list. Can be one of: runtimes, builds. Defaults to runtimes. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ listSpecifications(params?: { type?: string; + total?: boolean; }): Promise; /** * List allowed function specifications for this instance. * * @param {string} type - Specification type to list. Can be one of: runtimes, builds. Defaults to runtimes. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listSpecifications(type?: string): Promise; listSpecifications( - paramsOrFirst?: { type?: string } | string, + type?: string, + total?: boolean, + ): Promise; + listSpecifications( + paramsOrFirst?: { type?: string; total?: boolean } | string, + ...rest: [boolean?] ): Promise { - let params: { type?: string }; + let params: { type?: string; total?: boolean }; if ( !paramsOrFirst || @@ -512,19 +551,27 @@ export class Functions { typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst)) ) { - params = (paramsOrFirst || {}) as { type?: string }; + params = (paramsOrFirst || {}) as { + type?: string; + total?: boolean; + }; } else { params = { type: paramsOrFirst as string, + total: rest[0] as boolean, }; } const type = params.type; + const total = params.total; const apiPath = '/functions/specifications'; const apiPayload: Payload = {}; if (typeof type !== 'undefined') { apiPayload['type'] = type; } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/locale.ts b/src/services/locale.ts index 85b80390..949a1e52 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -32,12 +32,44 @@ export class Locale { /** * List of all locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). * + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ - listCodes(): Promise { + listCodes(params?: { total?: boolean }): Promise; + /** + * List of all locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). + * + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listCodes(total?: boolean): Promise; + listCodes( + paramsOrFirst?: { total?: boolean } | boolean, + ): Promise { + let params: { total?: boolean }; + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { total?: boolean }; + } else { + params = { + total: paramsOrFirst as boolean, + }; + } + + const total = params.total; const apiPath = '/locale/codes'; const apiPayload: Payload = {}; + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -51,12 +83,44 @@ export class Locale { /** * List of all continents. You can use the locale header to get the data in a supported language. * + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listContinents(params?: { total?: boolean }): Promise; + /** + * List of all continents. You can use the locale header to get the data in a supported language. + * + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. */ - listContinents(): Promise { + listContinents(total?: boolean): Promise; + listContinents( + paramsOrFirst?: { total?: boolean } | boolean, + ): Promise { + let params: { total?: boolean }; + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { total?: boolean }; + } else { + params = { + total: paramsOrFirst as boolean, + }; + } + + const total = params.total; const apiPath = '/locale/continents'; const apiPayload: Payload = {}; + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -70,12 +134,44 @@ export class Locale { /** * List of all countries. You can use the locale header to get the data in a supported language. * + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listCountries(params?: { total?: boolean }): Promise; + /** + * List of all countries. You can use the locale header to get the data in a supported language. + * + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. */ - listCountries(): Promise { + listCountries(total?: boolean): Promise; + listCountries( + paramsOrFirst?: { total?: boolean } | boolean, + ): Promise { + let params: { total?: boolean }; + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { total?: boolean }; + } else { + params = { + total: paramsOrFirst as boolean, + }; + } + + const total = params.total; const apiPath = '/locale/countries'; const apiPayload: Payload = {}; + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -89,12 +185,44 @@ export class Locale { /** * List of all countries that are currently members of the EU. You can use the locale header to get the data in a supported language. * + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listCountriesEU(params?: { total?: boolean }): Promise; + /** + * List of all countries that are currently members of the EU. You can use the locale header to get the data in a supported language. + * + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. */ - listCountriesEU(): Promise { + listCountriesEU(total?: boolean): Promise; + listCountriesEU( + paramsOrFirst?: { total?: boolean } | boolean, + ): Promise { + let params: { total?: boolean }; + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { total?: boolean }; + } else { + params = { + total: paramsOrFirst as boolean, + }; + } + + const total = params.total; const apiPath = '/locale/countries/eu'; const apiPayload: Payload = {}; + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -108,12 +236,46 @@ export class Locale { /** * List of all countries phone codes. You can use the locale header to get the data in a supported language. * + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listCountriesPhones(params?: { + total?: boolean; + }): Promise; + /** + * List of all countries phone codes. You can use the locale header to get the data in a supported language. + * + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. */ - listCountriesPhones(): Promise { + listCountriesPhones(total?: boolean): Promise; + listCountriesPhones( + paramsOrFirst?: { total?: boolean } | boolean, + ): Promise { + let params: { total?: boolean }; + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { total?: boolean }; + } else { + params = { + total: paramsOrFirst as boolean, + }; + } + + const total = params.total; const apiPath = '/locale/countries/phones'; const apiPayload: Payload = {}; + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -127,12 +289,44 @@ export class Locale { /** * List of all currencies, including currency symbol, name, plural, and decimal digits for all major and minor currencies. You can use the locale header to get the data in a supported language. * + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listCurrencies(params?: { total?: boolean }): Promise; + /** + * List of all currencies, including currency symbol, name, plural, and decimal digits for all major and minor currencies. You can use the locale header to get the data in a supported language. + * + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. */ - listCurrencies(): Promise { + listCurrencies(total?: boolean): Promise; + listCurrencies( + paramsOrFirst?: { total?: boolean } | boolean, + ): Promise { + let params: { total?: boolean }; + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { total?: boolean }; + } else { + params = { + total: paramsOrFirst as boolean, + }; + } + + const total = params.total; const apiPath = '/locale/currencies'; const apiPayload: Payload = {}; + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -146,12 +340,44 @@ export class Locale { /** * List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language. * + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listLanguages(params?: { total?: boolean }): Promise; + /** + * List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language. + * + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. */ - listLanguages(): Promise { + listLanguages(total?: boolean): Promise; + listLanguages( + paramsOrFirst?: { total?: boolean } | boolean, + ): Promise { + let params: { total?: boolean }; + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { total?: boolean }; + } else { + params = { + total: paramsOrFirst as boolean, + }; + } + + const total = params.total; const apiPath = '/locale/languages'; const apiPayload: Payload = {}; + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 0f812313..beb15901 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -104,6 +104,8 @@ export class Messaging { * @param {boolean} params.draft - Is message a draft * @param {boolean} params.html - Is content of type HTML * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string} params.replyToEmail - Email address to reply to. If not set, defaults to the sender email address. + * @param {string} params.replyToName - Name of the reply to recipient. If not set, defaults to the sender name. * @throws {AppwriteException} * @returns {Promise} */ @@ -120,6 +122,8 @@ export class Messaging { draft?: boolean; html?: boolean; scheduledAt?: string; + replyToEmail?: string; + replyToName?: string; }): Promise; /** * Create a new email message. @@ -136,6 +140,8 @@ export class Messaging { * @param {boolean} draft - Is message a draft * @param {boolean} html - Is content of type HTML * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string} replyToEmail - Email address to reply to. If not set, defaults to the sender email address. + * @param {string} replyToName - Name of the reply to recipient. If not set, defaults to the sender name. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -153,6 +159,8 @@ export class Messaging { draft?: boolean, html?: boolean, scheduledAt?: string, + replyToEmail?: string, + replyToName?: string, ): Promise; createEmail( paramsOrFirst: @@ -169,6 +177,8 @@ export class Messaging { draft?: boolean; html?: boolean; scheduledAt?: string; + replyToEmail?: string; + replyToName?: string; } | string, ...rest: [ @@ -183,6 +193,8 @@ export class Messaging { boolean?, boolean?, string?, + string?, + string?, ] ): Promise { let params: { @@ -198,6 +210,8 @@ export class Messaging { draft?: boolean; html?: boolean; scheduledAt?: string; + replyToEmail?: string; + replyToName?: string; }; if ( @@ -218,6 +232,8 @@ export class Messaging { draft?: boolean; html?: boolean; scheduledAt?: string; + replyToEmail?: string; + replyToName?: string; }; } else { params = { @@ -233,6 +249,8 @@ export class Messaging { draft: rest[8] as boolean, html: rest[9] as boolean, scheduledAt: rest[10] as string, + replyToEmail: rest[11] as string, + replyToName: rest[12] as string, }; } @@ -248,6 +266,8 @@ export class Messaging { const draft = params.draft; const html = params.html; const scheduledAt = params.scheduledAt; + const replyToEmail = params.replyToEmail; + const replyToName = params.replyToName; if (typeof messageId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "messageId"', @@ -301,6 +321,12 @@ export class Messaging { if (typeof scheduledAt !== 'undefined') { apiPayload['scheduledAt'] = scheduledAt; } + if (typeof replyToEmail !== 'undefined') { + apiPayload['replyToEmail'] = replyToEmail; + } + if (typeof replyToName !== 'undefined') { + apiPayload['replyToName'] = replyToName; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -328,6 +354,8 @@ export class Messaging { * @param {string[]} params.bcc - Array of target IDs to be added as BCC. * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as :. + * @param {string} params.replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. + * @param {string} params.replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. * @throws {AppwriteException} * @returns {Promise} */ @@ -344,6 +372,8 @@ export class Messaging { bcc?: string[]; scheduledAt?: string; attachments?: string[]; + replyToEmail?: string; + replyToName?: string; }): Promise; /** * Update an email message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. @@ -361,6 +391,8 @@ export class Messaging { * @param {string[]} bcc - Array of target IDs to be added as BCC. * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as :. + * @param {string} replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. + * @param {string} replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -378,6 +410,8 @@ export class Messaging { bcc?: string[], scheduledAt?: string, attachments?: string[], + replyToEmail?: string, + replyToName?: string, ): Promise; updateEmail( paramsOrFirst: @@ -394,6 +428,8 @@ export class Messaging { bcc?: string[]; scheduledAt?: string; attachments?: string[]; + replyToEmail?: string; + replyToName?: string; } | string, ...rest: [ @@ -408,6 +444,8 @@ export class Messaging { string[]?, string?, string[]?, + string?, + string?, ] ): Promise { let params: { @@ -423,6 +461,8 @@ export class Messaging { bcc?: string[]; scheduledAt?: string; attachments?: string[]; + replyToEmail?: string; + replyToName?: string; }; if ( @@ -443,6 +483,8 @@ export class Messaging { bcc?: string[]; scheduledAt?: string; attachments?: string[]; + replyToEmail?: string; + replyToName?: string; }; } else { params = { @@ -458,6 +500,8 @@ export class Messaging { bcc: rest[8] as string[], scheduledAt: rest[9] as string, attachments: rest[10] as string[], + replyToEmail: rest[11] as string, + replyToName: rest[12] as string, }; } @@ -473,6 +517,8 @@ export class Messaging { const bcc = params.bcc; const scheduledAt = params.scheduledAt; const attachments = params.attachments; + const replyToEmail = params.replyToEmail; + const replyToName = params.replyToName; if (typeof messageId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "messageId"', @@ -516,6 +562,12 @@ export class Messaging { if (typeof attachments !== 'undefined') { apiPayload['attachments'] = attachments; } + if (typeof replyToEmail !== 'undefined') { + apiPayload['replyToEmail'] = replyToEmail; + } + if (typeof replyToName !== 'undefined') { + apiPayload['replyToName'] = replyToName; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -549,6 +601,7 @@ export class Messaging { * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. + * @param {string} params.channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Available only for Android Platform. * @throws {AppwriteException} * @returns {Promise} */ @@ -572,6 +625,7 @@ export class Messaging { contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; + channelId?: string; }): Promise; /** * Create a new push notification. @@ -595,6 +649,7 @@ export class Messaging { * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. + * @param {string} channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Available only for Android Platform. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -619,6 +674,7 @@ export class Messaging { contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority, + channelId?: string, ): Promise; createPush( paramsOrFirst: @@ -642,6 +698,7 @@ export class Messaging { contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; + channelId?: string; } | string, ...rest: [ @@ -663,6 +720,7 @@ export class Messaging { boolean?, boolean?, MessagePriority?, + string?, ] ): Promise { let params: { @@ -685,6 +743,7 @@ export class Messaging { contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; + channelId?: string; }; if ( @@ -712,6 +771,7 @@ export class Messaging { contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; + channelId?: string; }; } else { params = { @@ -734,6 +794,7 @@ export class Messaging { contentAvailable: rest[15] as boolean, critical: rest[16] as boolean, priority: rest[17] as MessagePriority, + channelId: rest[18] as string, }; } @@ -756,6 +817,7 @@ export class Messaging { const contentAvailable = params.contentAvailable; const critical = params.critical; const priority = params.priority; + const channelId = params.channelId; if (typeof messageId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "messageId"', @@ -820,6 +882,9 @@ export class Messaging { if (typeof priority !== 'undefined') { apiPayload['priority'] = priority; } + if (typeof channelId !== 'undefined') { + apiPayload['channelId'] = channelId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -854,6 +919,7 @@ export class Messaging { * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + * @param {string} params.channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. * @throws {AppwriteException} * @returns {Promise} */ @@ -877,6 +943,7 @@ export class Messaging { contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; + channelId?: string; }): Promise; /** * Update a push notification by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. @@ -901,6 +968,7 @@ export class Messaging { * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + * @param {string} channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -925,6 +993,7 @@ export class Messaging { contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority, + channelId?: string, ): Promise; updatePush( paramsOrFirst: @@ -948,6 +1017,7 @@ export class Messaging { contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; + channelId?: string; } | string, ...rest: [ @@ -969,6 +1039,7 @@ export class Messaging { boolean?, boolean?, MessagePriority?, + string?, ] ): Promise { let params: { @@ -991,6 +1062,7 @@ export class Messaging { contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; + channelId?: string; }; if ( @@ -1018,6 +1090,7 @@ export class Messaging { contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; + channelId?: string; }; } else { params = { @@ -1040,6 +1113,7 @@ export class Messaging { contentAvailable: rest[15] as boolean, critical: rest[16] as boolean, priority: rest[17] as MessagePriority, + channelId: rest[18] as string, }; } @@ -1062,6 +1136,7 @@ export class Messaging { const contentAvailable = params.contentAvailable; const critical = params.critical; const priority = params.priority; + const channelId = params.channelId; if (typeof messageId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "messageId"', @@ -1126,6 +1201,9 @@ export class Messaging { if (typeof priority !== 'undefined') { apiPayload['priority'] = priority; } + if (typeof channelId !== 'undefined') { + apiPayload['channelId'] = channelId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2641,6 +2719,243 @@ export class Messaging { return this.client.call('patch', uri, apiHeaders, apiPayload); } + /** + * Create a new Appwrite push provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @throws {AppwriteException} + * @returns {Promise} + */ + createAppwriteProvider(params: { + providerId: string; + name: string; + enabled?: boolean; + qos?: number; + expiry?: number; + }): Promise; + /** + * Create a new Appwrite push provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createAppwriteProvider( + providerId: string, + name: string, + enabled?: boolean, + qos?: number, + expiry?: number, + ): Promise; + createAppwriteProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + enabled?: boolean; + qos?: number; + expiry?: number; + } + | string, + ...rest: [string?, boolean?, number?, number?] + ): Promise { + let params: { + providerId: string; + name: string; + enabled?: boolean; + qos?: number; + expiry?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + enabled?: boolean; + qos?: number; + expiry?: number; + }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + qos: rest[2] as number, + expiry: rest[3] as number, + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const qos = params.qos; + const expiry = params.expiry; + if (typeof providerId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/messaging/providers/appwrite'; + const apiPayload: Payload = {}; + if (typeof providerId !== 'undefined') { + apiPayload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof qos !== 'undefined') { + apiPayload['qos'] = qos; + } + if (typeof expiry !== 'undefined') { + apiPayload['expiry'] = expiry; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update an Appwrite push provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @throws {AppwriteException} + * @returns {Promise} + */ + updateAppwriteProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + qos?: number; + expiry?: number; + }): Promise; + /** + * Update an Appwrite push provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateAppwriteProvider( + providerId: string, + name?: string, + enabled?: boolean, + qos?: number, + expiry?: number, + ): Promise; + updateAppwriteProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + qos?: number; + expiry?: number; + } + | string, + ...rest: [string?, boolean?, number?, number?] + ): Promise { + let params: { + providerId: string; + name?: string; + enabled?: boolean; + qos?: number; + expiry?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + qos?: number; + expiry?: number; + }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + qos: rest[2] as number, + expiry: rest[3] as number, + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const qos = params.qos; + const expiry = params.expiry; + if (typeof providerId === 'undefined' || providerId === '') { + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); + } + const apiPath = '/messaging/providers/appwrite/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof qos !== 'undefined') { + apiPayload['qos'] = qos; + } + if (typeof expiry !== 'undefined') { + apiPayload['expiry'] = expiry; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + /** * Create a new Firebase Cloud Messaging provider. * @@ -6945,6 +7260,8 @@ export class Messaging { * @param {string} params.topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} params.name - Topic Name. * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} */ @@ -6952,6 +7269,8 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; + qos?: number; + expiry?: number; }): Promise; /** * Create a new topic. @@ -6959,6 +7278,8 @@ export class Messaging { * @param {string} topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} name - Topic Name. * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -6967,13 +7288,28 @@ export class Messaging { topicId: string, name: string, subscribe?: string[], + qos?: number, + expiry?: number, ): Promise; createTopic( paramsOrFirst: - { topicId: string; name: string; subscribe?: string[] } | string, - ...rest: [string?, string[]?] + | { + topicId: string; + name: string; + subscribe?: string[]; + qos?: number; + expiry?: number; + } + | string, + ...rest: [string?, string[]?, number?, number?] ): Promise { - let params: { topicId: string; name: string; subscribe?: string[] }; + let params: { + topicId: string; + name: string; + subscribe?: string[]; + qos?: number; + expiry?: number; + }; if ( paramsOrFirst && @@ -6984,18 +7320,24 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; + qos?: number; + expiry?: number; }; } else { params = { topicId: paramsOrFirst as string, name: rest[0] as string, subscribe: rest[1] as string[], + qos: rest[2] as number, + expiry: rest[3] as number, }; } const topicId = params.topicId; const name = params.name; const subscribe = params.subscribe; + const qos = params.qos; + const expiry = params.expiry; if (typeof topicId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "topicId"', @@ -7015,6 +7357,12 @@ export class Messaging { if (typeof subscribe !== 'undefined') { apiPayload['subscribe'] = subscribe; } + if (typeof qos !== 'undefined') { + apiPayload['qos'] = qos; + } + if (typeof expiry !== 'undefined') { + apiPayload['expiry'] = expiry; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -7090,6 +7438,8 @@ export class Messaging { * @param {string} params.topicId - Topic ID. * @param {string} params.name - Topic Name. * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} */ @@ -7097,6 +7447,8 @@ export class Messaging { topicId: string; name?: string; subscribe?: string[]; + qos?: number; + expiry?: number; }): Promise; /** * Update a topic by its unique ID. @@ -7105,6 +7457,8 @@ export class Messaging { * @param {string} topicId - Topic ID. * @param {string} name - Topic Name. * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -7113,13 +7467,28 @@ export class Messaging { topicId: string, name?: string, subscribe?: string[], + qos?: number, + expiry?: number, ): Promise; updateTopic( paramsOrFirst: - { topicId: string; name?: string; subscribe?: string[] } | string, - ...rest: [string?, string[]?] + | { + topicId: string; + name?: string; + subscribe?: string[]; + qos?: number; + expiry?: number; + } + | string, + ...rest: [string?, string[]?, number?, number?] ): Promise { - let params: { topicId: string; name?: string; subscribe?: string[] }; + let params: { + topicId: string; + name?: string; + subscribe?: string[]; + qos?: number; + expiry?: number; + }; if ( paramsOrFirst && @@ -7130,18 +7499,24 @@ export class Messaging { topicId: string; name?: string; subscribe?: string[]; + qos?: number; + expiry?: number; }; } else { params = { topicId: paramsOrFirst as string, name: rest[0] as string, subscribe: rest[1] as string[], + qos: rest[2] as number, + expiry: rest[3] as number, }; } const topicId = params.topicId; const name = params.name; const subscribe = params.subscribe; + const qos = params.qos; + const expiry = params.expiry; if (typeof topicId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "topicId"', @@ -7158,6 +7533,12 @@ export class Messaging { if (typeof subscribe !== 'undefined') { apiPayload['subscribe'] = subscribe; } + if (typeof qos !== 'undefined') { + apiPayload['qos'] = qos; + } + if (typeof expiry !== 'undefined') { + apiPayload['expiry'] = expiry; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/oauth-2.ts b/src/services/oauth-2.ts index b05acbdb..2f6e67db 100644 --- a/src/services/oauth-2.ts +++ b/src/services/oauth-2.ts @@ -801,6 +801,111 @@ export class Oauth2 { return this.client.call('get', uri, apiHeaders, apiPayload); } + /** + * Introspect an OAuth2 access token or refresh token. Authenticate with an API key holding the `oauth2.introspect` scope to introspect any token in the project, or with the client credentials of the app the token was issued to. + * + * @param {string} params.token - The access token or refresh token to introspect. + * @param {string} params.tokenTypeHint - Type of token to introspect. Can be one of: `access_token` or `refresh_token`. + * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + * @param {string} params.clientSecret - OAuth2 client secret. + * @throws {AppwriteException} + * @returns {Promise} + */ + introspect(params: { + token: string; + tokenTypeHint?: string; + clientId?: string; + clientSecret?: string; + }): Promise; + /** + * Introspect an OAuth2 access token or refresh token. Authenticate with an API key holding the `oauth2.introspect` scope to introspect any token in the project, or with the client credentials of the app the token was issued to. + * + * @param {string} token - The access token or refresh token to introspect. + * @param {string} tokenTypeHint - Type of token to introspect. Can be one of: `access_token` or `refresh_token`. + * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + * @param {string} clientSecret - OAuth2 client secret. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + introspect( + token: string, + tokenTypeHint?: string, + clientId?: string, + clientSecret?: string, + ): Promise; + introspect( + paramsOrFirst: + | { + token: string; + tokenTypeHint?: string; + clientId?: string; + clientSecret?: string; + } + | string, + ...rest: [string?, string?, string?] + ): Promise { + let params: { + token: string; + tokenTypeHint?: string; + clientId?: string; + clientSecret?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + token: string; + tokenTypeHint?: string; + clientId?: string; + clientSecret?: string; + }; + } else { + params = { + token: paramsOrFirst as string, + tokenTypeHint: rest[0] as string, + clientId: rest[1] as string, + clientSecret: rest[2] as string, + }; + } + + const token = params.token; + const tokenTypeHint = params.tokenTypeHint; + const clientId = params.clientId; + const clientSecret = params.clientSecret; + if (typeof token === 'undefined') { + throw new AppwriteException('Missing required parameter: "token"'); + } + const apiPath = '/oauth2/{project_id}/introspect'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); + const apiPayload: Payload = {}; + if (typeof token !== 'undefined') { + apiPayload['token'] = token; + } + if (typeof tokenTypeHint !== 'undefined') { + apiPayload['token_type_hint'] = tokenTypeHint; + } + if (typeof clientId !== 'undefined') { + apiPayload['client_id'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + apiPayload['client_secret'] = clientSecret; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + /** * List the organizations the OAuth2 access token can access. Resolves the token's `organization` authorization details, expanding the `*` wildcard into the concrete set of organizations the user can see. * diff --git a/src/services/organization.ts b/src/services/organization.ts index a79629b9..fa531f08 100644 --- a/src/services/organization.ts +++ b/src/services/organization.ts @@ -3,6 +3,7 @@ import type { Models } from '../models'; import { OrganizationKeyScopes } from '../enums/organization-key-scopes'; import { Region } from '../enums/region'; +import { ProjectKeyScopes } from '../enums/project-key-scopes'; export class Organization { client: Client; @@ -1557,4 +1558,449 @@ export class Organization { return this.client.call('delete', uri, apiHeaders, apiPayload); } + + /** + * Get a list of all API keys of a project in your organization. + * + * @param {string} params.projectId - Project unique ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire, accessedAt, name, scopes + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listProjectKeys(params: { + projectId: string; + queries?: string[]; + total?: boolean; + }): Promise; + /** + * Get a list of all API keys of a project in your organization. + * + * @param {string} projectId - Project unique ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire, accessedAt, name, scopes + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listProjectKeys( + projectId: string, + queries?: string[], + total?: boolean, + ): Promise; + listProjectKeys( + paramsOrFirst: + { projectId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] + ): Promise { + let params: { projectId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + queries?: string[]; + total?: boolean; + }; + } else { + params = { + projectId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean, + }; + } + + const projectId = params.projectId; + const queries = params.queries; + const total = params.total; + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + const apiPath = '/organization/projects/{projectId}/keys'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Create a new ephemeral API key for a project in your organization. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + * + * You can also create a standard API key if you need a longer-lived key instead. + * + * @param {string} params.projectId - Project unique ID. + * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. + * @param {number} params.duration - Time in seconds before ephemeral key expires. Maximum duration is 3600 seconds. + * @throws {AppwriteException} + * @returns {Promise} + */ + createEphemeralProjectKey(params: { + projectId: string; + scopes: ProjectKeyScopes[]; + duration: number; + }): Promise; + /** + * Create a new ephemeral API key for a project in your organization. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + * + * You can also create a standard API key if you need a longer-lived key instead. + * + * @param {string} projectId - Project unique ID. + * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. + * @param {number} duration - Time in seconds before ephemeral key expires. Maximum duration is 3600 seconds. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEphemeralProjectKey( + projectId: string, + scopes: ProjectKeyScopes[], + duration: number, + ): Promise; + createEphemeralProjectKey( + paramsOrFirst: + | { + projectId: string; + scopes: ProjectKeyScopes[]; + duration: number; + } + | string, + ...rest: [ProjectKeyScopes[]?, number?] + ): Promise { + let params: { + projectId: string; + scopes: ProjectKeyScopes[]; + duration: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + scopes: ProjectKeyScopes[]; + duration: number; + }; + } else { + params = { + projectId: paramsOrFirst as string, + scopes: rest[0] as ProjectKeyScopes[], + duration: rest[1] as number, + }; + } + + const projectId = params.projectId; + const scopes = params.scopes; + const duration = params.duration; + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + if (typeof scopes === 'undefined') { + throw new AppwriteException('Missing required parameter: "scopes"'); + } + if (typeof duration === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "duration"', + ); + } + const apiPath = + '/organization/projects/{projectId}/keys/ephemeral'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); + const apiPayload: Payload = {}; + if (typeof scopes !== 'undefined') { + apiPayload['scopes'] = scopes; + } + if (typeof duration !== 'undefined') { + apiPayload['duration'] = duration; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Get a project key by its unique ID. + * + * @param {string} params.projectId - Project unique ID. + * @param {string} params.keyId - Key ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getProjectKey(params: { + projectId: string; + keyId: string; + }): Promise; + /** + * Get a project key by its unique ID. + * + * @param {string} projectId - Project unique ID. + * @param {string} keyId - Key ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getProjectKey(projectId: string, keyId: string): Promise; + getProjectKey( + paramsOrFirst: { projectId: string; keyId: string } | string, + ...rest: [string?] + ): Promise { + let params: { projectId: string; keyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + keyId: string; + }; + } else { + params = { + projectId: paramsOrFirst as string, + keyId: rest[0] as string, + }; + } + + const projectId = params.projectId; + const keyId = params.keyId; + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + if (typeof keyId === 'undefined' || keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + const apiPath = '/organization/projects/{projectId}/keys/{keyId}' + .replace('{projectId}', encodeURIComponent(String(projectId))) + .replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Update a project key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. + * + * @param {string} params.projectId - Project unique ID. + * @param {string} params.keyId - Key ID. + * @param {string} params.name - Key name. Max length: 128 chars. + * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. + * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateProjectKey(params: { + projectId: string; + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }): Promise; + /** + * Update a project key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. + * + * @param {string} projectId - Project unique ID. + * @param {string} keyId - Key ID. + * @param {string} name - Key name. Max length: 128 chars. + * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. + * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateProjectKey( + projectId: string, + keyId: string, + name: string, + scopes: ProjectKeyScopes[], + expire?: string, + ): Promise; + updateProjectKey( + paramsOrFirst: + | { + projectId: string; + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + } + | string, + ...rest: [string?, string?, ProjectKeyScopes[]?, string?] + ): Promise { + let params: { + projectId: string; + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }; + } else { + params = { + projectId: paramsOrFirst as string, + keyId: rest[0] as string, + name: rest[1] as string, + scopes: rest[2] as ProjectKeyScopes[], + expire: rest[3] as string, + }; + } + + const projectId = params.projectId; + const keyId = params.keyId; + const name = params.name; + const scopes = params.scopes; + const expire = params.expire; + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + if (typeof keyId === 'undefined' || keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof scopes === 'undefined') { + throw new AppwriteException('Missing required parameter: "scopes"'); + } + const apiPath = '/organization/projects/{projectId}/keys/{keyId}' + .replace('{projectId}', encodeURIComponent(String(projectId))) + .replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof scopes !== 'undefined') { + apiPayload['scopes'] = scopes; + } + if (typeof expire !== 'undefined') { + apiPayload['expire'] = expire; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('put', uri, apiHeaders, apiPayload); + } + + /** + * Delete a project key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. + * + * @param {string} params.projectId - Project unique ID. + * @param {string} params.keyId - Key ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteProjectKey(params: { projectId: string; keyId: string }): Promise<{}>; + /** + * Delete a project key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. + * + * @param {string} projectId - Project unique ID. + * @param {string} keyId - Key ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteProjectKey(projectId: string, keyId: string): Promise<{}>; + deleteProjectKey( + paramsOrFirst: { projectId: string; keyId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { projectId: string; keyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + keyId: string; + }; + } else { + params = { + projectId: paramsOrFirst as string, + keyId: rest[0] as string, + }; + } + + const projectId = params.projectId; + const keyId = params.keyId; + if (typeof projectId === 'undefined' || projectId === '') { + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + if (typeof keyId === 'undefined' || keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + const apiPath = '/organization/projects/{projectId}/keys/{keyId}' + .replace('{projectId}', encodeURIComponent(String(projectId))) + .replace('{keyId}', encodeURIComponent(String(keyId))); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } } diff --git a/src/services/project.ts b/src/services/project.ts index f9897adf..085ec71c 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -3,8 +3,16 @@ import type { Models } from '../models'; import { ProjectAuthMethodId } from '../enums/project-auth-method-id'; import { ProjectKeyScopes } from '../enums/project-key-scopes'; +import { ProjectOAuth2Auth0Prompt } from '../enums/project-o-auth-2-auth-0-prompt'; +import { ProjectOAuth2DiscordPrompt } from '../enums/project-o-auth-2-discord-prompt'; +import { ProjectOAuth2GitHubPrompt } from '../enums/project-o-auth-2-git-hub-prompt'; import { ProjectOAuth2GooglePrompt } from '../enums/project-o-auth-2-google-prompt'; +import { ProjectOAuth2KakaoPrompt } from '../enums/project-o-auth-2-kakao-prompt'; +import { ProjectOAuth2MicrosoftPrompt } from '../enums/project-o-auth-2-microsoft-prompt'; import { ProjectOAuth2OidcPrompt } from '../enums/project-o-auth-2-oidc-prompt'; +import { ProjectOAuth2OktaPrompt } from '../enums/project-o-auth-2-okta-prompt'; +import { ProjectOAuth2SalesforcePrompt } from '../enums/project-o-auth-2-salesforce-prompt'; +import { ProjectOAuth2ZohoPrompt } from '../enums/project-o-auth-2-zoho-prompt'; import { ProjectOAuthProviderId } from '../enums/project-o-auth-provider-id'; import { ProjectPolicyId } from '../enums/project-policy-id'; import { ProjectProtocolId } from '../enums/project-protocol-id'; @@ -137,6 +145,337 @@ export class Project { return this.client.call('patch', uri, apiHeaders, apiPayload); } + /** + * Get a list of all environments of the project. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search, accessedAt, status, parentId + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listEnvironments(params?: { + queries?: string[]; + total?: boolean; + }): Promise; + /** + * Get a list of all environments of the project. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search, accessedAt, status, parentId + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listEnvironments( + queries?: string[], + total?: boolean, + ): Promise; + listEnvironments( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] + ): Promise { + let params: { queries?: string[]; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean, + }; + } + + const queries = params.queries; + const total = params.total; + const apiPath = '/project/environments'; + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. + * + * @param {string} params.environmentId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + createEnvironment(params: { + environmentId: string; + name: string; + }): Promise; + /** + * Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. + * + * @param {string} environmentId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEnvironment( + environmentId: string, + name: string, + ): Promise; + createEnvironment( + paramsOrFirst: { environmentId: string; name: string } | string, + ...rest: [string?] + ): Promise { + let params: { environmentId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + environmentId: string; + name: string; + }; + } else { + params = { + environmentId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const environmentId = params.environmentId; + const name = params.name; + if (typeof environmentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/project/environments'; + const apiPayload: Payload = {}; + if (typeof environmentId !== 'undefined') { + apiPayload['environmentId'] = environmentId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Get an environment of the project by its unique ID. + * + * @param {string} params.environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getEnvironment(params: { environmentId: string }): Promise; + /** + * Get an environment of the project by its unique ID. + * + * @param {string} environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getEnvironment(environmentId: string): Promise; + getEnvironment( + paramsOrFirst: { environmentId: string } | string, + ): Promise { + let params: { environmentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { environmentId: string }; + } else { + params = { + environmentId: paramsOrFirst as string, + }; + } + + const environmentId = params.environmentId; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Update the name of an environment of the project. + * + * @param {string} params.environmentId - Environment unique ID. + * @param {string} params.name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateEnvironment(params: { + environmentId: string; + name: string; + }): Promise; + /** + * Update the name of an environment of the project. + * + * @param {string} environmentId - Environment unique ID. + * @param {string} name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEnvironment( + environmentId: string, + name: string, + ): Promise; + updateEnvironment( + paramsOrFirst: { environmentId: string; name: string } | string, + ...rest: [string?] + ): Promise { + let params: { environmentId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + environmentId: string; + name: string; + }; + } else { + params = { + environmentId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const environmentId = params.environmentId; + const name = params.name; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + + /** + * Delete an environment of the project, with all of its resources and users. + * + * @param {string} params.environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteEnvironment(params: { environmentId: string }): Promise<{}>; + /** + * Delete an environment of the project, with all of its resources and users. + * + * @param {string} environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteEnvironment(environmentId: string): Promise<{}>; + deleteEnvironment( + paramsOrFirst: { environmentId: string } | string, + ): Promise<{}> { + let params: { environmentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { environmentId: string }; + } else { + params = { + environmentId: paramsOrFirst as string, + }; + } + + const environmentId = params.environmentId; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } + /** * Get a list of all API keys from the current project. * @@ -1291,7 +1630,9 @@ export class Project { * @param {string} params.keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 * @param {string} params.teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 * @param {string} params.p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {boolean} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[]} params.nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean} params.nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise} */ @@ -1301,6 +1642,8 @@ export class Project { teamId?: string; p8File?: string; enabled?: boolean; + nativeClientIds?: string[]; + nativeEnabled?: boolean; }): Promise; /** * Update the project OAuth2 Apple configuration. @@ -1309,7 +1652,9 @@ export class Project { * @param {string} keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 * @param {string} teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 * @param {string} p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {boolean} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[]} nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean} nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -1320,6 +1665,8 @@ export class Project { teamId?: string, p8File?: string, enabled?: boolean, + nativeClientIds?: string[], + nativeEnabled?: boolean, ): Promise; updateOAuth2Apple( paramsOrFirst?: @@ -1329,9 +1676,11 @@ export class Project { teamId?: string; p8File?: string; enabled?: boolean; + nativeClientIds?: string[]; + nativeEnabled?: boolean; } | string, - ...rest: [string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, boolean?, string[]?, boolean?] ): Promise { let params: { serviceId?: string; @@ -1339,6 +1688,8 @@ export class Project { teamId?: string; p8File?: string; enabled?: boolean; + nativeClientIds?: string[]; + nativeEnabled?: boolean; }; if ( @@ -1353,6 +1704,8 @@ export class Project { teamId?: string; p8File?: string; enabled?: boolean; + nativeClientIds?: string[]; + nativeEnabled?: boolean; }; } else { params = { @@ -1361,6 +1714,8 @@ export class Project { teamId: rest[1] as string, p8File: rest[2] as string, enabled: rest[3] as boolean, + nativeClientIds: rest[4] as string[], + nativeEnabled: rest[5] as boolean, }; } @@ -1369,6 +1724,8 @@ export class Project { const teamId = params.teamId; const p8File = params.p8File; const enabled = params.enabled; + const nativeClientIds = params.nativeClientIds; + const nativeEnabled = params.nativeEnabled; const apiPath = '/project/oauth2/apple'; const apiPayload: Payload = {}; if (typeof serviceId !== 'undefined') { @@ -1386,6 +1743,12 @@ export class Project { if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof nativeClientIds !== 'undefined') { + apiPayload['nativeClientIds'] = nativeClientIds; + } + if (typeof nativeEnabled !== 'undefined') { + apiPayload['nativeEnabled'] = nativeEnabled; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1489,6 +1852,7 @@ export class Project { * @param {string} params.clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF * @param {string} params.endpoint - Domain of Auth0 instance. For example: example.us.auth0.com * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2Auth0Prompt[]} params.prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. * @throws {AppwriteException} * @returns {Promise} */ @@ -1497,6 +1861,7 @@ export class Project { clientSecret?: string; endpoint?: string; enabled?: boolean; + prompt?: ProjectOAuth2Auth0Prompt[]; }): Promise; /** * Update the project OAuth2 Auth0 configuration. @@ -1505,6 +1870,7 @@ export class Project { * @param {string} clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF * @param {string} endpoint - Domain of Auth0 instance. For example: example.us.auth0.com * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2Auth0Prompt[]} prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -1514,6 +1880,7 @@ export class Project { clientSecret?: string, endpoint?: string, enabled?: boolean, + prompt?: ProjectOAuth2Auth0Prompt[], ): Promise; updateOAuth2Auth0( paramsOrFirst?: @@ -1522,15 +1889,17 @@ export class Project { clientSecret?: string; endpoint?: string; enabled?: boolean; + prompt?: ProjectOAuth2Auth0Prompt[]; } | string, - ...rest: [string?, string?, boolean?] + ...rest: [string?, string?, boolean?, ProjectOAuth2Auth0Prompt[]?] ): Promise { let params: { clientId?: string; clientSecret?: string; endpoint?: string; enabled?: boolean; + prompt?: ProjectOAuth2Auth0Prompt[]; }; if ( @@ -1544,6 +1913,7 @@ export class Project { clientSecret?: string; endpoint?: string; enabled?: boolean; + prompt?: ProjectOAuth2Auth0Prompt[]; }; } else { params = { @@ -1551,6 +1921,7 @@ export class Project { clientSecret: rest[0] as string, endpoint: rest[1] as string, enabled: rest[2] as boolean, + prompt: rest[3] as ProjectOAuth2Auth0Prompt[], }; } @@ -1558,6 +1929,7 @@ export class Project { const clientSecret = params.clientSecret; const endpoint = params.endpoint; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/auth0'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -1572,6 +1944,9 @@ export class Project { if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2190,6 +2565,7 @@ export class Project { * @param {string} params.clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 * @param {string} params.clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2DiscordPrompt[]} params.prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. * @throws {AppwriteException} * @returns {Promise} */ @@ -2197,6 +2573,7 @@ export class Project { clientId?: string; clientSecret?: string; enabled?: boolean; + prompt?: ProjectOAuth2DiscordPrompt[]; }): Promise; /** * Update the project OAuth2 Discord configuration. @@ -2204,6 +2581,7 @@ export class Project { * @param {string} clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 * @param {string} clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2DiscordPrompt[]} prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -2212,17 +2590,24 @@ export class Project { clientId?: string, clientSecret?: string, enabled?: boolean, + prompt?: ProjectOAuth2DiscordPrompt[], ): Promise; updateOAuth2Discord( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } + | { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + prompt?: ProjectOAuth2DiscordPrompt[]; + } | string, - ...rest: [string?, boolean?] + ...rest: [string?, boolean?, ProjectOAuth2DiscordPrompt[]?] ): Promise { let params: { clientId?: string; clientSecret?: string; enabled?: boolean; + prompt?: ProjectOAuth2DiscordPrompt[]; }; if ( @@ -2235,18 +2620,21 @@ export class Project { clientId?: string; clientSecret?: string; enabled?: boolean; + prompt?: ProjectOAuth2DiscordPrompt[]; }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, enabled: rest[1] as boolean, + prompt: rest[2] as ProjectOAuth2DiscordPrompt[], }; } const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/discord'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2258,6 +2646,9 @@ export class Project { if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2791,6 +3182,7 @@ export class Project { * @param {string} params.clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 * @param {string} params.clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2GitHubPrompt[]} params.prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. * @throws {AppwriteException} * @returns {Promise} */ @@ -2798,6 +3190,7 @@ export class Project { clientId?: string; clientSecret?: string; enabled?: boolean; + prompt?: ProjectOAuth2GitHubPrompt[]; }): Promise; /** * Update the project OAuth2 GitHub configuration. @@ -2805,6 +3198,7 @@ export class Project { * @param {string} clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 * @param {string} clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2GitHubPrompt[]} prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -2813,17 +3207,24 @@ export class Project { clientId?: string, clientSecret?: string, enabled?: boolean, + prompt?: ProjectOAuth2GitHubPrompt[], ): Promise; updateOAuth2GitHub( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } + | { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + prompt?: ProjectOAuth2GitHubPrompt[]; + } | string, - ...rest: [string?, boolean?] + ...rest: [string?, boolean?, ProjectOAuth2GitHubPrompt[]?] ): Promise { let params: { clientId?: string; clientSecret?: string; enabled?: boolean; + prompt?: ProjectOAuth2GitHubPrompt[]; }; if ( @@ -2836,18 +3237,21 @@ export class Project { clientId?: string; clientSecret?: string; enabled?: boolean; + prompt?: ProjectOAuth2GitHubPrompt[]; }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, enabled: rest[1] as boolean, + prompt: rest[2] as ProjectOAuth2GitHubPrompt[], }; } const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/github'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2859,6 +3263,9 @@ export class Project { if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2977,7 +3384,9 @@ export class Project { * @param {string} params.clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com * @param {string} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj * @param {ProjectOAuth2GooglePrompt[]} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {boolean} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[]} params.nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean} params.nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise} */ @@ -2986,6 +3395,8 @@ export class Project { clientSecret?: string; prompt?: ProjectOAuth2GooglePrompt[]; enabled?: boolean; + nativeClientIds?: string[]; + nativeEnabled?: boolean; }): Promise; /** * Update the project OAuth2 Google configuration. @@ -2993,7 +3404,9 @@ export class Project { * @param {string} clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com * @param {string} clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj * @param {ProjectOAuth2GooglePrompt[]} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {boolean} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[]} nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean} nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -3003,6 +3416,8 @@ export class Project { clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean, + nativeClientIds?: string[], + nativeEnabled?: boolean, ): Promise; updateOAuth2Google( paramsOrFirst?: @@ -3011,15 +3426,25 @@ export class Project { clientSecret?: string; prompt?: ProjectOAuth2GooglePrompt[]; enabled?: boolean; + nativeClientIds?: string[]; + nativeEnabled?: boolean; } | string, - ...rest: [string?, ProjectOAuth2GooglePrompt[]?, boolean?] + ...rest: [ + string?, + ProjectOAuth2GooglePrompt[]?, + boolean?, + string[]?, + boolean?, + ] ): Promise { let params: { clientId?: string; clientSecret?: string; prompt?: ProjectOAuth2GooglePrompt[]; enabled?: boolean; + nativeClientIds?: string[]; + nativeEnabled?: boolean; }; if ( @@ -3033,6 +3458,8 @@ export class Project { clientSecret?: string; prompt?: ProjectOAuth2GooglePrompt[]; enabled?: boolean; + nativeClientIds?: string[]; + nativeEnabled?: boolean; }; } else { params = { @@ -3040,6 +3467,8 @@ export class Project { clientSecret: rest[0] as string, prompt: rest[1] as ProjectOAuth2GooglePrompt[], enabled: rest[2] as boolean, + nativeClientIds: rest[3] as string[], + nativeEnabled: rest[4] as boolean, }; } @@ -3047,6 +3476,8 @@ export class Project { const clientSecret = params.clientSecret; const prompt = params.prompt; const enabled = params.enabled; + const nativeClientIds = params.nativeClientIds; + const nativeEnabled = params.nativeEnabled; const apiPath = '/project/oauth2/google'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3061,6 +3492,12 @@ export class Project { if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof nativeClientIds !== 'undefined') { + apiPayload['nativeClientIds'] = nativeClientIds; + } + if (typeof nativeEnabled !== 'undefined') { + apiPayload['nativeEnabled'] = nativeEnabled; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3157,6 +3594,107 @@ export class Project { return this.client.call('patch', uri, apiHeaders, apiPayload); } + /** + * Update the project OAuth2 Kakao configuration. + * + * @param {string} params.clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + * @param {string} params.clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {ProjectOAuth2KakaoPrompt[]} params.prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Kakao(params?: { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2KakaoPrompt[]; + enabled?: boolean; + }): Promise; + /** + * Update the project OAuth2 Kakao configuration. + * + * @param {string} clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + * @param {string} clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {ProjectOAuth2KakaoPrompt[]} prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Kakao( + clientId?: string, + clientSecret?: string, + prompt?: ProjectOAuth2KakaoPrompt[], + enabled?: boolean, + ): Promise; + updateOAuth2Kakao( + paramsOrFirst?: + | { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2KakaoPrompt[]; + enabled?: boolean; + } + | string, + ...rest: [string?, ProjectOAuth2KakaoPrompt[]?, boolean?] + ): Promise { + let params: { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2KakaoPrompt[]; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2KakaoPrompt[]; + enabled?: boolean; + }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + prompt: rest[1] as ProjectOAuth2KakaoPrompt[], + enabled: rest[2] as boolean, + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const prompt = params.prompt; + const enabled = params.enabled; + const apiPath = '/project/oauth2/kakao'; + const apiPayload: Payload = {}; + if (typeof clientId !== 'undefined') { + apiPayload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + apiPayload['clientSecret'] = clientSecret; + } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + /** * Update the project OAuth2 Keycloak configuration. * @@ -3451,6 +3989,7 @@ export class Project { * @param {string} params.applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u * @param {string} params.tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2MicrosoftPrompt[]} params.prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. * @throws {AppwriteException} * @returns {Promise} */ @@ -3459,6 +3998,7 @@ export class Project { applicationSecret?: string; tenant?: string; enabled?: boolean; + prompt?: ProjectOAuth2MicrosoftPrompt[]; }): Promise; /** * Update the project OAuth2 Microsoft configuration. @@ -3467,6 +4007,7 @@ export class Project { * @param {string} applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u * @param {string} tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2MicrosoftPrompt[]} prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -3476,6 +4017,7 @@ export class Project { applicationSecret?: string, tenant?: string, enabled?: boolean, + prompt?: ProjectOAuth2MicrosoftPrompt[], ): Promise; updateOAuth2Microsoft( paramsOrFirst?: @@ -3484,15 +4026,17 @@ export class Project { applicationSecret?: string; tenant?: string; enabled?: boolean; + prompt?: ProjectOAuth2MicrosoftPrompt[]; } | string, - ...rest: [string?, string?, boolean?] + ...rest: [string?, string?, boolean?, ProjectOAuth2MicrosoftPrompt[]?] ): Promise { let params: { applicationId?: string; applicationSecret?: string; tenant?: string; enabled?: boolean; + prompt?: ProjectOAuth2MicrosoftPrompt[]; }; if ( @@ -3506,6 +4050,7 @@ export class Project { applicationSecret?: string; tenant?: string; enabled?: boolean; + prompt?: ProjectOAuth2MicrosoftPrompt[]; }; } else { params = { @@ -3513,6 +4058,7 @@ export class Project { applicationSecret: rest[0] as string, tenant: rest[1] as string, enabled: rest[2] as boolean, + prompt: rest[3] as ProjectOAuth2MicrosoftPrompt[], }; } @@ -3520,6 +4066,7 @@ export class Project { const applicationSecret = params.applicationSecret; const tenant = params.tenant; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/microsoft'; const apiPayload: Payload = {}; if (typeof applicationId !== 'undefined') { @@ -3534,6 +4081,9 @@ export class Project { if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3812,6 +4362,7 @@ export class Project { * @param {string} params.domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ * @param {string} params.authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2OktaPrompt[]} params.prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. * @throws {AppwriteException} * @returns {Promise} */ @@ -3821,6 +4372,7 @@ export class Project { domain?: string; authorizationServerId?: string; enabled?: boolean; + prompt?: ProjectOAuth2OktaPrompt[]; }): Promise; /** * Update the project OAuth2 Okta configuration. @@ -3830,6 +4382,7 @@ export class Project { * @param {string} domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ * @param {string} authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2OktaPrompt[]} prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -3840,6 +4393,7 @@ export class Project { domain?: string, authorizationServerId?: string, enabled?: boolean, + prompt?: ProjectOAuth2OktaPrompt[], ): Promise; updateOAuth2Okta( paramsOrFirst?: @@ -3849,9 +4403,16 @@ export class Project { domain?: string; authorizationServerId?: string; enabled?: boolean; + prompt?: ProjectOAuth2OktaPrompt[]; } | string, - ...rest: [string?, string?, string?, boolean?] + ...rest: [ + string?, + string?, + string?, + boolean?, + ProjectOAuth2OktaPrompt[]?, + ] ): Promise { let params: { clientId?: string; @@ -3859,6 +4420,7 @@ export class Project { domain?: string; authorizationServerId?: string; enabled?: boolean; + prompt?: ProjectOAuth2OktaPrompt[]; }; if ( @@ -3873,6 +4435,7 @@ export class Project { domain?: string; authorizationServerId?: string; enabled?: boolean; + prompt?: ProjectOAuth2OktaPrompt[]; }; } else { params = { @@ -3881,6 +4444,7 @@ export class Project { domain: rest[1] as string, authorizationServerId: rest[2] as string, enabled: rest[3] as boolean, + prompt: rest[4] as ProjectOAuth2OktaPrompt[], }; } @@ -3889,6 +4453,7 @@ export class Project { const domain = params.domain; const authorizationServerId = params.authorizationServerId; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/okta'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3906,6 +4471,9 @@ export class Project { if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4263,6 +4831,7 @@ export class Project { * @param {string} params.customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq * @param {string} params.customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2SalesforcePrompt[]} params.prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. * @throws {AppwriteException} * @returns {Promise} */ @@ -4270,6 +4839,7 @@ export class Project { customerKey?: string; customerSecret?: string; enabled?: boolean; + prompt?: ProjectOAuth2SalesforcePrompt[]; }): Promise; /** * Update the project OAuth2 Salesforce configuration. @@ -4277,6 +4847,7 @@ export class Project { * @param {string} customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq * @param {string} customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2SalesforcePrompt[]} prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -4285,6 +4856,7 @@ export class Project { customerKey?: string, customerSecret?: string, enabled?: boolean, + prompt?: ProjectOAuth2SalesforcePrompt[], ): Promise; updateOAuth2Salesforce( paramsOrFirst?: @@ -4292,14 +4864,16 @@ export class Project { customerKey?: string; customerSecret?: string; enabled?: boolean; + prompt?: ProjectOAuth2SalesforcePrompt[]; } | string, - ...rest: [string?, boolean?] + ...rest: [string?, boolean?, ProjectOAuth2SalesforcePrompt[]?] ): Promise { let params: { customerKey?: string; customerSecret?: string; enabled?: boolean; + prompt?: ProjectOAuth2SalesforcePrompt[]; }; if ( @@ -4312,18 +4886,21 @@ export class Project { customerKey?: string; customerSecret?: string; enabled?: boolean; + prompt?: ProjectOAuth2SalesforcePrompt[]; }; } else { params = { customerKey: paramsOrFirst as string, customerSecret: rest[0] as string, enabled: rest[1] as boolean, + prompt: rest[2] as ProjectOAuth2SalesforcePrompt[], }; } const customerKey = params.customerKey; const customerSecret = params.customerSecret; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/salesforce'; const apiPayload: Payload = {}; if (typeof customerKey !== 'undefined') { @@ -4335,6 +4912,9 @@ export class Project { if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4465,10 +5045,95 @@ export class Project { | { clientId?: string; clientSecret?: string; enabled?: boolean } | string, ...rest: [string?, boolean?] - ): Promise { + ): Promise { + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean, + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + const apiPath = '/project/oauth2/spotify'; + const apiPayload: Payload = {}; + if (typeof clientId !== 'undefined') { + apiPayload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + apiPayload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + + /** + * Update the project OAuth2 Stripe configuration. + * + * @param {string} params.clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string} params.apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Stripe(params?: { + clientId?: string; + apiSecretKey?: string; + enabled?: boolean; + }): Promise; + /** + * Update the project OAuth2 Stripe configuration. + * + * @param {string} clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string} apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Stripe( + clientId?: string, + apiSecretKey?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Stripe( + paramsOrFirst?: + | { clientId?: string; apiSecretKey?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] + ): Promise { let params: { clientId?: string; - clientSecret?: string; + apiSecretKey?: string; enabled?: boolean; }; @@ -4480,27 +5145,27 @@ export class Project { ) { params = (paramsOrFirst || {}) as { clientId?: string; - clientSecret?: string; + apiSecretKey?: string; enabled?: boolean; }; } else { params = { clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, + apiSecretKey: rest[0] as string, enabled: rest[1] as boolean, }; } const clientId = params.clientId; - const clientSecret = params.clientSecret; + const apiSecretKey = params.apiSecretKey; const enabled = params.enabled; - const apiPath = '/project/oauth2/spotify'; + const apiPath = '/project/oauth2/stripe'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { apiPayload['clientId'] = clientId; } - if (typeof clientSecret !== 'undefined') { - apiPayload['clientSecret'] = clientSecret; + if (typeof apiSecretKey !== 'undefined') { + apiPayload['apiSecretKey'] = apiSecretKey; } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; @@ -4517,75 +5182,75 @@ export class Project { } /** - * Update the project OAuth2 Stripe configuration. + * Update the project OAuth2 TikTok configuration. * - * @param {string} params.clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR - * @param {string} params.apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {string} params.clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + * @param {string} params.clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - updateOAuth2Stripe(params?: { + updateOAuth2TikTok(params?: { clientId?: string; - apiSecretKey?: string; + clientSecret?: string; enabled?: boolean; - }): Promise; + }): Promise; /** - * Update the project OAuth2 Stripe configuration. + * Update the project OAuth2 TikTok configuration. * - * @param {string} clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR - * @param {string} apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {string} clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + * @param {string} clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Stripe( + updateOAuth2TikTok( clientId?: string, - apiSecretKey?: string, + clientSecret?: string, enabled?: boolean, - ): Promise; - updateOAuth2Stripe( + ): Promise; + updateOAuth2TikTok( paramsOrFirst?: - | { clientId?: string; apiSecretKey?: string; enabled?: boolean } + | { clientId?: string; clientSecret?: string; enabled?: boolean } | string, ...rest: [string?, boolean?] - ): Promise { + ): Promise { let params: { clientId?: string; - apiSecretKey?: string; + clientSecret?: string; enabled?: boolean; }; if ( - !paramsOrFirst || + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { clientId?: string; - apiSecretKey?: string; + clientSecret?: string; enabled?: boolean; }; } else { params = { clientId: paramsOrFirst as string, - apiSecretKey: rest[0] as string, + clientSecret: rest[0] as string, enabled: rest[1] as boolean, }; } const clientId = params.clientId; - const apiSecretKey = params.apiSecretKey; + const clientSecret = params.clientSecret; const enabled = params.enabled; - const apiPath = '/project/oauth2/stripe'; + const apiPath = '/project/oauth2/tiktok'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { apiPayload['clientId'] = clientId; } - if (typeof apiSecretKey !== 'undefined') { - apiPayload['apiSecretKey'] = apiSecretKey; + if (typeof clientSecret !== 'undefined') { + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; @@ -4864,6 +5529,91 @@ export class Project { return this.client.call('patch', uri, apiHeaders, apiPayload); } + /** + * Update the project OAuth2 Webflow configuration. + * + * @param {string} params.clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd + * @param {string} params.clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Webflow(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; + /** + * Update the project OAuth2 Webflow configuration. + * + * @param {string} clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd + * @param {string} clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Webflow( + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Webflow( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] + ): Promise { + let params: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean, + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + const apiPath = '/project/oauth2/webflow'; + const apiPayload: Payload = {}; + if (typeof clientId !== 'undefined') { + apiPayload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + apiPayload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + /** * Update the project OAuth2 WordPress configuration. * @@ -5210,6 +5960,7 @@ export class Project { * @param {string} params.clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B * @param {string} params.clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2ZohoPrompt[]} params.prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. * @throws {AppwriteException} * @returns {Promise} */ @@ -5217,6 +5968,7 @@ export class Project { clientId?: string; clientSecret?: string; enabled?: boolean; + prompt?: ProjectOAuth2ZohoPrompt[]; }): Promise; /** * Update the project OAuth2 Zoho configuration. @@ -5224,6 +5976,7 @@ export class Project { * @param {string} clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B * @param {string} clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2ZohoPrompt[]} prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -5232,17 +5985,24 @@ export class Project { clientId?: string, clientSecret?: string, enabled?: boolean, + prompt?: ProjectOAuth2ZohoPrompt[], ): Promise; updateOAuth2Zoho( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } + | { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + prompt?: ProjectOAuth2ZohoPrompt[]; + } | string, - ...rest: [string?, boolean?] + ...rest: [string?, boolean?, ProjectOAuth2ZohoPrompt[]?] ): Promise { let params: { clientId?: string; clientSecret?: string; enabled?: boolean; + prompt?: ProjectOAuth2ZohoPrompt[]; }; if ( @@ -5255,18 +6015,21 @@ export class Project { clientId?: string; clientSecret?: string; enabled?: boolean; + prompt?: ProjectOAuth2ZohoPrompt[]; }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, enabled: rest[1] as boolean, + prompt: rest[2] as ProjectOAuth2ZohoPrompt[], }; } const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/zoho'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -5278,6 +6041,9 @@ export class Project { if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -5379,7 +6145,7 @@ export class Project { * * @param {ProjectOAuthProviderId} params.providerId - OAuth2 provider key. For example: github, google, apple. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ getOAuth2Provider(params: { providerId: ProjectOAuthProviderId; @@ -5399,6 +6165,7 @@ export class Project { | Models.OAuth2Yandex | Models.OAuth2X | Models.OAuth2WordPress + | Models.OAuth2Webflow | Models.OAuth2Twitch | Models.OAuth2Stripe | Models.OAuth2Spotify @@ -5427,13 +6194,15 @@ export class Project { | Models.OAuth2Okta | Models.OAuth2Kick | Models.OAuth2Microsoft + | Models.OAuth2TikTok + | Models.OAuth2Kakao >; /** * Get a single OAuth2 provider configuration. Credential fields (client secret, p8 file, key/team IDs) are write-only and always returned empty. * * @param {ProjectOAuthProviderId} providerId - OAuth2 provider key. For example: github, google, apple. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ getOAuth2Provider( @@ -5454,6 +6223,7 @@ export class Project { | Models.OAuth2Yandex | Models.OAuth2X | Models.OAuth2WordPress + | Models.OAuth2Webflow | Models.OAuth2Twitch | Models.OAuth2Stripe | Models.OAuth2Spotify @@ -5482,6 +6252,8 @@ export class Project { | Models.OAuth2Okta | Models.OAuth2Kick | Models.OAuth2Microsoft + | Models.OAuth2TikTok + | Models.OAuth2Kakao >; getOAuth2Provider( paramsOrFirst: @@ -5502,6 +6274,7 @@ export class Project { | Models.OAuth2Yandex | Models.OAuth2X | Models.OAuth2WordPress + | Models.OAuth2Webflow | Models.OAuth2Twitch | Models.OAuth2Stripe | Models.OAuth2Spotify @@ -5530,6 +6303,8 @@ export class Project { | Models.OAuth2Okta | Models.OAuth2Kick | Models.OAuth2Microsoft + | Models.OAuth2TikTok + | Models.OAuth2Kakao > { let params: { providerId: ProjectOAuthProviderId }; @@ -5643,6 +6418,7 @@ export class Project { * @param {string} params.platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise} */ @@ -5650,6 +6426,7 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }): Promise; /** * Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. @@ -5657,6 +6434,7 @@ export class Project { * @param {string} platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -5665,14 +6443,25 @@ export class Project { platformId: string, name: string, applicationId: string, + fingerprints?: string[], ): Promise; createAndroidPlatform( paramsOrFirst: - | { platformId: string; name: string; applicationId: string } + | { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + } | string, - ...rest: [string?, string?] + ...rest: [string?, string?, string[]?] ): Promise { - let params: { platformId: string; name: string; applicationId: string }; + let params: { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + }; if ( paramsOrFirst && @@ -5683,18 +6472,21 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, + fingerprints: rest[2] as string[], }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; + const fingerprints = params.fingerprints; if (typeof platformId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -5719,6 +6511,9 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } + if (typeof fingerprints !== 'undefined') { + apiPayload['fingerprints'] = fingerprints; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -5736,6 +6531,7 @@ export class Project { * @param {string} params.platformId - Platform ID. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise} */ @@ -5743,6 +6539,7 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }): Promise; /** * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. @@ -5750,6 +6547,7 @@ export class Project { * @param {string} platformId - Platform ID. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -5758,14 +6556,25 @@ export class Project { platformId: string, name: string, applicationId: string, + fingerprints?: string[], ): Promise; updateAndroidPlatform( paramsOrFirst: - | { platformId: string; name: string; applicationId: string } + | { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + } | string, - ...rest: [string?, string?] + ...rest: [string?, string?, string[]?] ): Promise { - let params: { platformId: string; name: string; applicationId: string }; + let params: { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + }; if ( paramsOrFirst && @@ -5776,18 +6585,21 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, + fingerprints: rest[2] as string[], }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; + const fingerprints = params.fingerprints; if (typeof platformId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -5812,6 +6624,9 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } + if (typeof fingerprints !== 'undefined') { + apiPayload['fingerprints'] = fingerprints; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -7475,6 +8290,156 @@ export class Project { return this.client.call('patch', uri, apiHeaders, apiPayload); } + /** + * Updating this policy allows you to control if passwords are checked against the Have I Been Pwned breach database. When enabled, every password a user signs up, signs in or resets with is checked and the result is recorded on the user as `passwordPwned`. On its own the policy only records. Enable `users` to reject a breached password when a user signs up or sets a new password, and `sessions` to refuse a sign-in with a breached password until it is reset. Only the first five characters of the password hash are ever shared with the service. Options left out keep their current value. + * + * @param {boolean} params.enabled - Toggle password pwned policy. Set to true to check passwords against known data breaches and record the result on the user, or false to never check. Default is true. On its own this only records; use `users` and `sessions` to block. When changing this policy, existing passwords remain valid. + * @param {boolean} params.sessions - Whether a sign-in with a breached password is refused until the password is reset. Default is false, which allows the sign-in and only records the result. + * @param {boolean} params.users - Whether a breached password is rejected when a user signs up or sets a new password. Default is false, which allows the password and only records the result. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePasswordPwnedPolicy(params?: { + enabled?: boolean; + sessions?: boolean; + users?: boolean; + }): Promise; + /** + * Updating this policy allows you to control if passwords are checked against the Have I Been Pwned breach database. When enabled, every password a user signs up, signs in or resets with is checked and the result is recorded on the user as `passwordPwned`. On its own the policy only records. Enable `users` to reject a breached password when a user signs up or sets a new password, and `sessions` to refuse a sign-in with a breached password until it is reset. Only the first five characters of the password hash are ever shared with the service. Options left out keep their current value. + * + * @param {boolean} enabled - Toggle password pwned policy. Set to true to check passwords against known data breaches and record the result on the user, or false to never check. Default is true. On its own this only records; use `users` and `sessions` to block. When changing this policy, existing passwords remain valid. + * @param {boolean} sessions - Whether a sign-in with a breached password is refused until the password is reset. Default is false, which allows the sign-in and only records the result. + * @param {boolean} users - Whether a breached password is rejected when a user signs up or sets a new password. Default is false, which allows the password and only records the result. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasswordPwnedPolicy( + enabled?: boolean, + sessions?: boolean, + users?: boolean, + ): Promise; + updatePasswordPwnedPolicy( + paramsOrFirst?: + | { enabled?: boolean; sessions?: boolean; users?: boolean } + | boolean, + ...rest: [boolean?, boolean?] + ): Promise { + let params: { enabled?: boolean; sessions?: boolean; users?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + enabled?: boolean; + sessions?: boolean; + users?: boolean; + }; + } else { + params = { + enabled: paramsOrFirst as boolean, + sessions: rest[0] as boolean, + users: rest[1] as boolean, + }; + } + + const enabled = params.enabled; + const sessions = params.sessions; + const users = params.users; + const apiPath = '/project/policies/password-pwned'; + const apiPayload: Payload = {}; + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof sessions !== 'undefined') { + apiPayload['sessions'] = sessions; + } + if (typeof users !== 'undefined') { + apiPayload['users'] = users; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + + /** + * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. + * + * @param {boolean} params.enabled - Enable password rotation. Disabled by default. + * @param {number} params.maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePasswordRotationPolicy(params?: { + enabled?: boolean; + maxAge?: number; + }): Promise; + /** + * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. + * + * @param {boolean} enabled - Enable password rotation. Disabled by default. + * @param {number} maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasswordRotationPolicy( + enabled?: boolean, + maxAge?: number, + ): Promise; + updatePasswordRotationPolicy( + paramsOrFirst?: { enabled?: boolean; maxAge?: number } | boolean, + ...rest: [number?] + ): Promise { + let params: { enabled?: boolean; maxAge?: number }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + enabled?: boolean; + maxAge?: number; + }; + } else { + params = { + enabled: paramsOrFirst as boolean, + maxAge: rest[0] as number, + }; + } + + const enabled = params.enabled; + const maxAge = params.maxAge; + const apiPath = '/project/policies/password-rotation'; + const apiPayload: Payload = {}; + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof maxAge !== 'undefined') { + apiPayload['maxAge'] = maxAge; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + /** * Update the password strength requirements for users in the project. * @@ -7877,7 +8842,7 @@ export class Project { * * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ getPolicy(params: { policyId: ProjectPolicyId; @@ -7886,6 +8851,8 @@ export class Project { | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData + | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -7904,7 +8871,7 @@ export class Project { * * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ getPolicy( @@ -7914,6 +8881,8 @@ export class Project { | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData + | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -7934,6 +8903,8 @@ export class Project { | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData + | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation diff --git a/src/services/sites.ts b/src/services/sites.ts index d6845214..9bcfb71c 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -483,12 +483,44 @@ export class Sites { /** * Get a list of all frameworks that are currently available on the server instance. * + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ - listFrameworks(): Promise { + listFrameworks(params?: { total?: boolean }): Promise; + /** + * Get a list of all frameworks that are currently available on the server instance. + * + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listFrameworks(total?: boolean): Promise; + listFrameworks( + paramsOrFirst?: { total?: boolean } | boolean, + ): Promise { + let params: { total?: boolean }; + + if ( + typeof paramsOrFirst === 'undefined' || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { total?: boolean }; + } else { + params = { + total: paramsOrFirst as boolean, + }; + } + + const total = params.total; const apiPath = '/sites/frameworks'; const apiPayload: Payload = {}; + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -503,25 +535,32 @@ export class Sites { * List allowed site specifications for this instance. * * @param {string} params.type - Specification type to list. Can be one of: runtimes, builds. Defaults to runtimes. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ listSpecifications(params?: { type?: string; + total?: boolean; }): Promise; /** * List allowed site specifications for this instance. * * @param {string} type - Specification type to list. Can be one of: runtimes, builds. Defaults to runtimes. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listSpecifications(type?: string): Promise; listSpecifications( - paramsOrFirst?: { type?: string } | string, + type?: string, + total?: boolean, + ): Promise; + listSpecifications( + paramsOrFirst?: { type?: string; total?: boolean } | string, + ...rest: [boolean?] ): Promise { - let params: { type?: string }; + let params: { type?: string; total?: boolean }; if ( !paramsOrFirst || @@ -529,19 +568,27 @@ export class Sites { typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst)) ) { - params = (paramsOrFirst || {}) as { type?: string }; + params = (paramsOrFirst || {}) as { + type?: string; + total?: boolean; + }; } else { params = { type: paramsOrFirst as string, + total: rest[0] as boolean, }; } const type = params.type; + const total = params.total; const apiPath = '/sites/specifications'; const apiPayload: Payload = {}; if (typeof type !== 'undefined') { apiPayload['type'] = type; } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index b57d0960..d015406e 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -248,25 +248,32 @@ export class TablesDB { * List transactions across all databases. * * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ listTransactions(params?: { queries?: string[]; + total?: boolean; }): Promise; /** * List transactions across all databases. * * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTransactions(queries?: string[]): Promise; listTransactions( - paramsOrFirst?: { queries?: string[] } | string[], + queries?: string[], + total?: boolean, + ): Promise; + listTransactions( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[] }; + let params: { queries?: string[]; total?: boolean }; if ( !paramsOrFirst || @@ -274,19 +281,27 @@ export class TablesDB { typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst)) ) { - params = (paramsOrFirst || {}) as { queries?: string[] }; + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; } else { params = { queries: paramsOrFirst as string[], + total: rest[0] as boolean, }; } const queries = params.queries; + const total = params.total; const apiPath = '/tablesdb/transactions'; const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { apiPayload['queries'] = queries; } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/teams.ts b/src/services/teams.ts index f2ea276c..42053cb4 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -889,6 +889,7 @@ export class Teams { * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.url - URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} params.name - Name of the new team member. Max length: 128 chars. + * @param {string} params.membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @throws {AppwriteException} * @returns {Promise} */ @@ -900,6 +901,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }): Promise; /** * Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team. @@ -918,6 +920,7 @@ export class Teams { * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} url - URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} name - Name of the new team member. Max length: 128 chars. + * @param {string} membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -930,6 +933,7 @@ export class Teams { phone?: string, url?: string, name?: string, + membershipId?: string, ): Promise; createMembership( paramsOrFirst: @@ -941,9 +945,18 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; } | string, - ...rest: [string[]?, string?, string?, string?, string?, string?] + ...rest: [ + string[]?, + string?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise { let params: { teamId: string; @@ -953,6 +966,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }; if ( @@ -968,6 +982,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }; } else { params = { @@ -978,6 +993,7 @@ export class Teams { phone: rest[3] as string, url: rest[4] as string, name: rest[5] as string, + membershipId: rest[6] as string, }; } @@ -988,6 +1004,7 @@ export class Teams { const phone = params.phone; const url = params.url; const name = params.name; + const membershipId = params.membershipId; if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -1017,6 +1034,9 @@ export class Teams { if (typeof name !== 'undefined') { apiPayload['name'] = name; } + if (typeof membershipId !== 'undefined') { + apiPayload['membershipId'] = membershipId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts index 59fec93c..0988b27b 100644 --- a/src/services/vectors-db.ts +++ b/src/services/vectors-db.ts @@ -232,25 +232,32 @@ export class VectorsDB { * List transactions across all databases. * * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ listTransactions(params?: { queries?: string[]; + total?: boolean; }): Promise; /** * List transactions across all databases. * * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTransactions(queries?: string[]): Promise; listTransactions( - paramsOrFirst?: { queries?: string[] } | string[], + queries?: string[], + total?: boolean, + ): Promise; + listTransactions( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[] }; + let params: { queries?: string[]; total?: boolean }; if ( !paramsOrFirst || @@ -258,19 +265,27 @@ export class VectorsDB { typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst)) ) { - params = (paramsOrFirst || {}) as { queries?: string[] }; + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; } else { params = { queries: paramsOrFirst as string[], + total: rest[0] as boolean, }; } const queries = params.queries; + const total = params.total; const apiPath = '/vectorsdb/transactions'; const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { apiPayload['queries'] = queries; } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/waf.ts b/src/services/waf.ts new file mode 100644 index 00000000..d83e9f77 --- /dev/null +++ b/src/services/waf.ts @@ -0,0 +1,2137 @@ +import { AppwriteException, Client, type Payload } from '../client'; +import type { Models } from '../models'; + +export class Waf { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List WAF rules for the current project. + * + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listRules(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; + /** + * List WAF rules for the current project. + * + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRules( + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listRules( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] + ): Promise { + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + search?: string; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean, + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + const apiPath = '/waf/rules'; + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof search !== 'undefined') { + apiPayload['search'] = search; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string} params.resourceId - Resource identifier. Leave empty for the API resource type. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + createBypassRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string} resourceId - Resource identifier. Leave empty for the API resource type. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBypassRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + createBypassRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/bypass'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.name - Rule name. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to disable the rule. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateBypassRule(params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} name - Rule name. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to disable the rule. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBypassRule( + ruleId: string, + resourceType?: string, + resourceId?: string, + name?: string, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + updateBypassRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + resourceId: rest[1] as string, + name: rest[2] as string, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/bypass/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + + /** + * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.challengeType - Challenge type enforced by the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise} + */ + createChallengeRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }): Promise; + /** + * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {string} challengeType - Challenge type enforced by the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createChallengeRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string, + description?: string, + challengeType?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + difficulty?: number, + ttl?: number, + ): Promise; + createChallengeRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + number?, + boolean?, + string[]?, + number?, + number?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string, + description: rest[3] as string, + challengeType: rest[4] as string, + priority: rest[5] as number, + enabled: rest[6] as boolean, + conditions: rest[7] as string[], + difficulty: rest[8] as number, + ttl: rest[9] as number, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const challengeType = params.challengeType; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + const difficulty = params.difficulty; + const ttl = params.ttl; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/challenge'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + apiPayload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + if (typeof difficulty !== 'undefined') { + apiPayload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.name - Rule name. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.challengeType - Challenge type enforced by the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to disable the rule. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateChallengeRule(params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }): Promise; + /** + * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} name - Rule name. + * @param {string} description - Optional description for the rule. + * @param {string} challengeType - Challenge type enforced by the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to disable the rule. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateChallengeRule( + ruleId: string, + resourceType?: string, + resourceId?: string, + name?: string, + description?: string, + challengeType?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + difficulty?: number, + ttl?: number, + ): Promise; + updateChallengeRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + number?, + boolean?, + string[]?, + number?, + number?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + resourceId: rest[1] as string, + name: rest[2] as string, + description: rest[3] as string, + challengeType: rest[4] as string, + priority: rest[5] as number, + enabled: rest[6] as boolean, + conditions: rest[7] as string[], + difficulty: rest[8] as number, + ttl: rest[9] as number, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const challengeType = params.challengeType; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + const difficulty = params.difficulty; + const ttl = params.ttl; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/challenge/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + apiPayload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + if (typeof difficulty !== 'undefined') { + apiPayload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + + /** + * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + createDenyRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDenyRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + createDenyRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/deny'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.name - Rule name. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to disable the rule. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateDenyRule(params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} name - Rule name. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to disable the rule. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDenyRule( + ruleId: string, + resourceType?: string, + resourceId?: string, + name?: string, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + updateDenyRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + resourceId: rest[1] as string, + name: rest[2] as string, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/deny/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + + /** + * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {number} params.limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} params.interval - Interval in seconds used for rate limiting. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {string} params.strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + * @param {number} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRateLimitRule(params: { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {number} limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} interval - Interval in seconds used for rate limiting. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {string} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {string} strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + * @param {number} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRateLimitRule( + ruleId: string, + resourceType: string, + name: string, + limit: number, + interval: number, + resourceId?: string, + description?: string, + key?: string, + strategy?: string, + maxBucketSize?: number, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + createRateLimitRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + number?, + number?, + string?, + string?, + string?, + string?, + number?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + limit: rest[2] as number, + interval: rest[3] as number, + resourceId: rest[4] as string, + description: rest[5] as string, + key: rest[6] as string, + strategy: rest[7] as string, + maxBucketSize: rest[8] as number, + priority: rest[9] as number, + enabled: rest[10] as boolean, + conditions: rest[11] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const limit = params.limit; + const interval = params.interval; + const resourceId = params.resourceId; + const description = params.description; + const key = params.key; + const strategy = params.strategy; + const maxBucketSize = params.maxBucketSize; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof limit === 'undefined') { + throw new AppwriteException('Missing required parameter: "limit"'); + } + if (typeof interval === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "interval"', + ); + } + const apiPath = '/waf/rules/rate-limit'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof strategy !== 'undefined') { + apiPayload['strategy'] = strategy; + } + if (typeof maxBucketSize !== 'undefined') { + apiPayload['maxBucketSize'] = maxBucketSize; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.name - Rule name. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} params.interval - Interval in seconds used for rate limiting. + * @param {string} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {number} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to disable the rule. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRateLimitRule(params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + limit?: number; + interval?: number; + key?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} name - Rule name. + * @param {string} description - Optional description for the rule. + * @param {number} limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} interval - Interval in seconds used for rate limiting. + * @param {string} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {number} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to disable the rule. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRateLimitRule( + ruleId: string, + resourceType?: string, + resourceId?: string, + name?: string, + description?: string, + limit?: number, + interval?: number, + key?: string, + maxBucketSize?: number, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + updateRateLimitRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + limit?: number; + interval?: number; + key?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + number?, + number?, + string?, + number?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + limit?: number; + interval?: number; + key?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + limit?: number; + interval?: number; + key?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + resourceId: rest[1] as string, + name: rest[2] as string, + description: rest[3] as string, + limit: rest[4] as number, + interval: rest[5] as number, + key: rest[6] as string, + maxBucketSize: rest[7] as number, + priority: rest[8] as number, + enabled: rest[9] as boolean, + conditions: rest[10] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const limit = params.limit; + const interval = params.interval; + const key = params.key; + const maxBucketSize = params.maxBucketSize; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/rate-limit/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof maxBucketSize !== 'undefined') { + apiPayload['maxBucketSize'] = maxBucketSize; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + + /** + * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string} params.location - Location used for redirect responses. + * @param {number} params.statusCode - Integer status code used for redirect responses. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRedirectRule(params: { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string} location - Location used for redirect responses. + * @param {number} statusCode - Integer status code used for redirect responses. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRedirectRule( + ruleId: string, + resourceType: string, + name: string, + location: string, + statusCode: number, + resourceId?: string, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + createRedirectRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + string?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + location: rest[2] as string, + statusCode: rest[3] as number, + resourceId: rest[4] as string, + description: rest[5] as string, + priority: rest[6] as number, + enabled: rest[7] as boolean, + conditions: rest[8] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const location = params.location; + const statusCode = params.statusCode; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof location === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "location"', + ); + } + if (typeof statusCode === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "statusCode"', + ); + } + const apiPath = '/waf/rules/redirect'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof location !== 'undefined') { + apiPayload['location'] = location; + } + if (typeof statusCode !== 'undefined') { + apiPayload['statusCode'] = statusCode; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('post', uri, apiHeaders, apiPayload); + } + + /** + * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.name - Rule name. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.location - Location used for redirect responses. + * @param {number} params.statusCode - Integer status code used for redirect responses. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to disable the rule. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRedirectRule(params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + location?: string; + statusCode?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} name - Rule name. + * @param {string} description - Optional description for the rule. + * @param {string} location - Location used for redirect responses. + * @param {number} statusCode - Integer status code used for redirect responses. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to disable the rule. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRedirectRule( + ruleId: string, + resourceType?: string, + resourceId?: string, + name?: string, + description?: string, + location?: string, + statusCode?: number, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + updateRedirectRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + location?: string; + statusCode?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + number?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + location?: string; + statusCode?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + location?: string; + statusCode?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + resourceId: rest[1] as string, + name: rest[2] as string, + description: rest[3] as string, + location: rest[4] as string, + statusCode: rest[5] as number, + priority: rest[6] as number, + enabled: rest[7] as boolean, + conditions: rest[8] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const location = params.location; + const statusCode = params.statusCode; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/redirect/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof location !== 'undefined') { + apiPayload['location'] = location; + } + if (typeof statusCode !== 'undefined') { + apiPayload['statusCode'] = statusCode; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('patch', uri, apiHeaders, apiPayload); + } + + /** + * Get a WAF rule by its ID. + * + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getRule(params: { + ruleId: string; + }): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + >; + /** + * Get a WAF rule by its ID. + * + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRule( + ruleId: string, + ): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + >; + getRule( + paramsOrFirst: { ruleId: string } | string, + ): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + > { + let params: { ruleId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string, + }; + } + + const ruleId = params.ruleId; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Delete a WAF rule. + * + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteRule(params: { ruleId: string }): Promise<{}>; + /** + * Delete a WAF rule. + * + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteRule(ruleId: string): Promise<{}>; + deleteRule(paramsOrFirst: { ruleId: string } | string): Promise<{}> { + let params: { ruleId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string, + }; + } + + const ruleId = params.ruleId; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } +} diff --git a/test/services/account.test.js b/test/services/account.test.js index 072fc136..7adba21e 100644 --- a/test/services/account.test.js +++ b/test/services/account.test.js @@ -828,6 +828,44 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method createRecoveryOTP()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c168bb8', + secret: '', + expire: '2020-10-15T06:38:00.000+00:00', + phrase: 'Golden Fox', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.createRecoveryOTP('email@example.com'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRecoveryOTP()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c168bb8', + secret: '', + expire: '2020-10-15T06:38:00.000+00:00', + phrase: 'Golden Fox', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updateRecoveryOTP( + '', + '', + 'password', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method listSessions()', async () => { const data = { total: 5, @@ -934,6 +972,49 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method createIdTokenSession()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + userId: '5e5bb8c16897e', + expire: '2020-10-15T06:38:00.000+00:00', + provider: 'email', + providerUid: 'user@example.com', + providerAccessToken: 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + providerAccessTokenExpiry: '2020-10-15T06:38:00.000+00:00', + providerRefreshToken: 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + ip: '127.0.0.1', + osCode: 'Mac', + osName: 'Mac', + osVersion: 'Mac', + clientType: 'browser', + clientCode: 'CM', + clientName: 'Chrome Mobile iOS', + clientVersion: '84.0', + clientEngine: 'WebKit', + clientEngineVersion: '605.1.15', + deviceName: 'smartphone', + deviceBrand: 'Google', + deviceModel: 'Nexus 5', + countryCode: 'US', + countryName: 'United States', + current: true, + factors: [], + secret: '5e5bb8c16897e', + mfaUpdatedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.createIdTokenSession( + 'apple', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method updateMagicURLSession()', async () => { const data = { '\\$id': '5e5ea5c16897e', @@ -1358,6 +1439,43 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method createEmailVerificationOTP()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c168bb8', + secret: '', + expire: '2020-10-15T06:38:00.000+00:00', + phrase: 'Golden Fox', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.createEmailVerificationOTP(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateEmailVerificationOTP()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c168bb8', + secret: '', + expire: '2020-10-15T06:38:00.000+00:00', + phrase: 'Golden Fox', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updateEmailVerificationOTP( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method createPhoneVerification()', async () => { const data = { '\\$id': 'bb8ea5c16897e', diff --git a/test/services/avatars.test.js b/test/services/avatars.test.js index 62baf68d..ecd45047 100644 --- a/test/services/avatars.test.js +++ b/test/services/avatars.test.js @@ -1,4 +1,5 @@ const { Client } = require('../../dist/client'); +const { InputFile } = require('../../dist/inputFile'); const { Avatars } = require('../../dist/services/avatars'); const { fetch: mockedFetch, Response } = require('undici'); @@ -81,6 +82,45 @@ describe('Avatars', () => { expect(response).toEqual(data); }); + test('test method updatePhoto()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'John Doe', + registration: '2020-10-15T06:38:00.000+00:00', + status: true, + labels: [], + passwordUpdate: '2020-10-15T06:38:00.000+00:00', + email: 'john@appwrite.io', + phone: '+4930901820', + emailVerification: true, + phoneVerification: true, + mfa: true, + prefs: {}, + targets: [], + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await avatars.updatePhoto( + InputFile.fromBuffer(new Uint8Array(0), 'image.png'), + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deletePhoto()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await avatars.deletePhoto(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method getQR()', async () => { const data = new ArrayBuffer(0); mockedFetch.mockImplementation(() => new Response(data)); diff --git a/test/services/domains.test.js b/test/services/domains.test.js new file mode 100644 index 00000000..f77cb0ec --- /dev/null +++ b/test/services/domains.test.js @@ -0,0 +1,1012 @@ +const { Client } = require('../../dist/client'); +const { Domains } = require('../../dist/services/domains'); + +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); + +describe('Domains', () => { + const client = new Client(); + const domains = new Domains(client); + + test('test method list()', async () => { + const data = { + total: 5, + domains: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.list(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method create()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + domain: 'example.com', + registrar: 'appwrite', + nameservers: 'Appwrite', + expire: '2020-10-15T06:38:00.000+00:00', + renewal: '2020-10-15T06:38:00.000+00:00', + autoRenewal: true, + renewalPrice: 2599, + teamId: '5e5ea5c16897e', + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.create('', 'example.com'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPrice()', async () => { + const data = { + domain: 'example.com', + tld: 'com', + available: true, + periodYears: 1, + premium: true, + renewalPeriodYears: 1, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.getPrice('example.com'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listPrices()', async () => { + const data = { + total: 5, + prices: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.listPrices([]); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method get()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + domain: 'example.com', + registrar: 'appwrite', + nameservers: 'Appwrite', + expire: '2020-10-15T06:38:00.000+00:00', + renewal: '2020-10-15T06:38:00.000+00:00', + autoRenewal: true, + renewalPrice: 2599, + teamId: '5e5ea5c16897e', + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.get(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method delete()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.delete(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateNameservers()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + domain: 'example.com', + registrar: 'appwrite', + nameservers: 'Appwrite', + expire: '2020-10-15T06:38:00.000+00:00', + renewal: '2020-10-15T06:38:00.000+00:00', + autoRenewal: true, + renewalPrice: 2599, + teamId: '5e5ea5c16897e', + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.updateNameservers(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method verifyNameservers()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + domain: 'example.com', + registrar: 'appwrite', + nameservers: 'Appwrite', + expire: '2020-10-15T06:38:00.000+00:00', + renewal: '2020-10-15T06:38:00.000+00:00', + autoRenewal: true, + renewalPrice: 2599, + teamId: '5e5ea5c16897e', + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.verifyNameservers(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPresetGoogleWorkspace()', async () => { + const data = { + total: 5, + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.getPresetGoogleWorkspace(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createPresetGoogleWorkspace()', async () => { + const data = { + total: 5, + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = + await domains.createPresetGoogleWorkspace(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPresetICloud()', async () => { + const data = { + total: 5, + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.getPresetICloud(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createPresetICloud()', async () => { + const data = { + total: 5, + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.createPresetICloud(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPresetMailgun()', async () => { + const data = { + total: 5, + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.getPresetMailgun(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createPresetMailgun()', async () => { + const data = { + total: 5, + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.createPresetMailgun(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPresetOutlook()', async () => { + const data = { + total: 5, + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.getPresetOutlook(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createPresetOutlook()', async () => { + const data = { + total: 5, + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.createPresetOutlook(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPresetProtonMail()', async () => { + const data = { + total: 5, + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.getPresetProtonMail(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createPresetProtonMail()', async () => { + const data = { + total: 5, + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.createPresetProtonMail(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPresetZoho()', async () => { + const data = { + total: 5, + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.getPresetZoho(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createPresetZoho()', async () => { + const data = { + total: 5, + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.createPresetZoho(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listRecords()', async () => { + const data = { + total: 5, + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.listRecords(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRecordA()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.createRecordA( + '', + 'name', + 'value', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRecordA()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.updateRecordA( + '', + '', + 'name', + 'value', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRecordAAAA()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.createRecordAAAA( + '', + 'name', + 'value', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRecordAAAA()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.updateRecordAAAA( + '', + '', + 'name', + 'value', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRecordAlias()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.createRecordAlias( + '', + 'name', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRecordAlias()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.updateRecordAlias( + '', + '', + 'name', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRecordCAA()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.createRecordCAA( + '', + 'name', + 'value', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRecordCAA()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.updateRecordCAA( + '', + '', + 'name', + 'value', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRecordCNAME()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.createRecordCNAME( + '', + 'name', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRecordCNAME()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.updateRecordCNAME( + '', + '', + 'name', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRecordHTTPS()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.createRecordHTTPS( + '', + 'name', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRecordHTTPS()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.updateRecordHTTPS( + '', + '', + 'name', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRecordMX()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.createRecordMX( + '', + 'name', + '', + 1, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRecordMX()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.updateRecordMX( + '', + '', + 'name', + '', + 1, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRecordNS()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.createRecordNS( + '', + 'name', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRecordNS()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.updateRecordNS( + '', + '', + 'name', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRecordSRV()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.createRecordSRV( + '', + 'name', + '', + 1, + 1, + 1, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRecordSRV()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.updateRecordSRV( + '', + '', + 'name', + '', + 1, + 1, + 1, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRecordTXT()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.createRecordTXT( + '', + 'name', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRecordTXT()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.updateRecordTXT( + '', + '', + 'name', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getRecord()', async () => { + const data = { + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'A', + name: 'mail', + value: '192.0.2.1', + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: 'Mail server record', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.getRecord('', ''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteRecord()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.deleteRecord( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateTeam()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + domain: 'example.com', + registrar: 'appwrite', + nameservers: 'Appwrite', + expire: '2020-10-15T06:38:00.000+00:00', + renewal: '2020-10-15T06:38:00.000+00:00', + autoRenewal: true, + renewalPrice: 2599, + teamId: '5e5ea5c16897e', + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.updateTeam('', ''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getTransferStatus()', async () => { + const data = { + status: 'pending_registry', + reason: 'Transfer in progress', + timestamp: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.getTransferStatus(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getZone()', async () => { + const data = 'text'; + mockedFetch.mockImplementation(() => new Response(data)); + const response = await domains.getZone(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateZone()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + domain: 'example.com', + registrar: 'appwrite', + nameservers: 'Appwrite', + expire: '2020-10-15T06:38:00.000+00:00', + renewal: '2020-10-15T06:38:00.000+00:00', + autoRenewal: true, + renewalPrice: 2599, + teamId: '5e5ea5c16897e', + dnsRecords: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await domains.updateZone('', ''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); +}); diff --git a/test/services/messaging.test.js b/test/services/messaging.test.js index 5afb42c2..83b93177 100644 --- a/test/services/messaging.test.js +++ b/test/services/messaging.test.js @@ -335,6 +335,48 @@ describe('Messaging', () => { expect(response).toEqual(data); }); + test('test method createAppwriteProvider()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Mailgun', + provider: 'mailgun', + enabled: true, + type: 'sms', + credentials: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await messaging.createAppwriteProvider( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateAppwriteProvider()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Mailgun', + provider: 'mailgun', + enabled: true, + type: 'sms', + credentials: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = + await messaging.updateAppwriteProvider(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method createFcmProvider()', async () => { const data = { '\\$id': '5e5ea5c16897e', diff --git a/test/services/oauth2.test.js b/test/services/oauth2.test.js index 7523dcf0..716e7be0 100644 --- a/test/services/oauth2.test.js +++ b/test/services/oauth2.test.js @@ -116,6 +116,18 @@ describe('Oauth2', () => { expect(response).toEqual(data); }); + test('test method introspect()', async () => { + const data = { + active: true, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await oauth2.introspect(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method listOrganizations()', async () => { const data = { total: 5, diff --git a/test/services/organization.test.js b/test/services/organization.test.js index d01389af..8fe44cee 100644 --- a/test/services/organization.test.js +++ b/test/services/organization.test.js @@ -501,6 +501,104 @@ describe('Organization', () => { // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; + expect(response).toEqual(data); + }); + test('test method listProjectKeys()', async () => { + const data = { + total: 5, + keys: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await organization.listProjectKeys(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createEphemeralProjectKey()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'My API Key', + expire: '2020-10-15T06:38:00.000+00:00', + scopes: [], + secret: '919c2d18fb5d4...a2ae413da83346ad2', + accessedAt: '2020-10-15T06:38:00.000+00:00', + sdks: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await organization.createEphemeralProjectKey( + '', + [], + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getProjectKey()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'My API Key', + expire: '2020-10-15T06:38:00.000+00:00', + scopes: [], + secret: '919c2d18fb5d4...a2ae413da83346ad2', + accessedAt: '2020-10-15T06:38:00.000+00:00', + sdks: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await organization.getProjectKey( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateProjectKey()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'My API Key', + expire: '2020-10-15T06:38:00.000+00:00', + scopes: [], + secret: '919c2d18fb5d4...a2ae413da83346ad2', + accessedAt: '2020-10-15T06:38:00.000+00:00', + sdks: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await organization.updateProjectKey( + '', + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteProjectKey()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await organization.deleteProjectKey( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + expect(response).toEqual(data); }); }); diff --git a/test/services/project.test.js b/test/services/project.test.js index fc1abdb9..4755bf50 100644 --- a/test/services/project.test.js +++ b/test/services/project.test.js @@ -97,6 +97,146 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method listEnvironments()', async () => { + const data = { + total: 5, + projects: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.listEnvironments(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.createEnvironment( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.getEnvironment(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateEnvironment( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteEnvironment()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.deleteEnvironment(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method listKeys()', async () => { const data = { total: 5, @@ -687,6 +827,22 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updateOAuth2Kakao()', async () => { + const data = { + $id: 'github', + enabled: true, + clientId: '839ff5000000000000000000013206de', + clientSecret: 'jLNVOK00000000000000000000yJebea', + prompt: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateOAuth2Kakao(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method updateOAuth2Keycloak()', async () => { const data = { '\\$id': 'github', @@ -935,6 +1091,21 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updateOAuth2TikTok()', async () => { + const data = { + $id: 'github', + enabled: true, + clientId: 'awz000000000tyw0', + clientSecret: '6wXewM00000000000000000000yXnite', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateOAuth2TikTok(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method updateOAuth2Tradeshift()', async () => { const data = { '\\$id': 'github', @@ -980,6 +1151,23 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updateOAuth2Webflow()', async () => { + const data = { + $id: 'github', + enabled: true, + clientId: + '8bb20000000000000000000000000000000000000000000000000000000040dd', + clientSecret: + '59bf00000000000000000000000000000000000000000000000000000000fe59', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateOAuth2Webflow(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method updateOAuth2WordPress()', async () => { const data = { '\\$id': 'github', @@ -1076,9 +1264,9 @@ describe('Project', () => { const data = { '\\$id': 'github', enabled: true, - applicationId: '00001111-aaaa-2222-bbbb-3333cccc4444', - applicationSecret: 'A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u', - tenant: 'common', + clientId: '839ff5000000000000000000013206de', + clientSecret: 'jLNVOK00000000000000000000yJebea', + prompt: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.getOAuth2Provider('amazon'); @@ -1730,6 +1918,80 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updatePasswordPwnedPolicy()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updatePasswordPwnedPolicy(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasswordRotationPolicy()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updatePasswordRotationPolicy(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method updatePasswordStrengthPolicy()', async () => { const data = { '\\$id': 'password-dictionary', diff --git a/test/services/waf.test.js b/test/services/waf.test.js new file mode 100644 index 00000000..1e672a24 --- /dev/null +++ b/test/services/waf.test.js @@ -0,0 +1,354 @@ +const { Client } = require('../../dist/client'); +const { Waf } = require('../../dist/services/waf'); + +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); + +describe('Waf', () => { + const client = new Client(); + const waf = new Waf(client); + + test('test method listRules()', async () => { + const data = { + total: 5, + rules: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.listRules(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBypassRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createBypassRule( + '', + 'api', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateBypassRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateBypassRule(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createChallengeRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createChallengeRule( + '', + 'api', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateChallengeRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateChallengeRule(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createDenyRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createDenyRule('', 'api', ''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateDenyRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateDenyRule(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRateLimitRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + limit: 1000, + interval: 60, + key: 'userId', + strategy: 'slidingWindow', + maxBucketSize: 200, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createRateLimitRule( + '', + 'api', + '', + 1, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRateLimitRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + limit: 1000, + interval: 60, + key: 'userId', + strategy: 'slidingWindow', + maxBucketSize: 200, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateRateLimitRule(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRedirectRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createRedirectRule( + '', + 'api', + '', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRedirectRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateRedirectRule(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.getRule(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteRule()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.deleteRule(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); +}); From 17de4b42494e8e30917b05cbfed719dc02d7135c Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 14 Oct 2026 12:56:33 +0100 Subject: [PATCH 2/2] fix: accept null for the messaging qos params Null lets the subscriber choose the QoS, as the docs say, so the TypeScript input type must allow it. Also corrects the domains changelog line. --- CHANGELOG.md | 2 +- src/services/messaging.ts | 64 +++++++++++++++++++-------------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81d1ea4f..041a1b65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 29.4.0 -* Added: `domains` service to register, transfer and manage domains, DNS records, email presets and zones +* Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones * Added: `waf` service with bypass, challenge, deny, rate-limit and redirect rules * Added: `account.createEmailVerificationOTP`, `updateEmailVerificationOTP`, `createRecoveryOTP` and `updateRecoveryOTP` * Added: `account.createIdTokenSession` and `Identity.providerIdToken` diff --git a/src/services/messaging.ts b/src/services/messaging.ts index beb15901..34b1087e 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -2725,7 +2725,7 @@ export class Messaging { * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. * @param {boolean} params.enabled - Set as enabled. - * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} @@ -2734,7 +2734,7 @@ export class Messaging { providerId: string; name: string; enabled?: boolean; - qos?: number; + qos?: number | null; expiry?: number; }): Promise; /** @@ -2743,7 +2743,7 @@ export class Messaging { * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. * @param {boolean} enabled - Set as enabled. - * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} @@ -2753,7 +2753,7 @@ export class Messaging { providerId: string, name: string, enabled?: boolean, - qos?: number, + qos?: number | null, expiry?: number, ): Promise; createAppwriteProvider( @@ -2762,7 +2762,7 @@ export class Messaging { providerId: string; name: string; enabled?: boolean; - qos?: number; + qos?: number | null; expiry?: number; } | string, @@ -2772,7 +2772,7 @@ export class Messaging { providerId: string; name: string; enabled?: boolean; - qos?: number; + qos?: number | null; expiry?: number; }; @@ -2785,7 +2785,7 @@ export class Messaging { providerId: string; name: string; enabled?: boolean; - qos?: number; + qos?: number | null; expiry?: number; }; } else { @@ -2793,7 +2793,7 @@ export class Messaging { providerId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, - qos: rest[2] as number, + qos: rest[2] as number | null, expiry: rest[3] as number, }; } @@ -2845,7 +2845,7 @@ export class Messaging { * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. * @param {boolean} params.enabled - Set as enabled. - * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} @@ -2854,7 +2854,7 @@ export class Messaging { providerId: string; name?: string; enabled?: boolean; - qos?: number; + qos?: number | null; expiry?: number; }): Promise; /** @@ -2863,7 +2863,7 @@ export class Messaging { * @param {string} providerId - Provider ID. * @param {string} name - Provider name. * @param {boolean} enabled - Set as enabled. - * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} @@ -2873,7 +2873,7 @@ export class Messaging { providerId: string, name?: string, enabled?: boolean, - qos?: number, + qos?: number | null, expiry?: number, ): Promise; updateAppwriteProvider( @@ -2882,7 +2882,7 @@ export class Messaging { providerId: string; name?: string; enabled?: boolean; - qos?: number; + qos?: number | null; expiry?: number; } | string, @@ -2892,7 +2892,7 @@ export class Messaging { providerId: string; name?: string; enabled?: boolean; - qos?: number; + qos?: number | null; expiry?: number; }; @@ -2905,7 +2905,7 @@ export class Messaging { providerId: string; name?: string; enabled?: boolean; - qos?: number; + qos?: number | null; expiry?: number; }; } else { @@ -2913,7 +2913,7 @@ export class Messaging { providerId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, - qos: rest[2] as number, + qos: rest[2] as number | null, expiry: rest[3] as number, }; } @@ -7260,7 +7260,7 @@ export class Messaging { * @param {string} params.topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} params.name - Topic Name. * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} @@ -7269,7 +7269,7 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; + qos?: number | null; expiry?: number; }): Promise; /** @@ -7278,7 +7278,7 @@ export class Messaging { * @param {string} topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} name - Topic Name. * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} @@ -7288,7 +7288,7 @@ export class Messaging { topicId: string, name: string, subscribe?: string[], - qos?: number, + qos?: number | null, expiry?: number, ): Promise; createTopic( @@ -7297,7 +7297,7 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; + qos?: number | null; expiry?: number; } | string, @@ -7307,7 +7307,7 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; + qos?: number | null; expiry?: number; }; @@ -7320,7 +7320,7 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; + qos?: number | null; expiry?: number; }; } else { @@ -7328,7 +7328,7 @@ export class Messaging { topicId: paramsOrFirst as string, name: rest[0] as string, subscribe: rest[1] as string[], - qos: rest[2] as number, + qos: rest[2] as number | null, expiry: rest[3] as number, }; } @@ -7438,7 +7438,7 @@ export class Messaging { * @param {string} params.topicId - Topic ID. * @param {string} params.name - Topic Name. * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} @@ -7447,7 +7447,7 @@ export class Messaging { topicId: string; name?: string; subscribe?: string[]; - qos?: number; + qos?: number | null; expiry?: number; }): Promise; /** @@ -7457,7 +7457,7 @@ export class Messaging { * @param {string} topicId - Topic ID. * @param {string} name - Topic Name. * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). * @throws {AppwriteException} * @returns {Promise} @@ -7467,7 +7467,7 @@ export class Messaging { topicId: string, name?: string, subscribe?: string[], - qos?: number, + qos?: number | null, expiry?: number, ): Promise; updateTopic( @@ -7476,7 +7476,7 @@ export class Messaging { topicId: string; name?: string; subscribe?: string[]; - qos?: number; + qos?: number | null; expiry?: number; } | string, @@ -7486,7 +7486,7 @@ export class Messaging { topicId: string; name?: string; subscribe?: string[]; - qos?: number; + qos?: number | null; expiry?: number; }; @@ -7499,7 +7499,7 @@ export class Messaging { topicId: string; name?: string; subscribe?: string[]; - qos?: number; + qos?: number | null; expiry?: number; }; } else { @@ -7507,7 +7507,7 @@ export class Messaging { topicId: paramsOrFirst as string, name: rest[0] as string, subscribe: rest[1] as string[], - qos: rest[2] as number, + qos: rest[2] as number | null, expiry: rest[3] as number, }; }