diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..c14dbf09 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,13 @@ +node_modules/ +dist/ +types/ +package-lock.json + +# CI workflow files follow the YAML conventions of the publishing repository, +# not this SDK's source formatting. +.github/ + +# README and CHANGELOG carry caller-supplied markdown verbatim, which this +# SDK's formatter must not rewrite. +README.md +CHANGELOG.md diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..9b0bb437 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +{ + "tabWidth": 4, + "singleQuote": true +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b5d09b3..7d247ddd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Change Log +## 29.0.0-rc.1 + +* Breaking: `Execution.functionId` is replaced by `resourceId` and `resourceType`, now that executions cover both functions and sites +* Breaking: `AppInstallation.authorizationDetails` is now an array instead of an object +* Breaking: removed `dedicatedDatabases.execute` from `ProjectKeyScopes` +* Breaking: `EmbeddingModel` no longer offers `embedding-gemma` or `bge-small` +* Added: `documentsDB`, `vectorsDB`, `mysql`, `postgresql`, and `mongo` services, no longer hidden from server SDKs +* Added: `DocumentsDBIndexType` and `VectorsDBIndexType` enums +* Added: dedicated database models for branches, backups, restorations, poolers, PITR windows, extensions, and executions +* Added: `PostgresExtension`, `VectorsdbCollection`, `AttributeObject`, and `AttributeVector` models +* Added: `ExecutionResourceType` enum and `resourceType` on the `Execution` model +* Added: `OAuth2HuggingFace` model and the `huggingface` OAuth provider +* Added: `userId`, `emailHash`, and `name` parameters to `avatars.getPhoto` +* Added: `error`, `containerStatus`, and `lifecycleState` on the `Database` model +* Added: `changelogWatermark` on the `DatabaseMigration` model +* Added: `total` on the `DedicatedDatabaseBranchList` model +* Updated: `DedicatedDatabaseOperation.status` documents the new `queued` state + ## 28.0.0 * Breaking: removed `account.createJWT`; use `users.createJWT` instead. A leaked JWT could mint further JWTs, letting a credential outlive its own expiry — a session cannot duplicate itself to live forever either diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md index 125d73bb..fcc1ff18 100644 --- a/docs/examples/account/create-email-password-session.md +++ b/docs/examples/account/create-email-password-session.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.createEmailPasswordSession({ email: 'email@example.com', - password: 'password' + password: 'password', }); ``` diff --git a/docs/examples/account/create-email-token.md b/docs/examples/account/create-email-token.md index cebf1f61..639d3e18 100644 --- a/docs/examples/account/create-email-token.md +++ b/docs/examples/account/create-email-token.md @@ -11,6 +11,6 @@ const account = new sdk.Account(client); const result = await account.createEmailToken({ userId: '', email: 'email@example.com', - phrase: false // optional + phrase: false, // optional }); ``` diff --git a/docs/examples/account/create-email-verification.md b/docs/examples/account/create-email-verification.md index 6c74da96..15111f2f 100644 --- a/docs/examples/account/create-email-verification.md +++ b/docs/examples/account/create-email-verification.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); const result = await account.createEmailVerification({ - url: 'https://example.com' + url: 'https://example.com', }); ``` diff --git a/docs/examples/account/create-magic-url-token.md b/docs/examples/account/create-magic-url-token.md index ee5f1432..e1a85018 100644 --- a/docs/examples/account/create-magic-url-token.md +++ b/docs/examples/account/create-magic-url-token.md @@ -12,6 +12,6 @@ const result = await account.createMagicURLToken({ userId: '', email: 'email@example.com', url: 'https://example.com', // optional - phrase: false // optional + phrase: false, // optional }); ``` diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md index 25081e27..7574207e 100644 --- a/docs/examples/account/create-mfa-authenticator.md +++ b/docs/examples/account/create-mfa-authenticator.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); const result = await account.createMFAAuthenticator({ - type: sdk.AuthenticatorType.Totp + type: sdk.AuthenticatorType.Totp, }); ``` diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md index af4e0448..d3550e37 100644 --- a/docs/examples/account/create-mfa-challenge.md +++ b/docs/examples/account/create-mfa-challenge.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); const result = await account.createMFAChallenge({ - factor: sdk.AuthenticationFactor.Email + factor: sdk.AuthenticationFactor.Email, }); ``` diff --git a/docs/examples/account/create-o-auth-2-token.md b/docs/examples/account/create-o-auth-2-token.md index 7bc8a243..40e1d1fb 100644 --- a/docs/examples/account/create-o-auth-2-token.md +++ b/docs/examples/account/create-o-auth-2-token.md @@ -12,6 +12,6 @@ const result = await account.createOAuth2Token({ provider: sdk.OAuthProvider.Amazon, success: 'https://example.com', // optional failure: 'https://example.com', // optional - scopes: [] // optional + scopes: [], // optional }); ``` diff --git a/docs/examples/account/create-phone-token.md b/docs/examples/account/create-phone-token.md index 999f3e10..d40e003a 100644 --- a/docs/examples/account/create-phone-token.md +++ b/docs/examples/account/create-phone-token.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.createPhoneToken({ userId: '', - phone: '+12065550100' + phone: '+12065550100', }); ``` diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md index 4dd41d7e..9b6d8f3e 100644 --- a/docs/examples/account/create-recovery.md +++ b/docs/examples/account/create-recovery.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.createRecovery({ email: 'email@example.com', - url: 'https://example.com' + url: 'https://example.com', }); ``` diff --git a/docs/examples/account/create-session.md b/docs/examples/account/create-session.md index 3ab786f9..75a2ee44 100644 --- a/docs/examples/account/create-session.md +++ b/docs/examples/account/create-session.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.createSession({ userId: '', - secret: '' + secret: '', }); ``` diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md index 95dec7e3..abe7084e 100644 --- a/docs/examples/account/create-verification.md +++ b/docs/examples/account/create-verification.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); const result = await account.createVerification({ - url: 'https://example.com' + url: 'https://example.com', }); ``` diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md index abc8c133..2c94473e 100644 --- a/docs/examples/account/create.md +++ b/docs/examples/account/create.md @@ -12,6 +12,6 @@ const result = await account.create({ userId: '', email: 'email@example.com', password: 'password', - name: '' // optional + name: '', // optional }); ``` diff --git a/docs/examples/account/delete-consent-token.md b/docs/examples/account/delete-consent-token.md index 3b45b092..5b776176 100644 --- a/docs/examples/account/delete-consent-token.md +++ b/docs/examples/account/delete-consent-token.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.deleteConsentToken({ consentId: '', - tokenId: '' + tokenId: '', }); ``` diff --git a/docs/examples/account/delete-consent.md b/docs/examples/account/delete-consent.md index eb93abad..3265e8fd 100644 --- a/docs/examples/account/delete-consent.md +++ b/docs/examples/account/delete-consent.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); const result = await account.deleteConsent({ - consentId: '' + consentId: '', }); ``` diff --git a/docs/examples/account/delete-identity.md b/docs/examples/account/delete-identity.md index 53a043bf..050134cf 100644 --- a/docs/examples/account/delete-identity.md +++ b/docs/examples/account/delete-identity.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); const result = await account.deleteIdentity({ - identityId: '' + identityId: '', }); ``` diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md index 18522f2d..b3e5156f 100644 --- a/docs/examples/account/delete-mfa-authenticator.md +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); const result = await account.deleteMFAAuthenticator({ - type: sdk.AuthenticatorType.Totp + type: sdk.AuthenticatorType.Totp, }); ``` diff --git a/docs/examples/account/delete-session.md b/docs/examples/account/delete-session.md index 7fe49e3f..ed992d47 100644 --- a/docs/examples/account/delete-session.md +++ b/docs/examples/account/delete-session.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); const result = await account.deleteSession({ - sessionId: '' + sessionId: '', }); ``` diff --git a/docs/examples/account/get-consent-token.md b/docs/examples/account/get-consent-token.md index 3ae6c1ea..f2b7e1ef 100644 --- a/docs/examples/account/get-consent-token.md +++ b/docs/examples/account/get-consent-token.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.getConsentToken({ consentId: '', - tokenId: '' + tokenId: '', }); ``` diff --git a/docs/examples/account/get-consent.md b/docs/examples/account/get-consent.md index fc7cb6c7..77e8e39e 100644 --- a/docs/examples/account/get-consent.md +++ b/docs/examples/account/get-consent.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); const result = await account.getConsent({ - consentId: '' + consentId: '', }); ``` diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md index dab81595..7ccfd779 100644 --- a/docs/examples/account/get-session.md +++ b/docs/examples/account/get-session.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); const result = await account.getSession({ - sessionId: '' + sessionId: '', }); ``` diff --git a/docs/examples/account/list-consent-tokens.md b/docs/examples/account/list-consent-tokens.md index d271066f..0b12b44f 100644 --- a/docs/examples/account/list-consent-tokens.md +++ b/docs/examples/account/list-consent-tokens.md @@ -11,6 +11,6 @@ const account = new sdk.Account(client); const result = await account.listConsentTokens({ consentId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/account/list-consents.md b/docs/examples/account/list-consents.md index 12ec54ef..75530933 100644 --- a/docs/examples/account/list-consents.md +++ b/docs/examples/account/list-consents.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.listConsents({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md index 00d60b9e..e538a49e 100644 --- a/docs/examples/account/list-identities.md +++ b/docs/examples/account/list-identities.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.listIdentities({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md index d7e89331..6d993109 100644 --- a/docs/examples/account/list-logs.md +++ b/docs/examples/account/list-logs.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.listLogs({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/account/update-email-verification.md b/docs/examples/account/update-email-verification.md index 4fd5953b..49f012f0 100644 --- a/docs/examples/account/update-email-verification.md +++ b/docs/examples/account/update-email-verification.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.updateEmailVerification({ userId: '', - secret: '' + secret: '', }); ``` diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md index 985c189b..ed5188a8 100644 --- a/docs/examples/account/update-email.md +++ b/docs/examples/account/update-email.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.updateEmail({ email: 'email@example.com', - password: 'password' + password: 'password', }); ``` diff --git a/docs/examples/account/update-magic-url-session.md b/docs/examples/account/update-magic-url-session.md index 1811200a..790f69fc 100644 --- a/docs/examples/account/update-magic-url-session.md +++ b/docs/examples/account/update-magic-url-session.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.updateMagicURLSession({ userId: '', - secret: '' + secret: '', }); ``` diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md index fa34ef45..5f3edbeb 100644 --- a/docs/examples/account/update-mfa-authenticator.md +++ b/docs/examples/account/update-mfa-authenticator.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.updateMFAAuthenticator({ type: sdk.AuthenticatorType.Totp, - otp: '' + otp: '', }); ``` diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md index a584356b..01defd1c 100644 --- a/docs/examples/account/update-mfa-challenge.md +++ b/docs/examples/account/update-mfa-challenge.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.updateMFAChallenge({ challengeId: '', - otp: '' + otp: '', }); ``` diff --git a/docs/examples/account/update-mfa.md b/docs/examples/account/update-mfa.md index 38604a3b..63fa217e 100644 --- a/docs/examples/account/update-mfa.md +++ b/docs/examples/account/update-mfa.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); const result = await account.updateMFA({ - mfa: false + mfa: false, }); ``` diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md index 24fb8692..20bac30a 100644 --- a/docs/examples/account/update-name.md +++ b/docs/examples/account/update-name.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); const result = await account.updateName({ - name: '' + name: '', }); ``` diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index d359b344..cef8c690 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.updatePassword({ password: 'password', - oldPassword: 'password' // optional + oldPassword: 'password', // optional }); ``` diff --git a/docs/examples/account/update-phone-session.md b/docs/examples/account/update-phone-session.md index 204c33a7..5a2035e4 100644 --- a/docs/examples/account/update-phone-session.md +++ b/docs/examples/account/update-phone-session.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.updatePhoneSession({ userId: '', - secret: '' + secret: '', }); ``` diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md index c5e1abd3..796cdfab 100644 --- a/docs/examples/account/update-phone-verification.md +++ b/docs/examples/account/update-phone-verification.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.updatePhoneVerification({ userId: '', - secret: '' + secret: '', }); ``` diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md index c6763022..29158e3e 100644 --- a/docs/examples/account/update-phone.md +++ b/docs/examples/account/update-phone.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.updatePhone({ phone: '+12065550100', - password: 'password' + password: 'password', }); ``` diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index 65c70e0e..a4b167ff 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -10,9 +10,9 @@ const account = new sdk.Account(client); const result = await account.updatePrefs({ prefs: { - "language": "en", - "timezone": "UTC", - "darkTheme": true - } + language: 'en', + timezone: 'UTC', + darkTheme: true, + }, }); ``` diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md index 9008f675..a33078b8 100644 --- a/docs/examples/account/update-recovery.md +++ b/docs/examples/account/update-recovery.md @@ -11,6 +11,6 @@ const account = new sdk.Account(client); const result = await account.updateRecovery({ userId: '', secret: '', - password: 'password' + password: 'password', }); ``` diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md index 9dfcbf26..1e257276 100644 --- a/docs/examples/account/update-session.md +++ b/docs/examples/account/update-session.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); const result = await account.updateSession({ - sessionId: '' + sessionId: '', }); ``` diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md index 0486ce39..6a733622 100644 --- a/docs/examples/account/update-verification.md +++ b/docs/examples/account/update-verification.md @@ -10,6 +10,6 @@ const account = new sdk.Account(client); const result = await account.updateVerification({ userId: '', - secret: '' + secret: '', }); ``` diff --git a/docs/examples/activities/get-event.md b/docs/examples/activities/get-event.md index da7c261f..0cd3641a 100644 --- a/docs/examples/activities/get-event.md +++ b/docs/examples/activities/get-event.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const activities = new sdk.Activities(client); const result = await activities.getEvent({ - eventId: '' + eventId: '', }); ``` diff --git a/docs/examples/activities/list-events.md b/docs/examples/activities/list-events.md index 99263951..97f14e3f 100644 --- a/docs/examples/activities/list-events.md +++ b/docs/examples/activities/list-events.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const activities = new sdk.Activities(client); const result = await activities.listEvents({ - queries: [] // optional + queries: [], // optional }); ``` diff --git a/docs/examples/advisor/delete-report.md b/docs/examples/advisor/delete-report.md index 8169db07..16929bbb 100644 --- a/docs/examples/advisor/delete-report.md +++ b/docs/examples/advisor/delete-report.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const advisor = new sdk.Advisor(client); const result = await advisor.deleteReport({ - reportId: '' + reportId: '', }); ``` diff --git a/docs/examples/advisor/get-insight.md b/docs/examples/advisor/get-insight.md index 7a625d28..882d5ede 100644 --- a/docs/examples/advisor/get-insight.md +++ b/docs/examples/advisor/get-insight.md @@ -10,6 +10,6 @@ const advisor = new sdk.Advisor(client); const result = await advisor.getInsight({ reportId: '', - insightId: '' + insightId: '', }); ``` diff --git a/docs/examples/advisor/get-report.md b/docs/examples/advisor/get-report.md index abd111c0..a523bdc2 100644 --- a/docs/examples/advisor/get-report.md +++ b/docs/examples/advisor/get-report.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const advisor = new sdk.Advisor(client); const result = await advisor.getReport({ - reportId: '' + reportId: '', }); ``` diff --git a/docs/examples/advisor/list-insights.md b/docs/examples/advisor/list-insights.md index a4adefac..6b1d5ea9 100644 --- a/docs/examples/advisor/list-insights.md +++ b/docs/examples/advisor/list-insights.md @@ -11,6 +11,6 @@ const advisor = new sdk.Advisor(client); const result = await advisor.listInsights({ reportId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/advisor/list-reports.md b/docs/examples/advisor/list-reports.md index 6fa66f10..328570e3 100644 --- a/docs/examples/advisor/list-reports.md +++ b/docs/examples/advisor/list-reports.md @@ -10,6 +10,6 @@ const advisor = new sdk.Advisor(client); const result = await advisor.listReports({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/apps/create-installation-token.md b/docs/examples/apps/create-installation-token.md index 2b414528..dca0785c 100644 --- a/docs/examples/apps/create-installation-token.md +++ b/docs/examples/apps/create-installation-token.md @@ -10,6 +10,6 @@ const apps = new sdk.Apps(client); const result = await apps.createInstallationToken({ appId: '', - installationId: '' + installationId: '', }); ``` diff --git a/docs/examples/apps/create-key.md b/docs/examples/apps/create-key.md index 0b358162..db5d4de6 100644 --- a/docs/examples/apps/create-key.md +++ b/docs/examples/apps/create-key.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const apps = new sdk.Apps(client); const result = await apps.createKey({ - appId: '' + appId: '', }); ``` diff --git a/docs/examples/apps/create-secret.md b/docs/examples/apps/create-secret.md index 1f851041..e5a77eaa 100644 --- a/docs/examples/apps/create-secret.md +++ b/docs/examples/apps/create-secret.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const apps = new sdk.Apps(client); const result = await apps.createSecret({ - appId: '' + appId: '', }); ``` diff --git a/docs/examples/apps/create.md b/docs/examples/apps/create.md index 80339c51..613325ec 100644 --- a/docs/examples/apps/create.md +++ b/docs/examples/apps/create.md @@ -27,6 +27,6 @@ const result = await apps.create({ enabled: false, // optional type: 'public', // optional deviceFlow: false, // optional - teamId: '' // optional + teamId: '', // optional }); ``` diff --git a/docs/examples/apps/delete-installation.md b/docs/examples/apps/delete-installation.md index b9933fb9..ca3c4706 100644 --- a/docs/examples/apps/delete-installation.md +++ b/docs/examples/apps/delete-installation.md @@ -10,6 +10,6 @@ const apps = new sdk.Apps(client); const result = await apps.deleteInstallation({ appId: '', - installationId: '' + installationId: '', }); ``` diff --git a/docs/examples/apps/delete-key.md b/docs/examples/apps/delete-key.md index f4f0bb5e..df1050d5 100644 --- a/docs/examples/apps/delete-key.md +++ b/docs/examples/apps/delete-key.md @@ -10,6 +10,6 @@ const apps = new sdk.Apps(client); const result = await apps.deleteKey({ appId: '', - keyId: '' + keyId: '', }); ``` diff --git a/docs/examples/apps/delete-secret.md b/docs/examples/apps/delete-secret.md index eeb1e439..0fca77d2 100644 --- a/docs/examples/apps/delete-secret.md +++ b/docs/examples/apps/delete-secret.md @@ -10,6 +10,6 @@ const apps = new sdk.Apps(client); const result = await apps.deleteSecret({ appId: '', - secretId: '' + secretId: '', }); ``` diff --git a/docs/examples/apps/delete-tokens.md b/docs/examples/apps/delete-tokens.md index 757af7d4..e495a1d6 100644 --- a/docs/examples/apps/delete-tokens.md +++ b/docs/examples/apps/delete-tokens.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const apps = new sdk.Apps(client); const result = await apps.deleteTokens({ - appId: '' + appId: '', }); ``` diff --git a/docs/examples/apps/delete.md b/docs/examples/apps/delete.md index fd9138cd..366a2f57 100644 --- a/docs/examples/apps/delete.md +++ b/docs/examples/apps/delete.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const apps = new sdk.Apps(client); const result = await apps.delete({ - appId: '' + appId: '', }); ``` diff --git a/docs/examples/apps/get-installation.md b/docs/examples/apps/get-installation.md index ceddee24..fb257470 100644 --- a/docs/examples/apps/get-installation.md +++ b/docs/examples/apps/get-installation.md @@ -10,6 +10,6 @@ const apps = new sdk.Apps(client); const result = await apps.getInstallation({ appId: '', - installationId: '' + installationId: '', }); ``` diff --git a/docs/examples/apps/get-key.md b/docs/examples/apps/get-key.md index afc83ccc..f6adfab5 100644 --- a/docs/examples/apps/get-key.md +++ b/docs/examples/apps/get-key.md @@ -10,6 +10,6 @@ const apps = new sdk.Apps(client); const result = await apps.getKey({ appId: '', - keyId: '' + keyId: '', }); ``` diff --git a/docs/examples/apps/get-secret.md b/docs/examples/apps/get-secret.md index 4d6a0ec0..16e7b0e9 100644 --- a/docs/examples/apps/get-secret.md +++ b/docs/examples/apps/get-secret.md @@ -10,6 +10,6 @@ const apps = new sdk.Apps(client); const result = await apps.getSecret({ appId: '', - secretId: '' + secretId: '', }); ``` diff --git a/docs/examples/apps/get.md b/docs/examples/apps/get.md index 660c4f42..adb76398 100644 --- a/docs/examples/apps/get.md +++ b/docs/examples/apps/get.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const apps = new sdk.Apps(client); const result = await apps.get({ - appId: '' + appId: '', }); ``` diff --git a/docs/examples/apps/list-installations.md b/docs/examples/apps/list-installations.md index 4bb71973..885c5b51 100644 --- a/docs/examples/apps/list-installations.md +++ b/docs/examples/apps/list-installations.md @@ -11,6 +11,6 @@ const apps = new sdk.Apps(client); const result = await apps.listInstallations({ appId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/apps/list-keys.md b/docs/examples/apps/list-keys.md index 3a2198fd..ce9b27d7 100644 --- a/docs/examples/apps/list-keys.md +++ b/docs/examples/apps/list-keys.md @@ -11,6 +11,6 @@ const apps = new sdk.Apps(client); const result = await apps.listKeys({ appId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/apps/list-secrets.md b/docs/examples/apps/list-secrets.md index d1155a5d..47847537 100644 --- a/docs/examples/apps/list-secrets.md +++ b/docs/examples/apps/list-secrets.md @@ -11,6 +11,6 @@ const apps = new sdk.Apps(client); const result = await apps.listSecrets({ appId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/apps/list.md b/docs/examples/apps/list.md index d5942933..ed2c0b14 100644 --- a/docs/examples/apps/list.md +++ b/docs/examples/apps/list.md @@ -10,6 +10,6 @@ const apps = new sdk.Apps(client); const result = await apps.list({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/apps/update-labels.md b/docs/examples/apps/update-labels.md index 67a98fc7..d0e3cf3e 100644 --- a/docs/examples/apps/update-labels.md +++ b/docs/examples/apps/update-labels.md @@ -10,6 +10,6 @@ const apps = new sdk.Apps(client); const result = await apps.updateLabels({ appId: '', - labels: [] + labels: [], }); ``` diff --git a/docs/examples/apps/update-team.md b/docs/examples/apps/update-team.md index 65828dce..856e06be 100644 --- a/docs/examples/apps/update-team.md +++ b/docs/examples/apps/update-team.md @@ -10,6 +10,6 @@ const apps = new sdk.Apps(client); const result = await apps.updateTeam({ appId: '', - teamId: '' + teamId: '', }); ``` diff --git a/docs/examples/apps/update.md b/docs/examples/apps/update.md index 2ac2e585..ac8b86af 100644 --- a/docs/examples/apps/update.md +++ b/docs/examples/apps/update.md @@ -28,6 +28,6 @@ const result = await apps.update({ type: 'public', // optional deviceFlow: false, // optional installationScopes: [], // optional - installationRedirectUrl: 'https://example.com' // optional + installationRedirectUrl: 'https://example.com', // optional }); ``` diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index 6ffb388d..be84bc59 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -12,6 +12,6 @@ const result = await avatars.getBrowser({ code: sdk.Browser.AvantBrowser, width: 0, // optional height: 0, // optional - quality: -1 // optional + quality: -1, // optional }); ``` diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index ea806baf..86c27067 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -12,6 +12,6 @@ const result = await avatars.getCreditCard({ code: sdk.CreditCard.AmericanExpress, width: 0, // optional height: 0, // optional - quality: -1 // optional + quality: -1, // optional }); ``` diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md index bd9ae2ca..d9ba4092 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const avatars = new sdk.Avatars(client); const result = await avatars.getFavicon({ - url: 'https://example.com' + url: 'https://example.com', }); ``` diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index d05b666b..bbf954bc 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -12,6 +12,6 @@ const result = await avatars.getFlag({ code: sdk.Flag.Afghanistan, width: 0, // optional height: 0, // optional - quality: -1 // optional + quality: -1, // optional }); ``` diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md index 6f013db1..89b6c733 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -11,6 +11,6 @@ const avatars = new sdk.Avatars(client); const result = await avatars.getImage({ url: 'https://example.com', width: 0, // optional - height: 0 // optional + height: 0, // optional }); ``` diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md index 3d35c6df..ee565067 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -12,6 +12,6 @@ const result = await avatars.getInitials({ name: '', // optional width: 0, // optional height: 0, // optional - background: '' // optional + background: 'FFFFFF', // optional }); ``` diff --git a/docs/examples/avatars/get-photo.md b/docs/examples/avatars/get-photo.md new file mode 100644 index 00000000..8421fbb9 --- /dev/null +++ b/docs/examples/avatars/get-photo.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 + .setSession(''); // The user session to authenticate with + +const avatars = new sdk.Avatars(client); + +const result = await avatars.getPhoto({ + width: 0, // optional + height: 0, // optional + quality: 0, // optional + output: 'png', // optional + rating: 'g', // optional + userId: 'current()', // optional + emailHash: '', // optional + name: '', // optional +}); +``` diff --git a/docs/examples/avatars/get-qr.md b/docs/examples/avatars/get-qr.md index e4235a38..791202ed 100644 --- a/docs/examples/avatars/get-qr.md +++ b/docs/examples/avatars/get-qr.md @@ -12,6 +12,6 @@ const result = await avatars.getQR({ text: '', size: 1, // optional margin: 0, // optional - download: false // optional + download: false, // optional }); ``` diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index d83f24ab..708db1ca 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -11,14 +11,15 @@ const avatars = new sdk.Avatars(client); const result = await avatars.getScreenshot({ url: 'https://example.com', headers: { - "Authorization": "Bearer token123", - "X-Custom-Header": "value" + Authorization: 'Bearer token123', + 'X-Custom-Header': 'value', }, // optional viewportWidth: 1920, // optional viewportHeight: 1080, // optional scale: 2, // optional theme: sdk.BrowserTheme.Dark, // optional - userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15', // optional + userAgent: + 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15', // optional fullpage: true, // optional locale: 'en-US', // optional timezone: sdk.Timezone.AfricaAbidjan, // optional @@ -26,11 +27,14 @@ const result = await avatars.getScreenshot({ longitude: -122.4194, // optional accuracy: 100, // optional touch: true, // optional - permissions: [sdk.BrowserPermission.Geolocation, sdk.BrowserPermission.Notifications], // optional + permissions: [ + sdk.BrowserPermission.Geolocation, + sdk.BrowserPermission.Notifications, + ], // optional sleep: 3, // optional width: 800, // optional height: 600, // optional quality: 85, // optional - output: sdk.ImageFormat.Jpeg // optional + output: sdk.ImageFormat.Jpeg, // optional }); ``` diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md index 1a11d459..9a8d2a5f 100644 --- a/docs/examples/backups/create-archive.md +++ b/docs/examples/backups/create-archive.md @@ -10,6 +10,6 @@ const backups = new sdk.Backups(client); const result = await backups.createArchive({ services: [sdk.BackupServices.Databases], - resourceId: '' // optional + resourceId: '', // optional }); ``` diff --git a/docs/examples/backups/create-policy.md b/docs/examples/backups/create-policy.md index 71670929..46774bf2 100644 --- a/docs/examples/backups/create-policy.md +++ b/docs/examples/backups/create-policy.md @@ -15,6 +15,6 @@ const result = await backups.createPolicy({ schedule: '', name: '', // optional resourceId: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md index f41a2344..40a4447d 100644 --- a/docs/examples/backups/create-restoration.md +++ b/docs/examples/backups/create-restoration.md @@ -12,6 +12,6 @@ const result = await backups.createRestoration({ archiveId: '', services: [sdk.BackupServices.Databases], newResourceId: '', // optional - newResourceName: '' // optional + newResourceName: '', // optional }); ``` diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md index f0c5615d..babedbce 100644 --- a/docs/examples/backups/delete-archive.md +++ b/docs/examples/backups/delete-archive.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const backups = new sdk.Backups(client); const result = await backups.deleteArchive({ - archiveId: '' + archiveId: '', }); ``` diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md index 493e89ef..69dd413a 100644 --- a/docs/examples/backups/delete-policy.md +++ b/docs/examples/backups/delete-policy.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const backups = new sdk.Backups(client); const result = await backups.deletePolicy({ - policyId: '' + policyId: '', }); ``` diff --git a/docs/examples/backups/get-archive.md b/docs/examples/backups/get-archive.md index ade4e222..0e8c1444 100644 --- a/docs/examples/backups/get-archive.md +++ b/docs/examples/backups/get-archive.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const backups = new sdk.Backups(client); const result = await backups.getArchive({ - archiveId: '' + archiveId: '', }); ``` diff --git a/docs/examples/backups/get-policy.md b/docs/examples/backups/get-policy.md index 391c0196..838e8d5b 100644 --- a/docs/examples/backups/get-policy.md +++ b/docs/examples/backups/get-policy.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const backups = new sdk.Backups(client); const result = await backups.getPolicy({ - policyId: '' + policyId: '', }); ``` diff --git a/docs/examples/backups/get-restoration.md b/docs/examples/backups/get-restoration.md index 46d18f3a..37e1c6b7 100644 --- a/docs/examples/backups/get-restoration.md +++ b/docs/examples/backups/get-restoration.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const backups = new sdk.Backups(client); const result = await backups.getRestoration({ - restorationId: '' + restorationId: '', }); ``` diff --git a/docs/examples/backups/list-archives.md b/docs/examples/backups/list-archives.md index d6f51c56..4e4ff600 100644 --- a/docs/examples/backups/list-archives.md +++ b/docs/examples/backups/list-archives.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const backups = new sdk.Backups(client); const result = await backups.listArchives({ - queries: [] // optional + queries: [], // optional }); ``` diff --git a/docs/examples/backups/list-policies.md b/docs/examples/backups/list-policies.md index 7f87b1d6..322024b4 100644 --- a/docs/examples/backups/list-policies.md +++ b/docs/examples/backups/list-policies.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const backups = new sdk.Backups(client); const result = await backups.listPolicies({ - queries: [] // optional + queries: [], // optional }); ``` diff --git a/docs/examples/backups/list-restorations.md b/docs/examples/backups/list-restorations.md index 4475a17d..5ea7e0a0 100644 --- a/docs/examples/backups/list-restorations.md +++ b/docs/examples/backups/list-restorations.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const backups = new sdk.Backups(client); const result = await backups.listRestorations({ - queries: [] // optional + queries: [], // optional }); ``` diff --git a/docs/examples/backups/update-policy.md b/docs/examples/backups/update-policy.md index 5912b39f..69af997c 100644 --- a/docs/examples/backups/update-policy.md +++ b/docs/examples/backups/update-policy.md @@ -13,6 +13,6 @@ const result = await backups.updatePolicy({ name: '', // optional retention: 1, // optional schedule: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/databases/create-big-int-attribute.md b/docs/examples/databases/create-big-int-attribute.md index 3d40ce75..f52034eb 100644 --- a/docs/examples/databases/create-big-int-attribute.md +++ b/docs/examples/databases/create-big-int-attribute.md @@ -11,11 +11,11 @@ const databases = new sdk.Databases(client); const result = await databases.createBigIntAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - min: null, // optional - max: null, // optional - xdefault: null, // optional - array: false // optional + min: 0, // optional + max: 1000000, // optional + xdefault: 0, // optional + array: false, // optional }); ``` diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md index 606ca49c..88aac351 100644 --- a/docs/examples/databases/create-boolean-attribute.md +++ b/docs/examples/databases/create-boolean-attribute.md @@ -11,9 +11,9 @@ const databases = new sdk.Databases(client); const result = await databases.createBooleanAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: false, // optional - array: false // optional + array: false, // optional }); ``` diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md index b58e0919..8eda4155 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -16,6 +16,6 @@ const result = await databases.createCollection({ documentSecurity: false, // optional enabled: false, // optional attributes: [], // optional - indexes: [] // optional + indexes: [], // optional }); ``` diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md index 361ee95e..0a90cbc7 100644 --- a/docs/examples/databases/create-datetime-attribute.md +++ b/docs/examples/databases/create-datetime-attribute.md @@ -11,9 +11,9 @@ const databases = new sdk.Databases(client); const result = await databases.createDatetimeAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: '2020-10-15T06:38:00.000+00:00', // optional - array: false // optional + array: false, // optional }); ``` diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 3c38b69e..f9147dfa 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -13,13 +13,13 @@ const result = await databases.createDocument({ collectionId: '', documentId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 30, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 30, + isAdmin: false, }, permissions: [sdk.Permission.read(sdk.Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 60f4eab8..29f12043 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -12,6 +12,6 @@ const result = await databases.createDocuments({ databaseId: '', collectionId: '', documents: [], - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md index 13382c3d..0f2f7ac7 100644 --- a/docs/examples/databases/create-email-attribute.md +++ b/docs/examples/databases/create-email-attribute.md @@ -11,9 +11,9 @@ const databases = new sdk.Databases(client); const result = await databases.createEmailAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: 'email@example.com', // optional - array: false // optional + array: false, // optional }); ``` diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md index fe7abce4..fddf585d 100644 --- a/docs/examples/databases/create-enum-attribute.md +++ b/docs/examples/databases/create-enum-attribute.md @@ -11,10 +11,10 @@ const databases = new sdk.Databases(client); const result = await databases.createEnumAttribute({ databaseId: '', collectionId: '', - key: '', - elements: [], + key: '', + elements: ['active', 'inactive'], required: false, - xdefault: '', // optional - array: false // optional + xdefault: 'active', // optional + array: false, // optional }); ``` diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md index f179528f..ebf6ef51 100644 --- a/docs/examples/databases/create-float-attribute.md +++ b/docs/examples/databases/create-float-attribute.md @@ -11,11 +11,11 @@ const databases = new sdk.Databases(client); const result = await databases.createFloatAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - min: null, // optional - max: null, // optional - xdefault: null, // optional - array: false // optional + min: 0, // optional + max: 100, // optional + xdefault: 10.5, // optional + array: false, // optional }); ``` diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index ba3bf3a6..095bd46a 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -11,10 +11,10 @@ const databases = new sdk.Databases(client); const result = await databases.createIndex({ databaseId: '', collectionId: '', - key: '', + key: '', type: sdk.DatabasesIndexType.Key, attributes: [], orders: [sdk.OrderBy.Asc], // optional - lengths: [] // optional + lengths: [], // optional }); ``` diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md index d0dbed90..b9f56547 100644 --- a/docs/examples/databases/create-integer-attribute.md +++ b/docs/examples/databases/create-integer-attribute.md @@ -11,11 +11,11 @@ const databases = new sdk.Databases(client); const result = await databases.createIntegerAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - min: null, // optional - max: null, // optional - xdefault: null, // optional - array: false // optional + min: 0, // optional + max: 100, // optional + xdefault: 10, // optional + array: false, // optional }); ``` diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md index c21ad541..edcee675 100644 --- a/docs/examples/databases/create-ip-attribute.md +++ b/docs/examples/databases/create-ip-attribute.md @@ -11,9 +11,9 @@ const databases = new sdk.Databases(client); const result = await databases.createIpAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', // optional - array: false // optional + xdefault: '192.0.2.0', // optional + array: false, // optional }); ``` diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md index 8d615095..01ae03ee 100644 --- a/docs/examples/databases/create-line-attribute.md +++ b/docs/examples/databases/create-line-attribute.md @@ -11,8 +11,12 @@ const databases = new sdk.Databases(client); const result = await databases.createLineAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: [[1, 2], [3, 4], [5, 6]] // optional + xdefault: [ + [1, 2], + [3, 4], + [5, 6], + ], // optional }); ``` diff --git a/docs/examples/databases/create-longtext-attribute.md b/docs/examples/databases/create-longtext-attribute.md index b49077ee..6685fde8 100644 --- a/docs/examples/databases/create-longtext-attribute.md +++ b/docs/examples/databases/create-longtext-attribute.md @@ -11,10 +11,10 @@ const databases = new sdk.Databases(client); const result = await databases.createLongtextAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); ``` diff --git a/docs/examples/databases/create-mediumtext-attribute.md b/docs/examples/databases/create-mediumtext-attribute.md index 44d9199f..ed950b4e 100644 --- a/docs/examples/databases/create-mediumtext-attribute.md +++ b/docs/examples/databases/create-mediumtext-attribute.md @@ -11,10 +11,10 @@ const databases = new sdk.Databases(client); const result = await databases.createMediumtextAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); ``` diff --git a/docs/examples/databases/create-operations.md b/docs/examples/databases/create-operations.md index 06a3c468..42e51898 100644 --- a/docs/examples/databases/create-operations.md +++ b/docs/examples/databases/create-operations.md @@ -11,15 +11,15 @@ const databases = new sdk.Databases(client); const result = await databases.createOperations({ transactionId: '', operations: [ - { - "action": "create", - "databaseId": "", - "collectionId": "", - "documentId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional + { + action: 'create', + databaseId: '', + collectionId: '', + documentId: '', + data: { + name: "Walter O'Brien", + }, + }, + ], // optional }); ``` diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md index 57058752..6825bfeb 100644 --- a/docs/examples/databases/create-point-attribute.md +++ b/docs/examples/databases/create-point-attribute.md @@ -11,8 +11,8 @@ const databases = new sdk.Databases(client); const result = await databases.createPointAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: [1, 2] // optional + xdefault: [1, 2], // optional }); ``` diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md index f3562ab4..c155e136 100644 --- a/docs/examples/databases/create-polygon-attribute.md +++ b/docs/examples/databases/create-polygon-attribute.md @@ -11,8 +11,15 @@ const databases = new sdk.Databases(client); const result = await databases.createPolygonAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: [[[1, 2], [3, 4], [5, 6], [1, 2]]] // optional + xdefault: [ + [ + [1, 2], + [3, 4], + [5, 6], + [1, 2], + ], + ], // optional }); ``` diff --git a/docs/examples/databases/create-relationship-attribute.md b/docs/examples/databases/create-relationship-attribute.md index 30d4dfd7..4d79cf45 100644 --- a/docs/examples/databases/create-relationship-attribute.md +++ b/docs/examples/databases/create-relationship-attribute.md @@ -14,8 +14,8 @@ const result = await databases.createRelationshipAttribute({ relatedCollectionId: '', type: sdk.RelationshipType.OneToOne, twoWay: false, // optional - key: '', // optional - twoWayKey: '', // optional - onDelete: sdk.RelationMutate.Cascade // optional + key: '', // optional + twoWayKey: '', // optional + onDelete: sdk.RelationMutate.Cascade, // optional }); ``` diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md index e0c2cdb4..187afaf2 100644 --- a/docs/examples/databases/create-string-attribute.md +++ b/docs/examples/databases/create-string-attribute.md @@ -11,11 +11,11 @@ const databases = new sdk.Databases(client); const result = await databases.createStringAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', size: 1, required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); ``` diff --git a/docs/examples/databases/create-text-attribute.md b/docs/examples/databases/create-text-attribute.md index 48fd6ded..3dec73cf 100644 --- a/docs/examples/databases/create-text-attribute.md +++ b/docs/examples/databases/create-text-attribute.md @@ -11,10 +11,10 @@ const databases = new sdk.Databases(client); const result = await databases.createTextAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); ``` diff --git a/docs/examples/databases/create-transaction.md b/docs/examples/databases/create-transaction.md index 8785149a..2ef16fca 100644 --- a/docs/examples/databases/create-transaction.md +++ b/docs/examples/databases/create-transaction.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); const result = await databases.createTransaction({ - ttl: 60 // optional + ttl: 60, // optional }); ``` diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md index f0d1a29a..41c5db97 100644 --- a/docs/examples/databases/create-url-attribute.md +++ b/docs/examples/databases/create-url-attribute.md @@ -11,9 +11,9 @@ const databases = new sdk.Databases(client); const result = await databases.createUrlAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: 'https://example.com', // optional - array: false // optional + array: false, // optional }); ``` diff --git a/docs/examples/databases/create-varchar-attribute.md b/docs/examples/databases/create-varchar-attribute.md index 64582747..ce55e847 100644 --- a/docs/examples/databases/create-varchar-attribute.md +++ b/docs/examples/databases/create-varchar-attribute.md @@ -11,11 +11,11 @@ const databases = new sdk.Databases(client); const result = await databases.createVarcharAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', size: 1, required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); ``` diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md index d35731b6..ce42a134 100644 --- a/docs/examples/databases/create.md +++ b/docs/examples/databases/create.md @@ -11,6 +11,6 @@ const databases = new sdk.Databases(client); const result = await databases.create({ databaseId: '', name: '', - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md index 80fe2486..c48bf9b4 100644 --- a/docs/examples/databases/decrement-document-attribute.md +++ b/docs/examples/databases/decrement-document-attribute.md @@ -12,9 +12,9 @@ const result = await databases.decrementDocumentAttribute({ databaseId: '', collectionId: '', documentId: '', - attribute: '', - value: null, // optional - min: null, // optional - transactionId: '' // optional + attribute: '', + value: 1, // optional + min: 0, // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/databases/delete-attribute.md b/docs/examples/databases/delete-attribute.md index 30501051..89ffcd84 100644 --- a/docs/examples/databases/delete-attribute.md +++ b/docs/examples/databases/delete-attribute.md @@ -11,6 +11,6 @@ const databases = new sdk.Databases(client); const result = await databases.deleteAttribute({ databaseId: '', collectionId: '', - key: '' + key: '', }); ``` diff --git a/docs/examples/databases/delete-collection.md b/docs/examples/databases/delete-collection.md index 2da5c205..473e92dd 100644 --- a/docs/examples/databases/delete-collection.md +++ b/docs/examples/databases/delete-collection.md @@ -10,6 +10,6 @@ const databases = new sdk.Databases(client); const result = await databases.deleteCollection({ databaseId: '', - collectionId: '' + collectionId: '', }); ``` diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index 22bc7143..9ecdbbe9 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -12,6 +12,6 @@ const result = await databases.deleteDocument({ databaseId: '', collectionId: '', documentId: '', - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index 4851243e..682c0e7b 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -12,6 +12,6 @@ const result = await databases.deleteDocuments({ databaseId: '', collectionId: '', queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md index b7a8f0c3..861a842d 100644 --- a/docs/examples/databases/delete-index.md +++ b/docs/examples/databases/delete-index.md @@ -11,6 +11,6 @@ const databases = new sdk.Databases(client); const result = await databases.deleteIndex({ databaseId: '', collectionId: '', - key: '' + key: '', }); ``` diff --git a/docs/examples/databases/delete-transaction.md b/docs/examples/databases/delete-transaction.md index b89214ba..8868eb92 100644 --- a/docs/examples/databases/delete-transaction.md +++ b/docs/examples/databases/delete-transaction.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); const result = await databases.deleteTransaction({ - transactionId: '' + transactionId: '', }); ``` diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md index 00009485..101b2246 100644 --- a/docs/examples/databases/delete.md +++ b/docs/examples/databases/delete.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); const result = await databases.delete({ - databaseId: '' + databaseId: '', }); ``` diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md index eade77dd..4cdaa8ae 100644 --- a/docs/examples/databases/get-attribute.md +++ b/docs/examples/databases/get-attribute.md @@ -11,6 +11,6 @@ const databases = new sdk.Databases(client); const result = await databases.getAttribute({ databaseId: '', collectionId: '', - key: '' + key: '', }); ``` diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md index 8b96abaf..ccfc0f09 100644 --- a/docs/examples/databases/get-collection.md +++ b/docs/examples/databases/get-collection.md @@ -10,6 +10,6 @@ const databases = new sdk.Databases(client); const result = await databases.getCollection({ databaseId: '', - collectionId: '' + collectionId: '', }); ``` diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index 9a66df4f..28255247 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -13,6 +13,6 @@ const result = await databases.getDocument({ collectionId: '', documentId: '', queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md index 1900b0f5..71872676 100644 --- a/docs/examples/databases/get-index.md +++ b/docs/examples/databases/get-index.md @@ -11,6 +11,6 @@ const databases = new sdk.Databases(client); const result = await databases.getIndex({ databaseId: '', collectionId: '', - key: '' + key: '', }); ``` diff --git a/docs/examples/databases/get-transaction.md b/docs/examples/databases/get-transaction.md index 09c0255a..0f4bbd45 100644 --- a/docs/examples/databases/get-transaction.md +++ b/docs/examples/databases/get-transaction.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); const result = await databases.getTransaction({ - transactionId: '' + transactionId: '', }); ``` diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md index 9533a738..6b5834e8 100644 --- a/docs/examples/databases/get.md +++ b/docs/examples/databases/get.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); const result = await databases.get({ - databaseId: '' + databaseId: '', }); ``` diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md index cb24d704..3f5d7e70 100644 --- a/docs/examples/databases/increment-document-attribute.md +++ b/docs/examples/databases/increment-document-attribute.md @@ -12,9 +12,9 @@ const result = await databases.incrementDocumentAttribute({ databaseId: '', collectionId: '', documentId: '', - attribute: '', - value: null, // optional - max: null, // optional - transactionId: '' // optional + attribute: '', + value: 1, // optional + max: 100, // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md index 635391cd..5d9af70e 100644 --- a/docs/examples/databases/list-attributes.md +++ b/docs/examples/databases/list-attributes.md @@ -12,6 +12,6 @@ const result = await databases.listAttributes({ databaseId: '', collectionId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md index 38f1f3eb..59585102 100644 --- a/docs/examples/databases/list-collections.md +++ b/docs/examples/databases/list-collections.md @@ -12,6 +12,6 @@ const result = await databases.listCollections({ databaseId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index 11fcec2d..e395ef12 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -14,6 +14,6 @@ const result = await databases.listDocuments({ queries: [], // optional transactionId: '', // optional total: false, // optional - ttl: 0 // optional + ttl: 0, // optional }); ``` diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md index c6411092..0100d77f 100644 --- a/docs/examples/databases/list-indexes.md +++ b/docs/examples/databases/list-indexes.md @@ -12,6 +12,6 @@ const result = await databases.listIndexes({ databaseId: '', collectionId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/databases/list-transactions.md b/docs/examples/databases/list-transactions.md index 4707b131..c3356828 100644 --- a/docs/examples/databases/list-transactions.md +++ b/docs/examples/databases/list-transactions.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); const result = await databases.listTransactions({ - queries: [] // optional + queries: [], // optional }); ``` diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md index d88d05ee..b2a38dfa 100644 --- a/docs/examples/databases/list.md +++ b/docs/examples/databases/list.md @@ -11,6 +11,6 @@ const databases = new sdk.Databases(client); const result = await databases.list({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/databases/update-big-int-attribute.md b/docs/examples/databases/update-big-int-attribute.md index 1ff012a5..7603578d 100644 --- a/docs/examples/databases/update-big-int-attribute.md +++ b/docs/examples/databases/update-big-int-attribute.md @@ -11,11 +11,11 @@ const databases = new sdk.Databases(client); const result = await databases.updateBigIntAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: null, - min: null, // optional - max: null, // optional - newKey: '' // optional + xdefault: 0, + min: 0, // optional + max: 1000000, // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-boolean-attribute.md b/docs/examples/databases/update-boolean-attribute.md index c9b165e9..5184217c 100644 --- a/docs/examples/databases/update-boolean-attribute.md +++ b/docs/examples/databases/update-boolean-attribute.md @@ -11,9 +11,9 @@ const databases = new sdk.Databases(client); const result = await databases.updateBooleanAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: false, - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index f7f65c32..d33ce0b6 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -15,6 +15,6 @@ const result = await databases.updateCollection({ permissions: [sdk.Permission.read(sdk.Role.any())], // optional documentSecurity: false, // optional enabled: false, // optional - purge: false // optional + purge: false, // optional }); ``` diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md index 6c65696b..f3bb80ea 100644 --- a/docs/examples/databases/update-datetime-attribute.md +++ b/docs/examples/databases/update-datetime-attribute.md @@ -11,9 +11,9 @@ const databases = new sdk.Databases(client); const result = await databases.updateDatetimeAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: '2020-10-15T06:38:00.000+00:00', - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index cae4ccfe..70372552 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -13,13 +13,13 @@ const result = await databases.updateDocument({ collectionId: '', documentId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 33, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 33, + isAdmin: false, }, // optional permissions: [sdk.Permission.read(sdk.Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index 168074c1..b32cc887 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -12,13 +12,13 @@ const result = await databases.updateDocuments({ databaseId: '', collectionId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 33, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 33, + isAdmin: false, }, // optional queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/databases/update-email-attribute.md b/docs/examples/databases/update-email-attribute.md index fa6c4319..69658e20 100644 --- a/docs/examples/databases/update-email-attribute.md +++ b/docs/examples/databases/update-email-attribute.md @@ -11,9 +11,9 @@ const databases = new sdk.Databases(client); const result = await databases.updateEmailAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: 'email@example.com', - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md index 0fc74cdf..2463223f 100644 --- a/docs/examples/databases/update-enum-attribute.md +++ b/docs/examples/databases/update-enum-attribute.md @@ -11,10 +11,10 @@ const databases = new sdk.Databases(client); const result = await databases.updateEnumAttribute({ databaseId: '', collectionId: '', - key: '', - elements: [], + key: '', + elements: ['active', 'inactive'], required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'active', + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-float-attribute.md b/docs/examples/databases/update-float-attribute.md index 894ab665..63af3be9 100644 --- a/docs/examples/databases/update-float-attribute.md +++ b/docs/examples/databases/update-float-attribute.md @@ -11,11 +11,11 @@ const databases = new sdk.Databases(client); const result = await databases.updateFloatAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: null, - min: null, // optional - max: null, // optional - newKey: '' // optional + xdefault: 10.5, + min: 0, // optional + max: 100, // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-integer-attribute.md b/docs/examples/databases/update-integer-attribute.md index 10ddb38f..14a16a93 100644 --- a/docs/examples/databases/update-integer-attribute.md +++ b/docs/examples/databases/update-integer-attribute.md @@ -11,11 +11,11 @@ const databases = new sdk.Databases(client); const result = await databases.updateIntegerAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: null, - min: null, // optional - max: null, // optional - newKey: '' // optional + xdefault: 10, + min: 0, // optional + max: 100, // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-ip-attribute.md b/docs/examples/databases/update-ip-attribute.md index 5e53e5d7..1ece6658 100644 --- a/docs/examples/databases/update-ip-attribute.md +++ b/docs/examples/databases/update-ip-attribute.md @@ -11,9 +11,9 @@ const databases = new sdk.Databases(client); const result = await databases.updateIpAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: '192.0.2.0', + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md index c106a035..bd366899 100644 --- a/docs/examples/databases/update-line-attribute.md +++ b/docs/examples/databases/update-line-attribute.md @@ -11,9 +11,13 @@ const databases = new sdk.Databases(client); const result = await databases.updateLineAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: [[1, 2], [3, 4], [5, 6]], // optional - newKey: '' // optional + xdefault: [ + [1, 2], + [3, 4], + [5, 6], + ], // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-longtext-attribute.md b/docs/examples/databases/update-longtext-attribute.md index d21f3988..97d3c28d 100644 --- a/docs/examples/databases/update-longtext-attribute.md +++ b/docs/examples/databases/update-longtext-attribute.md @@ -11,9 +11,9 @@ const databases = new sdk.Databases(client); const result = await databases.updateLongtextAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'Hello World', + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-mediumtext-attribute.md b/docs/examples/databases/update-mediumtext-attribute.md index 25857d5d..5398f710 100644 --- a/docs/examples/databases/update-mediumtext-attribute.md +++ b/docs/examples/databases/update-mediumtext-attribute.md @@ -11,9 +11,9 @@ const databases = new sdk.Databases(client); const result = await databases.updateMediumtextAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'Hello World', + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md index 96a4ae85..1c64a2c8 100644 --- a/docs/examples/databases/update-point-attribute.md +++ b/docs/examples/databases/update-point-attribute.md @@ -11,9 +11,9 @@ const databases = new sdk.Databases(client); const result = await databases.updatePointAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: [1, 2], // optional - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md index 72828a8a..9cff5778 100644 --- a/docs/examples/databases/update-polygon-attribute.md +++ b/docs/examples/databases/update-polygon-attribute.md @@ -11,9 +11,16 @@ const databases = new sdk.Databases(client); const result = await databases.updatePolygonAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: [[[1, 2], [3, 4], [5, 6], [1, 2]]], // optional - newKey: '' // optional + xdefault: [ + [ + [1, 2], + [3, 4], + [5, 6], + [1, 2], + ], + ], // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-relationship-attribute.md b/docs/examples/databases/update-relationship-attribute.md index 9dc8ebd7..50710f8e 100644 --- a/docs/examples/databases/update-relationship-attribute.md +++ b/docs/examples/databases/update-relationship-attribute.md @@ -11,8 +11,8 @@ const databases = new sdk.Databases(client); const result = await databases.updateRelationshipAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', onDelete: sdk.RelationMutate.Cascade, // optional - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md index 1c509d28..75f269c4 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -11,10 +11,10 @@ const databases = new sdk.Databases(client); const result = await databases.updateStringAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', + xdefault: 'Hello World', size: 1, // optional - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-text-attribute.md b/docs/examples/databases/update-text-attribute.md index 3154f5a9..0075135e 100644 --- a/docs/examples/databases/update-text-attribute.md +++ b/docs/examples/databases/update-text-attribute.md @@ -11,9 +11,9 @@ const databases = new sdk.Databases(client); const result = await databases.updateTextAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'Hello World', + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-transaction.md b/docs/examples/databases/update-transaction.md index a83cb03b..6d31e2e5 100644 --- a/docs/examples/databases/update-transaction.md +++ b/docs/examples/databases/update-transaction.md @@ -11,6 +11,6 @@ const databases = new sdk.Databases(client); const result = await databases.updateTransaction({ transactionId: '', commit: false, // optional - rollback: false // optional + rollback: false, // optional }); ``` diff --git a/docs/examples/databases/update-url-attribute.md b/docs/examples/databases/update-url-attribute.md index 1cebc2f4..96c69534 100644 --- a/docs/examples/databases/update-url-attribute.md +++ b/docs/examples/databases/update-url-attribute.md @@ -11,9 +11,9 @@ const databases = new sdk.Databases(client); const result = await databases.updateUrlAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, xdefault: 'https://example.com', - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update-varchar-attribute.md b/docs/examples/databases/update-varchar-attribute.md index 43a1cf03..1a2ad8c1 100644 --- a/docs/examples/databases/update-varchar-attribute.md +++ b/docs/examples/databases/update-varchar-attribute.md @@ -11,10 +11,10 @@ const databases = new sdk.Databases(client); const result = await databases.updateVarcharAttribute({ databaseId: '', collectionId: '', - key: '', + key: '', required: false, - xdefault: '', + xdefault: 'Hello World', size: 1, // optional - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md index 36ff3bd1..6ae2bc11 100644 --- a/docs/examples/databases/update.md +++ b/docs/examples/databases/update.md @@ -11,6 +11,6 @@ const databases = new sdk.Databases(client); const result = await databases.update({ databaseId: '', name: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 13e882ad..580baf23 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -13,13 +13,13 @@ const result = await databases.upsertDocument({ collectionId: '', documentId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 30, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 30, + isAdmin: false, }, // optional permissions: [sdk.Permission.read(sdk.Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 2a304924..aa253547 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -12,6 +12,6 @@ const result = await databases.upsertDocuments({ databaseId: '', collectionId: '', documents: [], - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/documentsdb/create-collection.md b/docs/examples/documentsdb/create-collection.md new file mode 100644 index 00000000..5915ae97 --- /dev/null +++ b/docs/examples/documentsdb/create-collection.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.createCollection({ + databaseId: '', + collectionId: '', + name: '', + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + documentSecurity: false, // optional + enabled: false, // optional + attributes: [], // optional + indexes: [], // optional +}); +``` diff --git a/docs/examples/documentsdb/create-document.md b/docs/examples/documentsdb/create-document.md new file mode 100644 index 00000000..9b3e1d19 --- /dev/null +++ b/docs/examples/documentsdb/create-document.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 + .setSession(''); // The user session to authenticate with + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.createDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: { + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 30, + isAdmin: false, + }, + permissions: [sdk.Permission.read(sdk.Role.any())], // optional +}); +``` diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md new file mode 100644 index 00000000..35884cc5 --- /dev/null +++ b/docs/examples/documentsdb/create-documents.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.createDocuments({ + databaseId: '', + collectionId: '', + documents: [], +}); +``` diff --git a/docs/examples/documentsdb/create-failover.md b/docs/examples/documentsdb/create-failover.md new file mode 100644 index 00000000..a652719a --- /dev/null +++ b/docs/examples/documentsdb/create-failover.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.createFailover({ + databaseId: '', + targetReplicaId: '', // optional +}); +``` diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md new file mode 100644 index 00000000..72e4669c --- /dev/null +++ b/docs/examples/documentsdb/create-index.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.createIndex({ + databaseId: '', + collectionId: '', + key: '', + type: sdk.DocumentsDBIndexType.Key, + attributes: [], + orders: [sdk.OrderBy.Asc], // optional + lengths: [], // optional +}); +``` diff --git a/docs/examples/documentsdb/create-operations.md b/docs/examples/documentsdb/create-operations.md new file mode 100644 index 00000000..c874aa33 --- /dev/null +++ b/docs/examples/documentsdb/create-operations.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.createOperations({ + transactionId: '', + operations: [ + { + action: 'create', + databaseId: '', + collectionId: '', + documentId: '', + data: { + name: "Walter O'Brien", + }, + }, + ], // optional +}); +``` diff --git a/docs/examples/documentsdb/create-transaction.md b/docs/examples/documentsdb/create-transaction.md new file mode 100644 index 00000000..241425f2 --- /dev/null +++ b/docs/examples/documentsdb/create-transaction.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.createTransaction({ + ttl: 60, // optional +}); +``` diff --git a/docs/examples/documentsdb/create.md b/docs/examples/documentsdb/create.md new file mode 100644 index 00000000..cb0806b3 --- /dev/null +++ b/docs/examples/documentsdb/create.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.create({ + databaseId: '', + name: '', + enabled: false, // optional + specification: 'serverless', // optional + replicas: 0, // optional + syncMode: 'async', // optional +}); +``` diff --git a/docs/examples/documentsdb/decrement-document-attribute.md b/docs/examples/documentsdb/decrement-document-attribute.md new file mode 100644 index 00000000..27f8bdf2 --- /dev/null +++ b/docs/examples/documentsdb/decrement-document-attribute.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 + .setSession(''); // The user session to authenticate with + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.decrementDocumentAttribute({ + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + value: 1, // optional + min: 0, // optional + transactionId: '', // optional +}); +``` diff --git a/docs/examples/documentsdb/delete-collection.md b/docs/examples/documentsdb/delete-collection.md new file mode 100644 index 00000000..5ff38ef7 --- /dev/null +++ b/docs/examples/documentsdb/delete-collection.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.deleteCollection({ + databaseId: '', + collectionId: '', +}); +``` diff --git a/docs/examples/documentsdb/delete-document.md b/docs/examples/documentsdb/delete-document.md new file mode 100644 index 00000000..9fac5c0d --- /dev/null +++ b/docs/examples/documentsdb/delete-document.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 + .setSession(''); // The user session to authenticate with + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.deleteDocument({ + databaseId: '', + collectionId: '', + documentId: '', + transactionId: '', // optional +}); +``` diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md new file mode 100644 index 00000000..9bb214ee --- /dev/null +++ b/docs/examples/documentsdb/delete-documents.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.deleteDocuments({ + databaseId: '', + collectionId: '', + queries: [], // optional + transactionId: '', // optional +}); +``` diff --git a/docs/examples/documentsdb/delete-index.md b/docs/examples/documentsdb/delete-index.md new file mode 100644 index 00000000..f4c04354 --- /dev/null +++ b/docs/examples/documentsdb/delete-index.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.deleteIndex({ + databaseId: '', + collectionId: '', + key: '', +}); +``` diff --git a/docs/examples/documentsdb/delete-transaction.md b/docs/examples/documentsdb/delete-transaction.md new file mode 100644 index 00000000..f8144ced --- /dev/null +++ b/docs/examples/documentsdb/delete-transaction.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.deleteTransaction({ + transactionId: '', +}); +``` diff --git a/docs/examples/documentsdb/delete.md b/docs/examples/documentsdb/delete.md new file mode 100644 index 00000000..46b532de --- /dev/null +++ b/docs/examples/documentsdb/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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.delete({ + databaseId: '', +}); +``` diff --git a/docs/examples/documentsdb/get-collection.md b/docs/examples/documentsdb/get-collection.md new file mode 100644 index 00000000..dc68d3e5 --- /dev/null +++ b/docs/examples/documentsdb/get-collection.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.getCollection({ + databaseId: '', + collectionId: '', +}); +``` diff --git a/docs/examples/documentsdb/get-document.md b/docs/examples/documentsdb/get-document.md new file mode 100644 index 00000000..9755fda2 --- /dev/null +++ b/docs/examples/documentsdb/get-document.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 + .setSession(''); // The user session to authenticate with + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.getDocument({ + databaseId: '', + collectionId: '', + documentId: '', + queries: [], // optional + transactionId: '', // optional +}); +``` diff --git a/docs/examples/documentsdb/get-index.md b/docs/examples/documentsdb/get-index.md new file mode 100644 index 00000000..9faf529d --- /dev/null +++ b/docs/examples/documentsdb/get-index.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.getIndex({ + databaseId: '', + collectionId: '', + key: '', +}); +``` diff --git a/docs/examples/documentsdb/get-replicas.md b/docs/examples/documentsdb/get-replicas.md new file mode 100644 index 00000000..eeda5ea1 --- /dev/null +++ b/docs/examples/documentsdb/get-replicas.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.getReplicas({ + databaseId: '', +}); +``` diff --git a/docs/examples/documentsdb/get-status.md b/docs/examples/documentsdb/get-status.md new file mode 100644 index 00000000..a40a487f --- /dev/null +++ b/docs/examples/documentsdb/get-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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.getStatus({ + databaseId: '', +}); +``` diff --git a/docs/examples/documentsdb/get-transaction.md b/docs/examples/documentsdb/get-transaction.md new file mode 100644 index 00000000..132bef36 --- /dev/null +++ b/docs/examples/documentsdb/get-transaction.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.getTransaction({ + transactionId: '', +}); +``` diff --git a/docs/examples/documentsdb/get.md b/docs/examples/documentsdb/get.md new file mode 100644 index 00000000..092bad49 --- /dev/null +++ b/docs/examples/documentsdb/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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.get({ + databaseId: '', +}); +``` diff --git a/docs/examples/documentsdb/increment-document-attribute.md b/docs/examples/documentsdb/increment-document-attribute.md new file mode 100644 index 00000000..11015d8e --- /dev/null +++ b/docs/examples/documentsdb/increment-document-attribute.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 + .setSession(''); // The user session to authenticate with + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.incrementDocumentAttribute({ + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + value: 1, // optional + max: 100, // optional + transactionId: '', // optional +}); +``` diff --git a/docs/examples/documentsdb/list-collections.md b/docs/examples/documentsdb/list-collections.md new file mode 100644 index 00000000..8d4bb1d2 --- /dev/null +++ b/docs/examples/documentsdb/list-collections.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.listCollections({ + databaseId: '', + queries: [], // optional + search: '', // optional + total: false, // optional +}); +``` diff --git a/docs/examples/documentsdb/list-documents.md b/docs/examples/documentsdb/list-documents.md new file mode 100644 index 00000000..dde50aa3 --- /dev/null +++ b/docs/examples/documentsdb/list-documents.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.listDocuments({ + databaseId: '', + collectionId: '', + queries: [], // optional + transactionId: '', // optional + total: false, // optional + ttl: 0, // optional +}); +``` diff --git a/docs/examples/documentsdb/list-indexes.md b/docs/examples/documentsdb/list-indexes.md new file mode 100644 index 00000000..32b0acaa --- /dev/null +++ b/docs/examples/documentsdb/list-indexes.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.listIndexes({ + databaseId: '', + collectionId: '', + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/documentsdb/list-operations.md b/docs/examples/documentsdb/list-operations.md new file mode 100644 index 00000000..a9c67208 --- /dev/null +++ b/docs/examples/documentsdb/list-operations.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.listOperations({ + databaseId: '', + status: 'queued', // optional + limit: 1, // optional + offset: 0, // optional +}); +``` diff --git a/docs/examples/documentsdb/list-specifications.md b/docs/examples/documentsdb/list-specifications.md new file mode 100644 index 00000000..3d6419d8 --- /dev/null +++ b/docs/examples/documentsdb/list-specifications.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 + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.listSpecifications(); +``` diff --git a/docs/examples/documentsdb/list-transactions.md b/docs/examples/documentsdb/list-transactions.md new file mode 100644 index 00000000..8bc66d4b --- /dev/null +++ b/docs/examples/documentsdb/list-transactions.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.listTransactions({ + queries: [], // optional +}); +``` diff --git a/docs/examples/documentsdb/list.md b/docs/examples/documentsdb/list.md new file mode 100644 index 00000000..9ff1cfe0 --- /dev/null +++ b/docs/examples/documentsdb/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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.list({ + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/documentsdb/update-collection.md b/docs/examples/documentsdb/update-collection.md new file mode 100644 index 00000000..beb1cd3d --- /dev/null +++ b/docs/examples/documentsdb/update-collection.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.updateCollection({ + databaseId: '', + collectionId: '', + name: '', + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + documentSecurity: false, // optional + enabled: false, // optional + purge: false, // optional +}); +``` diff --git a/docs/examples/documentsdb/update-document.md b/docs/examples/documentsdb/update-document.md new file mode 100644 index 00000000..7e9538bc --- /dev/null +++ b/docs/examples/documentsdb/update-document.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.updateDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: {}, // optional + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + transactionId: '', // optional +}); +``` diff --git a/docs/examples/documentsdb/update-documents.md b/docs/examples/documentsdb/update-documents.md new file mode 100644 index 00000000..bb5a46e6 --- /dev/null +++ b/docs/examples/documentsdb/update-documents.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.updateDocuments({ + databaseId: '', + collectionId: '', + data: {}, // optional + queries: [], // optional + transactionId: '', // optional +}); +``` diff --git a/docs/examples/documentsdb/update-transaction.md b/docs/examples/documentsdb/update-transaction.md new file mode 100644 index 00000000..5a149173 --- /dev/null +++ b/docs/examples/documentsdb/update-transaction.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.updateTransaction({ + transactionId: '', + commit: false, // optional + rollback: false, // optional +}); +``` diff --git a/docs/examples/documentsdb/update.md b/docs/examples/documentsdb/update.md new file mode 100644 index 00000000..1e3c22ab --- /dev/null +++ b/docs/examples/documentsdb/update.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.update({ + databaseId: '', + name: '', + enabled: false, // optional + specification: 'serverless', // optional + replicas: 0, // optional + syncMode: 'async', // optional +}); +``` diff --git a/docs/examples/documentsdb/upsert-document.md b/docs/examples/documentsdb/upsert-document.md new file mode 100644 index 00000000..e9ffed17 --- /dev/null +++ b/docs/examples/documentsdb/upsert-document.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.upsertDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: {}, // optional + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + transactionId: '', // optional +}); +``` diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md new file mode 100644 index 00000000..23b52200 --- /dev/null +++ b/docs/examples/documentsdb/upsert-documents.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 documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.upsertDocuments({ + databaseId: '', + collectionId: '', + documents: [], + transactionId: '', // optional +}); +``` diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index 5beebf51..537a4402 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -10,6 +10,6 @@ const embeddings = new sdk.Embeddings(client); const result = await embeddings.createTextEmbeddings({ texts: [], - model: sdk.EmbeddingModel.NomicEmbedText // optional + model: sdk.EmbeddingModel.NomicEmbedText, // optional }); ``` diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index 0cd67cbf..0a4baff1 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -14,6 +14,6 @@ const result = await functions.createDeployment({ code: InputFile.fromPath('/path/to/file', 'filename'), activate: false, entrypoint: '', // optional - commands: '' // optional + commands: '', // optional }); ``` diff --git a/docs/examples/functions/create-duplicate-deployment.md b/docs/examples/functions/create-duplicate-deployment.md index f5abb222..179bb379 100644 --- a/docs/examples/functions/create-duplicate-deployment.md +++ b/docs/examples/functions/create-duplicate-deployment.md @@ -11,6 +11,6 @@ const functions = new sdk.Functions(client); const result = await functions.createDuplicateDeployment({ functionId: '', deploymentId: '', - buildId: '' // optional + buildId: '', // optional }); ``` diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index f93d87e4..f5c5bc42 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -15,6 +15,6 @@ const result = await functions.createExecution({ xpath: '', // optional method: sdk.ExecutionMethod.GET, // optional headers: {}, // optional - scheduledAt: '' // optional + scheduledAt: '', // optional }); ``` diff --git a/docs/examples/functions/create-template-deployment.md b/docs/examples/functions/create-template-deployment.md index 20977559..a3e819f3 100644 --- a/docs/examples/functions/create-template-deployment.md +++ b/docs/examples/functions/create-template-deployment.md @@ -15,6 +15,6 @@ const result = await functions.createTemplateDeployment({ rootDirectory: '', type: sdk.TemplateReferenceType.Commit, reference: '', - activate: false // optional + activate: false, // optional }); ``` diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md index 21246bbe..e6ffd3d0 100644 --- a/docs/examples/functions/create-variable.md +++ b/docs/examples/functions/create-variable.md @@ -13,6 +13,6 @@ const result = await functions.createVariable({ variableId: '', key: '', value: '', - secret: false // optional + secret: false, // optional }); ``` diff --git a/docs/examples/functions/create-vcs-deployment.md b/docs/examples/functions/create-vcs-deployment.md index 4bf9d23b..36672fa4 100644 --- a/docs/examples/functions/create-vcs-deployment.md +++ b/docs/examples/functions/create-vcs-deployment.md @@ -12,6 +12,6 @@ const result = await functions.createVcsDeployment({ functionId: '', type: sdk.VCSReferenceType.Branch, reference: '', - activate: false // optional + activate: false, // optional }); ``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index cb9c3e8c..7d6e855b 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -12,9 +12,9 @@ const result = await functions.create({ functionId: '', name: '', runtime: sdk.Runtime.Node145, - execute: ["any"], // optional + execute: ['any'], // optional events: [], // optional - schedule: '', // optional + schedule: '0 0 * * *', // optional timeout: 1, // optional enabled: false, // optional logging: false, // optional @@ -28,8 +28,8 @@ const result = await functions.create({ providerRootDirectory: '', // optional providerBranches: [], // optional providerPaths: [], // optional - buildSpecification: '', // optional - runtimeSpecification: '', // optional - deploymentRetention: 0 // optional + buildSpecification: 's-1vcpu-512mb', // optional + runtimeSpecification: 's-1vcpu-512mb', // optional + deploymentRetention: 0, // optional }); ``` diff --git a/docs/examples/functions/delete-deployment.md b/docs/examples/functions/delete-deployment.md index 20120ebd..101508c9 100644 --- a/docs/examples/functions/delete-deployment.md +++ b/docs/examples/functions/delete-deployment.md @@ -10,6 +10,6 @@ const functions = new sdk.Functions(client); const result = await functions.deleteDeployment({ functionId: '', - deploymentId: '' + deploymentId: '', }); ``` diff --git a/docs/examples/functions/delete-execution.md b/docs/examples/functions/delete-execution.md index 4d78ad9c..bbbc6062 100644 --- a/docs/examples/functions/delete-execution.md +++ b/docs/examples/functions/delete-execution.md @@ -10,6 +10,6 @@ const functions = new sdk.Functions(client); const result = await functions.deleteExecution({ functionId: '', - executionId: '' + executionId: '', }); ``` diff --git a/docs/examples/functions/delete-variable.md b/docs/examples/functions/delete-variable.md index b8ed9d54..1882393a 100644 --- a/docs/examples/functions/delete-variable.md +++ b/docs/examples/functions/delete-variable.md @@ -10,6 +10,6 @@ const functions = new sdk.Functions(client); const result = await functions.deleteVariable({ functionId: '', - variableId: '' + variableId: '', }); ``` diff --git a/docs/examples/functions/delete.md b/docs/examples/functions/delete.md index 446ca2a5..b2259a16 100644 --- a/docs/examples/functions/delete.md +++ b/docs/examples/functions/delete.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); const result = await functions.delete({ - functionId: '' + functionId: '', }); ``` diff --git a/docs/examples/functions/get-deployment-download.md b/docs/examples/functions/get-deployment-download.md index 6a75badd..e85081a0 100644 --- a/docs/examples/functions/get-deployment-download.md +++ b/docs/examples/functions/get-deployment-download.md @@ -12,6 +12,6 @@ const result = await functions.getDeploymentDownload({ functionId: '', deploymentId: '', type: sdk.DeploymentDownloadType.Source, // optional - token: '' // optional + token: '', // optional }); ``` diff --git a/docs/examples/functions/get-deployment.md b/docs/examples/functions/get-deployment.md index 29d9b2e6..c6b1b882 100644 --- a/docs/examples/functions/get-deployment.md +++ b/docs/examples/functions/get-deployment.md @@ -10,6 +10,6 @@ const functions = new sdk.Functions(client); const result = await functions.getDeployment({ functionId: '', - deploymentId: '' + deploymentId: '', }); ``` diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md index c987772d..dae7043a 100644 --- a/docs/examples/functions/get-execution.md +++ b/docs/examples/functions/get-execution.md @@ -10,6 +10,6 @@ const functions = new sdk.Functions(client); const result = await functions.getExecution({ functionId: '', - executionId: '' + executionId: '', }); ``` diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md index abc2e91d..8f9f37e0 100644 --- a/docs/examples/functions/get-variable.md +++ b/docs/examples/functions/get-variable.md @@ -10,6 +10,6 @@ const functions = new sdk.Functions(client); const result = await functions.getVariable({ functionId: '', - variableId: '' + variableId: '', }); ``` diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md index 97050f04..5eb892c4 100644 --- a/docs/examples/functions/get.md +++ b/docs/examples/functions/get.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); const result = await functions.get({ - functionId: '' + functionId: '', }); ``` diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md index c53aaa45..966e5638 100644 --- a/docs/examples/functions/list-deployments.md +++ b/docs/examples/functions/list-deployments.md @@ -12,6 +12,6 @@ const result = await functions.listDeployments({ functionId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index b549100f..ad4ea3d8 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -11,6 +11,6 @@ const functions = new sdk.Functions(client); const result = await functions.listExecutions({ functionId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/functions/list-specifications.md b/docs/examples/functions/list-specifications.md index f9bb52b9..f779206d 100644 --- a/docs/examples/functions/list-specifications.md +++ b/docs/examples/functions/list-specifications.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); const result = await functions.listSpecifications({ - type: 'runtimes' // optional + type: 'runtimes', // optional }); ``` diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md index d09e5d05..e0f09516 100644 --- a/docs/examples/functions/list-variables.md +++ b/docs/examples/functions/list-variables.md @@ -11,6 +11,6 @@ const functions = new sdk.Functions(client); const result = await functions.listVariables({ functionId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index faeeaae7..db5204eb 100644 --- a/docs/examples/functions/list.md +++ b/docs/examples/functions/list.md @@ -11,6 +11,6 @@ const functions = new sdk.Functions(client); const result = await functions.list({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/functions/update-deployment-status.md b/docs/examples/functions/update-deployment-status.md index 5d45a02a..acbdea42 100644 --- a/docs/examples/functions/update-deployment-status.md +++ b/docs/examples/functions/update-deployment-status.md @@ -10,6 +10,6 @@ const functions = new sdk.Functions(client); const result = await functions.updateDeploymentStatus({ functionId: '', - deploymentId: '' + deploymentId: '', }); ``` diff --git a/docs/examples/functions/update-function-deployment.md b/docs/examples/functions/update-function-deployment.md index 0dfd06f5..fc183f8a 100644 --- a/docs/examples/functions/update-function-deployment.md +++ b/docs/examples/functions/update-function-deployment.md @@ -10,6 +10,6 @@ const functions = new sdk.Functions(client); const result = await functions.updateFunctionDeployment({ functionId: '', - deploymentId: '' + deploymentId: '', }); ``` diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md index e0bdec98..61b96621 100644 --- a/docs/examples/functions/update-variable.md +++ b/docs/examples/functions/update-variable.md @@ -13,6 +13,6 @@ const result = await functions.updateVariable({ variableId: '', key: '', // optional value: '', // optional - secret: false // optional + secret: false, // optional }); ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 7d64aa26..2f299f28 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -12,9 +12,9 @@ const result = await functions.update({ functionId: '', name: '', runtime: sdk.Runtime.Node145, // optional - execute: ["any"], // optional + execute: ['any'], // optional events: [], // optional - schedule: '', // optional + schedule: '0 0 * * *', // optional timeout: 1, // optional enabled: false, // optional logging: false, // optional @@ -28,8 +28,8 @@ const result = await functions.update({ providerRootDirectory: '', // optional providerBranches: [], // optional providerPaths: [], // optional - buildSpecification: '', // optional - runtimeSpecification: '', // optional - deploymentRetention: 0 // optional + buildSpecification: 's-1vcpu-512mb', // optional + runtimeSpecification: 's-1vcpu-512mb', // optional + deploymentRetention: 0, // optional }); ``` diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index 31aa4bf3..cb60aa52 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const graphql = new sdk.Graphql(client); const result = await graphql.mutation({ - query: {} + query: {}, }); ``` diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 3bd436e0..86ba6962 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const graphql = new sdk.Graphql(client); const result = await graphql.query({ - query: {} + query: {}, }); ``` diff --git a/docs/examples/messaging/create-apns-provider.md b/docs/examples/messaging/create-apns-provider.md index dc203a39..04e45525 100644 --- a/docs/examples/messaging/create-apns-provider.md +++ b/docs/examples/messaging/create-apns-provider.md @@ -16,6 +16,6 @@ const result = await messaging.createAPNSProvider({ teamId: '', // optional bundleId: '', // optional sandbox: false, // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index 1662aae1..c979b47c 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -20,6 +20,6 @@ const result = await messaging.createEmail({ attachments: [], // optional draft: false, // optional html: false, // optional - scheduledAt: '2020-10-15T06:38:00.000+00:00' // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); ``` diff --git a/docs/examples/messaging/create-fcm-provider.md b/docs/examples/messaging/create-fcm-provider.md index 78b6d06c..d23e5f46 100644 --- a/docs/examples/messaging/create-fcm-provider.md +++ b/docs/examples/messaging/create-fcm-provider.md @@ -12,6 +12,6 @@ const result = await messaging.createFCMProvider({ providerId: '', name: '', serviceAccountJSON: {}, // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/messaging/create-mailgun-provider.md b/docs/examples/messaging/create-mailgun-provider.md index f2961b6d..70f64eb4 100644 --- a/docs/examples/messaging/create-mailgun-provider.md +++ b/docs/examples/messaging/create-mailgun-provider.md @@ -12,12 +12,12 @@ const result = await messaging.createMailgunProvider({ providerId: '', name: '', apiKey: '', // optional - domain: '', // optional + domain: 'example.com', // optional isEuRegion: false, // optional fromName: '', // optional fromEmail: 'email@example.com', // optional replyToName: '', // optional replyToEmail: 'email@example.com', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/messaging/create-msg-91-provider.md b/docs/examples/messaging/create-msg-91-provider.md index ba6829a6..ace599e3 100644 --- a/docs/examples/messaging/create-msg-91-provider.md +++ b/docs/examples/messaging/create-msg-91-provider.md @@ -14,6 +14,6 @@ const result = await messaging.createMsg91Provider({ templateId: '', // optional senderId: '', // optional authKey: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index 467cde4a..6e2fd140 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -22,11 +22,11 @@ const result = await messaging.createPush({ sound: '', // optional color: '', // optional tag: '', // optional - badge: null, // optional + badge: 1, // optional draft: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional contentAvailable: false, // optional critical: false, // optional - priority: sdk.MessagePriority.Normal // optional + priority: sdk.MessagePriority.Normal, // optional }); ``` diff --git a/docs/examples/messaging/create-resend-provider.md b/docs/examples/messaging/create-resend-provider.md index d1c391d0..746cdeb9 100644 --- a/docs/examples/messaging/create-resend-provider.md +++ b/docs/examples/messaging/create-resend-provider.md @@ -16,6 +16,6 @@ const result = await messaging.createResendProvider({ fromEmail: 'email@example.com', // optional replyToName: '', // optional replyToEmail: 'email@example.com', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/messaging/create-sendgrid-provider.md b/docs/examples/messaging/create-sendgrid-provider.md index 9c3be00c..18eea0b9 100644 --- a/docs/examples/messaging/create-sendgrid-provider.md +++ b/docs/examples/messaging/create-sendgrid-provider.md @@ -16,6 +16,6 @@ const result = await messaging.createSendgridProvider({ fromEmail: 'email@example.com', // optional replyToName: '', // optional replyToEmail: 'email@example.com', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/messaging/create-ses-provider.md b/docs/examples/messaging/create-ses-provider.md index c25a7fea..2112c283 100644 --- a/docs/examples/messaging/create-ses-provider.md +++ b/docs/examples/messaging/create-ses-provider.md @@ -18,6 +18,6 @@ const result = await messaging.createSesProvider({ fromEmail: 'email@example.com', // optional replyToName: '', // optional replyToEmail: 'email@example.com', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md index 31d75c00..0108af62 100644 --- a/docs/examples/messaging/create-sms.md +++ b/docs/examples/messaging/create-sms.md @@ -15,6 +15,6 @@ const result = await messaging.createSMS({ users: [], // optional targets: [], // optional draft: false, // optional - scheduledAt: '2020-10-15T06:38:00.000+00:00' // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); ``` diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md index b980c3b3..65e264ff 100644 --- a/docs/examples/messaging/create-smtp-provider.md +++ b/docs/examples/messaging/create-smtp-provider.md @@ -12,7 +12,7 @@ const result = await messaging.createSMTPProvider({ providerId: '', name: '', host: '', - port: 1, // optional + port: 587, // optional username: '', // optional password: 'password', // optional encryption: sdk.SmtpEncryption.None, // optional @@ -22,6 +22,6 @@ const result = await messaging.createSMTPProvider({ fromEmail: 'email@example.com', // optional replyToName: '', // optional replyToEmail: 'email@example.com', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/messaging/create-subscriber.md b/docs/examples/messaging/create-subscriber.md index 51410af7..cd5027e9 100644 --- a/docs/examples/messaging/create-subscriber.md +++ b/docs/examples/messaging/create-subscriber.md @@ -11,6 +11,6 @@ const messaging = new sdk.Messaging(client); const result = await messaging.createSubscriber({ topicId: '', subscriberId: '', - targetId: '' + targetId: '', }); ``` diff --git a/docs/examples/messaging/create-telesign-provider.md b/docs/examples/messaging/create-telesign-provider.md index baf83a6c..7d2a8e33 100644 --- a/docs/examples/messaging/create-telesign-provider.md +++ b/docs/examples/messaging/create-telesign-provider.md @@ -14,6 +14,6 @@ const result = await messaging.createTelesignProvider({ from: '+12065550100', // optional customerId: '', // optional apiKey: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/messaging/create-textmagic-provider.md b/docs/examples/messaging/create-textmagic-provider.md index 655a2248..05b49347 100644 --- a/docs/examples/messaging/create-textmagic-provider.md +++ b/docs/examples/messaging/create-textmagic-provider.md @@ -14,6 +14,6 @@ const result = await messaging.createTextmagicProvider({ from: '+12065550100', // optional username: '', // optional apiKey: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md index 4625517a..5a05064e 100644 --- a/docs/examples/messaging/create-topic.md +++ b/docs/examples/messaging/create-topic.md @@ -11,6 +11,6 @@ const messaging = new sdk.Messaging(client); const result = await messaging.createTopic({ topicId: '', name: '', - subscribe: ["any"] // optional + subscribe: ['any'], // optional }); ``` diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index 0db55435..4b25a767 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -14,6 +14,6 @@ const result = await messaging.createTwilioProvider({ from: '+12065550100', // optional accountSid: '', // optional authToken: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/messaging/create-vonage-provider.md b/docs/examples/messaging/create-vonage-provider.md index cf8cd38a..f5f94a5b 100644 --- a/docs/examples/messaging/create-vonage-provider.md +++ b/docs/examples/messaging/create-vonage-provider.md @@ -14,6 +14,6 @@ const result = await messaging.createVonageProvider({ from: '+12065550100', // optional apiKey: '', // optional apiSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/messaging/delete-provider.md b/docs/examples/messaging/delete-provider.md index 53fc2aea..d1bc6074 100644 --- a/docs/examples/messaging/delete-provider.md +++ b/docs/examples/messaging/delete-provider.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); const result = await messaging.deleteProvider({ - providerId: '' + providerId: '', }); ``` diff --git a/docs/examples/messaging/delete-subscriber.md b/docs/examples/messaging/delete-subscriber.md index 99c61d7a..d25b9d79 100644 --- a/docs/examples/messaging/delete-subscriber.md +++ b/docs/examples/messaging/delete-subscriber.md @@ -10,6 +10,6 @@ const messaging = new sdk.Messaging(client); const result = await messaging.deleteSubscriber({ topicId: '', - subscriberId: '' + subscriberId: '', }); ``` diff --git a/docs/examples/messaging/delete-topic.md b/docs/examples/messaging/delete-topic.md index 3ffa99f9..78a0898f 100644 --- a/docs/examples/messaging/delete-topic.md +++ b/docs/examples/messaging/delete-topic.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); const result = await messaging.deleteTopic({ - topicId: '' + topicId: '', }); ``` diff --git a/docs/examples/messaging/delete.md b/docs/examples/messaging/delete.md index 62e7d61a..feb7e028 100644 --- a/docs/examples/messaging/delete.md +++ b/docs/examples/messaging/delete.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); const result = await messaging.delete({ - messageId: '' + messageId: '', }); ``` diff --git a/docs/examples/messaging/get-message.md b/docs/examples/messaging/get-message.md index 894a74ac..30c5ee15 100644 --- a/docs/examples/messaging/get-message.md +++ b/docs/examples/messaging/get-message.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); const result = await messaging.getMessage({ - messageId: '' + messageId: '', }); ``` diff --git a/docs/examples/messaging/get-provider.md b/docs/examples/messaging/get-provider.md index c7e91ff0..e7f43b89 100644 --- a/docs/examples/messaging/get-provider.md +++ b/docs/examples/messaging/get-provider.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); const result = await messaging.getProvider({ - providerId: '' + providerId: '', }); ``` diff --git a/docs/examples/messaging/get-subscriber.md b/docs/examples/messaging/get-subscriber.md index 8a915341..7fbb75d0 100644 --- a/docs/examples/messaging/get-subscriber.md +++ b/docs/examples/messaging/get-subscriber.md @@ -10,6 +10,6 @@ const messaging = new sdk.Messaging(client); const result = await messaging.getSubscriber({ topicId: '', - subscriberId: '' + subscriberId: '', }); ``` diff --git a/docs/examples/messaging/get-topic.md b/docs/examples/messaging/get-topic.md index f352c9d7..72c855f3 100644 --- a/docs/examples/messaging/get-topic.md +++ b/docs/examples/messaging/get-topic.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); const result = await messaging.getTopic({ - topicId: '' + topicId: '', }); ``` diff --git a/docs/examples/messaging/list-messages.md b/docs/examples/messaging/list-messages.md index 053adc9f..39ad98fa 100644 --- a/docs/examples/messaging/list-messages.md +++ b/docs/examples/messaging/list-messages.md @@ -11,6 +11,6 @@ const messaging = new sdk.Messaging(client); const result = await messaging.listMessages({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/messaging/list-providers.md b/docs/examples/messaging/list-providers.md index 603ff0bd..968921d1 100644 --- a/docs/examples/messaging/list-providers.md +++ b/docs/examples/messaging/list-providers.md @@ -11,6 +11,6 @@ const messaging = new sdk.Messaging(client); const result = await messaging.listProviders({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/messaging/list-subscribers.md b/docs/examples/messaging/list-subscribers.md index bba6aae4..241c7493 100644 --- a/docs/examples/messaging/list-subscribers.md +++ b/docs/examples/messaging/list-subscribers.md @@ -12,6 +12,6 @@ const result = await messaging.listSubscribers({ topicId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/messaging/list-targets.md b/docs/examples/messaging/list-targets.md index dc053961..d318da81 100644 --- a/docs/examples/messaging/list-targets.md +++ b/docs/examples/messaging/list-targets.md @@ -11,6 +11,6 @@ const messaging = new sdk.Messaging(client); const result = await messaging.listTargets({ messageId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/messaging/list-topics.md b/docs/examples/messaging/list-topics.md index 62fecb61..eaef351f 100644 --- a/docs/examples/messaging/list-topics.md +++ b/docs/examples/messaging/list-topics.md @@ -11,6 +11,6 @@ const messaging = new sdk.Messaging(client); const result = await messaging.listTopics({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/messaging/update-apns-provider.md b/docs/examples/messaging/update-apns-provider.md index 6cd012d9..800e8850 100644 --- a/docs/examples/messaging/update-apns-provider.md +++ b/docs/examples/messaging/update-apns-provider.md @@ -16,6 +16,6 @@ const result = await messaging.updateAPNSProvider({ authKeyId: '', // optional teamId: '', // optional bundleId: '', // optional - sandbox: false // optional + sandbox: false, // optional }); ``` diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index f4e27865..aaf9d751 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -20,6 +20,6 @@ const result = await messaging.updateEmail({ cc: [], // optional bcc: [], // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional - attachments: [] // optional + attachments: [], // optional }); ``` diff --git a/docs/examples/messaging/update-fcm-provider.md b/docs/examples/messaging/update-fcm-provider.md index 4d76843e..8612b2a6 100644 --- a/docs/examples/messaging/update-fcm-provider.md +++ b/docs/examples/messaging/update-fcm-provider.md @@ -12,6 +12,6 @@ const result = await messaging.updateFCMProvider({ providerId: '', name: '', // optional enabled: false, // optional - serviceAccountJSON: {} // optional + serviceAccountJSON: {}, // optional }); ``` diff --git a/docs/examples/messaging/update-mailgun-provider.md b/docs/examples/messaging/update-mailgun-provider.md index 5725f1eb..fddbf5d6 100644 --- a/docs/examples/messaging/update-mailgun-provider.md +++ b/docs/examples/messaging/update-mailgun-provider.md @@ -12,12 +12,12 @@ const result = await messaging.updateMailgunProvider({ providerId: '', name: '', // optional apiKey: '', // optional - domain: '', // optional + domain: 'example.com', // optional isEuRegion: false, // optional enabled: false, // optional fromName: '', // optional fromEmail: 'email@example.com', // optional replyToName: '', // optional - replyToEmail: '' // optional + replyToEmail: '', // optional }); ``` diff --git a/docs/examples/messaging/update-msg-91-provider.md b/docs/examples/messaging/update-msg-91-provider.md index d66ba73f..debc079b 100644 --- a/docs/examples/messaging/update-msg-91-provider.md +++ b/docs/examples/messaging/update-msg-91-provider.md @@ -14,6 +14,6 @@ const result = await messaging.updateMsg91Provider({ enabled: false, // optional templateId: '', // optional senderId: '', // optional - authKey: '' // optional + authKey: '', // optional }); ``` diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index f0e5e324..cf8f6f1b 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -22,11 +22,11 @@ const result = await messaging.updatePush({ sound: '', // optional color: '', // optional tag: '', // optional - badge: null, // optional + badge: 1, // optional draft: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional contentAvailable: false, // optional critical: false, // optional - priority: sdk.MessagePriority.Normal // optional + priority: sdk.MessagePriority.Normal, // optional }); ``` diff --git a/docs/examples/messaging/update-resend-provider.md b/docs/examples/messaging/update-resend-provider.md index 563c907f..e3c7fc2f 100644 --- a/docs/examples/messaging/update-resend-provider.md +++ b/docs/examples/messaging/update-resend-provider.md @@ -16,6 +16,6 @@ const result = await messaging.updateResendProvider({ fromName: '', // optional fromEmail: 'email@example.com', // optional replyToName: '', // optional - replyToEmail: '' // optional + replyToEmail: '', // optional }); ``` diff --git a/docs/examples/messaging/update-sendgrid-provider.md b/docs/examples/messaging/update-sendgrid-provider.md index ece8ae7c..8e5b59b9 100644 --- a/docs/examples/messaging/update-sendgrid-provider.md +++ b/docs/examples/messaging/update-sendgrid-provider.md @@ -16,6 +16,6 @@ const result = await messaging.updateSendgridProvider({ fromName: '', // optional fromEmail: 'email@example.com', // optional replyToName: '', // optional - replyToEmail: '' // optional + replyToEmail: '', // optional }); ``` diff --git a/docs/examples/messaging/update-ses-provider.md b/docs/examples/messaging/update-ses-provider.md index 2858646f..d3e943a1 100644 --- a/docs/examples/messaging/update-ses-provider.md +++ b/docs/examples/messaging/update-ses-provider.md @@ -18,6 +18,6 @@ const result = await messaging.updateSesProvider({ fromName: '', // optional fromEmail: 'email@example.com', // optional replyToName: '', // optional - replyToEmail: '' // optional + replyToEmail: '', // optional }); ``` diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 074cab2e..940474a4 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -15,6 +15,6 @@ const result = await messaging.updateSMS({ targets: [], // optional content: '', // optional draft: false, // optional - scheduledAt: '2020-10-15T06:38:00.000+00:00' // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); ``` diff --git a/docs/examples/messaging/update-smtp-provider.md b/docs/examples/messaging/update-smtp-provider.md index 1b0ec725..94e862be 100644 --- a/docs/examples/messaging/update-smtp-provider.md +++ b/docs/examples/messaging/update-smtp-provider.md @@ -22,6 +22,6 @@ const result = await messaging.updateSMTPProvider({ fromEmail: 'email@example.com', // optional replyToName: '', // optional replyToEmail: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/messaging/update-telesign-provider.md b/docs/examples/messaging/update-telesign-provider.md index b8b7ea08..5d9442f2 100644 --- a/docs/examples/messaging/update-telesign-provider.md +++ b/docs/examples/messaging/update-telesign-provider.md @@ -14,6 +14,6 @@ const result = await messaging.updateTelesignProvider({ enabled: false, // optional customerId: '', // optional apiKey: '', // optional - from: '' // optional + from: '', // optional }); ``` diff --git a/docs/examples/messaging/update-textmagic-provider.md b/docs/examples/messaging/update-textmagic-provider.md index bf35cef8..ef15093d 100644 --- a/docs/examples/messaging/update-textmagic-provider.md +++ b/docs/examples/messaging/update-textmagic-provider.md @@ -14,6 +14,6 @@ const result = await messaging.updateTextmagicProvider({ enabled: false, // optional username: '', // optional apiKey: '', // optional - from: '' // optional + from: '', // optional }); ``` diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md index 8ec30739..2397220a 100644 --- a/docs/examples/messaging/update-topic.md +++ b/docs/examples/messaging/update-topic.md @@ -11,6 +11,6 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updateTopic({ topicId: '', name: '', // optional - subscribe: ["any"] // optional + subscribe: ['any'], // optional }); ``` diff --git a/docs/examples/messaging/update-twilio-provider.md b/docs/examples/messaging/update-twilio-provider.md index da83c43c..eb02eccd 100644 --- a/docs/examples/messaging/update-twilio-provider.md +++ b/docs/examples/messaging/update-twilio-provider.md @@ -14,6 +14,6 @@ const result = await messaging.updateTwilioProvider({ enabled: false, // optional accountSid: '', // optional authToken: '', // optional - from: '' // optional + from: '', // optional }); ``` diff --git a/docs/examples/messaging/update-vonage-provider.md b/docs/examples/messaging/update-vonage-provider.md index caefea0d..203e435c 100644 --- a/docs/examples/messaging/update-vonage-provider.md +++ b/docs/examples/messaging/update-vonage-provider.md @@ -14,6 +14,6 @@ const result = await messaging.updateVonageProvider({ enabled: false, // optional apiKey: '', // optional apiSecret: '', // optional - from: '' // optional + from: '', // optional }); ``` diff --git a/docs/examples/mongo/create-backup-policy.md b/docs/examples/mongo/create-backup-policy.md new file mode 100644 index 00000000..3496600c --- /dev/null +++ b/docs/examples/mongo/create-backup-policy.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 mongo = new sdk.Mongo(client); + +const result = await mongo.createBackupPolicy({ + databaseId: '', + policyId: '', + name: '', + schedule: '', + retention: 1, + type: 'full', // optional + enabled: false, // optional +}); +``` diff --git a/docs/examples/mongo/create-backup.md b/docs/examples/mongo/create-backup.md new file mode 100644 index 00000000..532eac7b --- /dev/null +++ b/docs/examples/mongo/create-backup.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 mongo = new sdk.Mongo(client); + +const result = await mongo.createBackup({ + databaseId: '', + type: 'full', // optional +}); +``` diff --git a/docs/examples/mongo/create-branch.md b/docs/examples/mongo/create-branch.md new file mode 100644 index 00000000..78aa3759 --- /dev/null +++ b/docs/examples/mongo/create-branch.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 mongo = new sdk.Mongo(client); + +const result = await mongo.createBranch({ + databaseId: '', + branchId: '', // optional + ttl: 300, // optional +}); +``` diff --git a/docs/examples/mongo/create-failover.md b/docs/examples/mongo/create-failover.md new file mode 100644 index 00000000..598b48d7 --- /dev/null +++ b/docs/examples/mongo/create-failover.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 mongo = new sdk.Mongo(client); + +const result = await mongo.createFailover({ + databaseId: '', + targetReplicaId: '', // optional +}); +``` diff --git a/docs/examples/mongo/create-migration.md b/docs/examples/mongo/create-migration.md new file mode 100644 index 00000000..dfa2b2b7 --- /dev/null +++ b/docs/examples/mongo/create-migration.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 mongo = new sdk.Mongo(client); + +const result = await mongo.createMigration({ + databaseId: '', + targetType: 'shared', + specification: '', // optional +}); +``` diff --git a/docs/examples/mongo/create-restoration.md b/docs/examples/mongo/create-restoration.md new file mode 100644 index 00000000..7a6f1a3d --- /dev/null +++ b/docs/examples/mongo/create-restoration.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 mongo = new sdk.Mongo(client); + +const result = await mongo.createRestoration({ + databaseId: '', + type: 'backup', // optional + backupId: '', // optional + targetDatabaseId: '', // optional + targetTime: '2020-10-15T06:38:00.000+00:00', // optional +}); +``` diff --git a/docs/examples/mongo/create-upgrade.md b/docs/examples/mongo/create-upgrade.md new file mode 100644 index 00000000..6764df2d --- /dev/null +++ b/docs/examples/mongo/create-upgrade.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 mongo = new sdk.Mongo(client); + +const result = await mongo.createUpgrade({ + databaseId: '', + targetVersion: '', +}); +``` diff --git a/docs/examples/mongo/create.md b/docs/examples/mongo/create.md new file mode 100644 index 00000000..cb6d8f71 --- /dev/null +++ b/docs/examples/mongo/create.md @@ -0,0 +1,27 @@ +```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 mongo = new sdk.Mongo(client); + +const result = await mongo.create({ + databaseId: '', + name: '', + version: '17', // optional + specification: '', // optional + replicas: 0, // optional + syncMode: 'async', // optional + networkIdleTimeoutSeconds: 60, // optional + networkIPAllowlist: [], // optional + idleTimeoutMinutes: 5, // optional + pitr: false, // optional + pitrRetentionDays: 1, // optional + storageAutoscaling: false, // optional + storageAutoscalingThresholdPercent: 50, // optional + storageAutoscalingMaxGb: 0, // optional +}); +``` diff --git a/docs/examples/mongo/delete-backup-policy.md b/docs/examples/mongo/delete-backup-policy.md new file mode 100644 index 00000000..959a03cf --- /dev/null +++ b/docs/examples/mongo/delete-backup-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 mongo = new sdk.Mongo(client); + +const result = await mongo.deleteBackupPolicy({ + databaseId: '', + policyId: '', +}); +``` diff --git a/docs/examples/mongo/delete-backup.md b/docs/examples/mongo/delete-backup.md new file mode 100644 index 00000000..386d2209 --- /dev/null +++ b/docs/examples/mongo/delete-backup.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 mongo = new sdk.Mongo(client); + +const result = await mongo.deleteBackup({ + databaseId: '', + backupId: '', +}); +``` diff --git a/docs/examples/mongo/delete-branch.md b/docs/examples/mongo/delete-branch.md new file mode 100644 index 00000000..2bb3b262 --- /dev/null +++ b/docs/examples/mongo/delete-branch.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 mongo = new sdk.Mongo(client); + +const result = await mongo.deleteBranch({ + databaseId: '', + branchId: '', +}); +``` diff --git a/docs/examples/mongo/delete.md b/docs/examples/mongo/delete.md new file mode 100644 index 00000000..8da60508 --- /dev/null +++ b/docs/examples/mongo/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 mongo = new sdk.Mongo(client); + +const result = await mongo.delete({ + databaseId: '', +}); +``` diff --git a/docs/examples/mongo/get-backup-policy.md b/docs/examples/mongo/get-backup-policy.md new file mode 100644 index 00000000..fe057b5c --- /dev/null +++ b/docs/examples/mongo/get-backup-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 mongo = new sdk.Mongo(client); + +const result = await mongo.getBackupPolicy({ + databaseId: '', + policyId: '', +}); +``` diff --git a/docs/examples/mongo/get-backup.md b/docs/examples/mongo/get-backup.md new file mode 100644 index 00000000..a80c6290 --- /dev/null +++ b/docs/examples/mongo/get-backup.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 mongo = new sdk.Mongo(client); + +const result = await mongo.getBackup({ + databaseId: '', + backupId: '', +}); +``` diff --git a/docs/examples/mongo/get-pitr.md b/docs/examples/mongo/get-pitr.md new file mode 100644 index 00000000..fb1fe5d7 --- /dev/null +++ b/docs/examples/mongo/get-pitr.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 mongo = new sdk.Mongo(client); + +const result = await mongo.getPitr({ + databaseId: '', +}); +``` diff --git a/docs/examples/mongo/get-replicas.md b/docs/examples/mongo/get-replicas.md new file mode 100644 index 00000000..33402e1d --- /dev/null +++ b/docs/examples/mongo/get-replicas.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 mongo = new sdk.Mongo(client); + +const result = await mongo.getReplicas({ + databaseId: '', +}); +``` diff --git a/docs/examples/mongo/get-restoration.md b/docs/examples/mongo/get-restoration.md new file mode 100644 index 00000000..0ab1d0cd --- /dev/null +++ b/docs/examples/mongo/get-restoration.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 mongo = new sdk.Mongo(client); + +const result = await mongo.getRestoration({ + databaseId: '', + restorationId: '', +}); +``` diff --git a/docs/examples/mongo/get-status.md b/docs/examples/mongo/get-status.md new file mode 100644 index 00000000..2e15d829 --- /dev/null +++ b/docs/examples/mongo/get-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 mongo = new sdk.Mongo(client); + +const result = await mongo.getStatus({ + databaseId: '', +}); +``` diff --git a/docs/examples/mongo/get.md b/docs/examples/mongo/get.md new file mode 100644 index 00000000..7caf6348 --- /dev/null +++ b/docs/examples/mongo/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 mongo = new sdk.Mongo(client); + +const result = await mongo.get({ + databaseId: '', +}); +``` diff --git a/docs/examples/mongo/list-backup-policies.md b/docs/examples/mongo/list-backup-policies.md new file mode 100644 index 00000000..d40381ef --- /dev/null +++ b/docs/examples/mongo/list-backup-policies.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 mongo = new sdk.Mongo(client); + +const result = await mongo.listBackupPolicies({ + databaseId: '', + queries: [], // optional +}); +``` diff --git a/docs/examples/mongo/list-backups.md b/docs/examples/mongo/list-backups.md new file mode 100644 index 00000000..2041759f --- /dev/null +++ b/docs/examples/mongo/list-backups.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 mongo = new sdk.Mongo(client); + +const result = await mongo.listBackups({ + databaseId: '', + queries: [], // optional +}); +``` diff --git a/docs/examples/mongo/list-branches.md b/docs/examples/mongo/list-branches.md new file mode 100644 index 00000000..663723b8 --- /dev/null +++ b/docs/examples/mongo/list-branches.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 mongo = new sdk.Mongo(client); + +const result = await mongo.listBranches({ + databaseId: '', +}); +``` diff --git a/docs/examples/mongo/list-operations.md b/docs/examples/mongo/list-operations.md new file mode 100644 index 00000000..aac0189c --- /dev/null +++ b/docs/examples/mongo/list-operations.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 mongo = new sdk.Mongo(client); + +const result = await mongo.listOperations({ + databaseId: '', + status: 'queued', // optional + limit: 1, // optional + offset: 0, // optional +}); +``` diff --git a/docs/examples/mongo/list-restorations.md b/docs/examples/mongo/list-restorations.md new file mode 100644 index 00000000..1efd1462 --- /dev/null +++ b/docs/examples/mongo/list-restorations.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 mongo = new sdk.Mongo(client); + +const result = await mongo.listRestorations({ + databaseId: '', + status: 'pending', // optional + type: 'backup', // optional + limit: 1, // optional + offset: 0, // optional +}); +``` diff --git a/docs/examples/mongo/list-specifications.md b/docs/examples/mongo/list-specifications.md new file mode 100644 index 00000000..f8b3110f --- /dev/null +++ b/docs/examples/mongo/list-specifications.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 + .setKey(''); // Your secret API key + +const mongo = new sdk.Mongo(client); + +const result = await mongo.listSpecifications(); +``` diff --git a/docs/examples/mongo/list.md b/docs/examples/mongo/list.md new file mode 100644 index 00000000..ee7406b7 --- /dev/null +++ b/docs/examples/mongo/list.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 mongo = new sdk.Mongo(client); + +const result = await mongo.list({ + queries: [], // optional +}); +``` diff --git a/docs/examples/mongo/update-backup-policy.md b/docs/examples/mongo/update-backup-policy.md new file mode 100644 index 00000000..9d22b781 --- /dev/null +++ b/docs/examples/mongo/update-backup-policy.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 mongo = new sdk.Mongo(client); + +const result = await mongo.updateBackupPolicy({ + databaseId: '', + policyId: '', + name: '', // optional + schedule: '', // optional + retention: 1, // optional + enabled: false, // optional +}); +``` diff --git a/docs/examples/mongo/update-backup-storage.md b/docs/examples/mongo/update-backup-storage.md new file mode 100644 index 00000000..8632ab61 --- /dev/null +++ b/docs/examples/mongo/update-backup-storage.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 mongo = new sdk.Mongo(client); + +const result = await mongo.updateBackupStorage({ + databaseId: '', + provider: 's3', + bucket: '', + accessKey: '', + secretKey: '', + region: '', // optional + prefix: '', // optional + endpoint: '', // optional +}); +``` diff --git a/docs/examples/mongo/update-credentials.md b/docs/examples/mongo/update-credentials.md new file mode 100644 index 00000000..43cd025a --- /dev/null +++ b/docs/examples/mongo/update-credentials.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 mongo = new sdk.Mongo(client); + +const result = await mongo.updateCredentials({ + databaseId: '', +}); +``` diff --git a/docs/examples/mongo/update-maintenance.md b/docs/examples/mongo/update-maintenance.md new file mode 100644 index 00000000..e28f6fd1 --- /dev/null +++ b/docs/examples/mongo/update-maintenance.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 mongo = new sdk.Mongo(client); + +const result = await mongo.updateMaintenance({ + databaseId: '', + day: 'sun', + hourUtc: 0, +}); +``` diff --git a/docs/examples/mongo/update.md b/docs/examples/mongo/update.md new file mode 100644 index 00000000..046588e6 --- /dev/null +++ b/docs/examples/mongo/update.md @@ -0,0 +1,34 @@ +```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 mongo = new sdk.Mongo(client); + +const result = await mongo.update({ + databaseId: '', + name: '', // optional + status: 'ready', // optional + specification: '', // optional + replicas: 0, // optional + syncMode: 'async', // optional + networkIdleTimeoutSeconds: 60, // optional + networkIPAllowlist: [], // optional + idleTimeoutMinutes: 5, // optional + pitr: false, // optional + pitrRetentionDays: 1, // optional + storageAutoscaling: false, // optional + storageAutoscalingThresholdPercent: 50, // optional + storageAutoscalingMaxGb: 0, // optional + metricsTraceSampleRate: null, // optional + metricsSlowQueryLogThresholdMs: 0, // optional + sqlApiEnabled: false, // optional + sqlApiAllowedStatements: [], // optional + sqlApiMaxRows: 1, // optional + sqlApiMaxBytes: 1024, // optional + sqlApiTimeoutSeconds: 1, // optional +}); +``` diff --git a/docs/examples/mysql/create-backup-policy.md b/docs/examples/mysql/create-backup-policy.md new file mode 100644 index 00000000..bbaf973e --- /dev/null +++ b/docs/examples/mysql/create-backup-policy.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 mysql = new sdk.Mysql(client); + +const result = await mysql.createBackupPolicy({ + databaseId: '', + policyId: '', + name: '', + schedule: '', + retention: 1, + type: 'full', // optional + enabled: false, // optional +}); +``` diff --git a/docs/examples/mysql/create-backup.md b/docs/examples/mysql/create-backup.md new file mode 100644 index 00000000..5515c81c --- /dev/null +++ b/docs/examples/mysql/create-backup.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 mysql = new sdk.Mysql(client); + +const result = await mysql.createBackup({ + databaseId: '', + type: 'full', // optional +}); +``` diff --git a/docs/examples/mysql/create-branch.md b/docs/examples/mysql/create-branch.md new file mode 100644 index 00000000..6c5f671f --- /dev/null +++ b/docs/examples/mysql/create-branch.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 mysql = new sdk.Mysql(client); + +const result = await mysql.createBranch({ + databaseId: '', + branchId: '', // optional + ttl: 300, // optional +}); +``` diff --git a/docs/examples/mysql/create-execution.md b/docs/examples/mysql/create-execution.md new file mode 100644 index 00000000..2554bbeb --- /dev/null +++ b/docs/examples/mysql/create-execution.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 mysql = new sdk.Mysql(client); + +const result = await mysql.createExecution({ + databaseId: '', + sql: '', + bindings: {}, // optional + timeoutSeconds: 1, // optional +}); +``` diff --git a/docs/examples/mysql/create-failover.md b/docs/examples/mysql/create-failover.md new file mode 100644 index 00000000..0fcf5b90 --- /dev/null +++ b/docs/examples/mysql/create-failover.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 mysql = new sdk.Mysql(client); + +const result = await mysql.createFailover({ + databaseId: '', + targetReplicaId: '', // optional +}); +``` diff --git a/docs/examples/mysql/create-migration.md b/docs/examples/mysql/create-migration.md new file mode 100644 index 00000000..1c09f565 --- /dev/null +++ b/docs/examples/mysql/create-migration.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 mysql = new sdk.Mysql(client); + +const result = await mysql.createMigration({ + databaseId: '', + targetType: 'shared', + specification: '', // optional +}); +``` diff --git a/docs/examples/mysql/create-restoration.md b/docs/examples/mysql/create-restoration.md new file mode 100644 index 00000000..6e95f011 --- /dev/null +++ b/docs/examples/mysql/create-restoration.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 mysql = new sdk.Mysql(client); + +const result = await mysql.createRestoration({ + databaseId: '', + type: 'backup', // optional + backupId: '', // optional + targetDatabaseId: '', // optional + targetTime: '2020-10-15T06:38:00.000+00:00', // optional +}); +``` diff --git a/docs/examples/mysql/create-upgrade.md b/docs/examples/mysql/create-upgrade.md new file mode 100644 index 00000000..36aeac54 --- /dev/null +++ b/docs/examples/mysql/create-upgrade.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 mysql = new sdk.Mysql(client); + +const result = await mysql.createUpgrade({ + databaseId: '', + targetVersion: '', +}); +``` diff --git a/docs/examples/mysql/create.md b/docs/examples/mysql/create.md new file mode 100644 index 00000000..81573b49 --- /dev/null +++ b/docs/examples/mysql/create.md @@ -0,0 +1,27 @@ +```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 mysql = new sdk.Mysql(client); + +const result = await mysql.create({ + databaseId: '', + name: '', + version: '17', // optional + specification: '', // optional + replicas: 0, // optional + syncMode: 'async', // optional + networkIdleTimeoutSeconds: 60, // optional + networkIPAllowlist: [], // optional + idleTimeoutMinutes: 5, // optional + pitr: false, // optional + pitrRetentionDays: 1, // optional + storageAutoscaling: false, // optional + storageAutoscalingThresholdPercent: 50, // optional + storageAutoscalingMaxGb: 0, // optional +}); +``` diff --git a/docs/examples/mysql/delete-backup-policy.md b/docs/examples/mysql/delete-backup-policy.md new file mode 100644 index 00000000..94b672a2 --- /dev/null +++ b/docs/examples/mysql/delete-backup-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 mysql = new sdk.Mysql(client); + +const result = await mysql.deleteBackupPolicy({ + databaseId: '', + policyId: '', +}); +``` diff --git a/docs/examples/mysql/delete-backup.md b/docs/examples/mysql/delete-backup.md new file mode 100644 index 00000000..1a416691 --- /dev/null +++ b/docs/examples/mysql/delete-backup.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 mysql = new sdk.Mysql(client); + +const result = await mysql.deleteBackup({ + databaseId: '', + backupId: '', +}); +``` diff --git a/docs/examples/mysql/delete-branch.md b/docs/examples/mysql/delete-branch.md new file mode 100644 index 00000000..426cbccd --- /dev/null +++ b/docs/examples/mysql/delete-branch.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 mysql = new sdk.Mysql(client); + +const result = await mysql.deleteBranch({ + databaseId: '', + branchId: '', +}); +``` diff --git a/docs/examples/mysql/delete.md b/docs/examples/mysql/delete.md new file mode 100644 index 00000000..3cd55c34 --- /dev/null +++ b/docs/examples/mysql/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 mysql = new sdk.Mysql(client); + +const result = await mysql.delete({ + databaseId: '', +}); +``` diff --git a/docs/examples/mysql/get-backup-policy.md b/docs/examples/mysql/get-backup-policy.md new file mode 100644 index 00000000..e6f98bcf --- /dev/null +++ b/docs/examples/mysql/get-backup-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 mysql = new sdk.Mysql(client); + +const result = await mysql.getBackupPolicy({ + databaseId: '', + policyId: '', +}); +``` diff --git a/docs/examples/mysql/get-backup.md b/docs/examples/mysql/get-backup.md new file mode 100644 index 00000000..2c97a9d4 --- /dev/null +++ b/docs/examples/mysql/get-backup.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 mysql = new sdk.Mysql(client); + +const result = await mysql.getBackup({ + databaseId: '', + backupId: '', +}); +``` diff --git a/docs/examples/mysql/get-pitr.md b/docs/examples/mysql/get-pitr.md new file mode 100644 index 00000000..69e114ce --- /dev/null +++ b/docs/examples/mysql/get-pitr.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 mysql = new sdk.Mysql(client); + +const result = await mysql.getPitr({ + databaseId: '', +}); +``` diff --git a/docs/examples/mysql/get-pooler.md b/docs/examples/mysql/get-pooler.md new file mode 100644 index 00000000..8817ead3 --- /dev/null +++ b/docs/examples/mysql/get-pooler.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 mysql = new sdk.Mysql(client); + +const result = await mysql.getPooler({ + databaseId: '', +}); +``` diff --git a/docs/examples/mysql/get-replicas.md b/docs/examples/mysql/get-replicas.md new file mode 100644 index 00000000..a5f669d4 --- /dev/null +++ b/docs/examples/mysql/get-replicas.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 mysql = new sdk.Mysql(client); + +const result = await mysql.getReplicas({ + databaseId: '', +}); +``` diff --git a/docs/examples/mysql/get-restoration.md b/docs/examples/mysql/get-restoration.md new file mode 100644 index 00000000..9a8285b4 --- /dev/null +++ b/docs/examples/mysql/get-restoration.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 mysql = new sdk.Mysql(client); + +const result = await mysql.getRestoration({ + databaseId: '', + restorationId: '', +}); +``` diff --git a/docs/examples/mysql/get-status.md b/docs/examples/mysql/get-status.md new file mode 100644 index 00000000..eb783a45 --- /dev/null +++ b/docs/examples/mysql/get-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 mysql = new sdk.Mysql(client); + +const result = await mysql.getStatus({ + databaseId: '', +}); +``` diff --git a/docs/examples/mysql/get.md b/docs/examples/mysql/get.md new file mode 100644 index 00000000..0608db70 --- /dev/null +++ b/docs/examples/mysql/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 mysql = new sdk.Mysql(client); + +const result = await mysql.get({ + databaseId: '', +}); +``` diff --git a/docs/examples/mysql/list-backup-policies.md b/docs/examples/mysql/list-backup-policies.md new file mode 100644 index 00000000..4b3127af --- /dev/null +++ b/docs/examples/mysql/list-backup-policies.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 mysql = new sdk.Mysql(client); + +const result = await mysql.listBackupPolicies({ + databaseId: '', + queries: [], // optional +}); +``` diff --git a/docs/examples/mysql/list-backups.md b/docs/examples/mysql/list-backups.md new file mode 100644 index 00000000..c88356e5 --- /dev/null +++ b/docs/examples/mysql/list-backups.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 mysql = new sdk.Mysql(client); + +const result = await mysql.listBackups({ + databaseId: '', + queries: [], // optional +}); +``` diff --git a/docs/examples/mysql/list-branches.md b/docs/examples/mysql/list-branches.md new file mode 100644 index 00000000..7c3f80da --- /dev/null +++ b/docs/examples/mysql/list-branches.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 mysql = new sdk.Mysql(client); + +const result = await mysql.listBranches({ + databaseId: '', +}); +``` diff --git a/docs/examples/mysql/list-operations.md b/docs/examples/mysql/list-operations.md new file mode 100644 index 00000000..9e322f16 --- /dev/null +++ b/docs/examples/mysql/list-operations.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 mysql = new sdk.Mysql(client); + +const result = await mysql.listOperations({ + databaseId: '', + status: 'queued', // optional + limit: 1, // optional + offset: 0, // optional +}); +``` diff --git a/docs/examples/mysql/list-restorations.md b/docs/examples/mysql/list-restorations.md new file mode 100644 index 00000000..179e85a0 --- /dev/null +++ b/docs/examples/mysql/list-restorations.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 mysql = new sdk.Mysql(client); + +const result = await mysql.listRestorations({ + databaseId: '', + status: 'pending', // optional + type: 'backup', // optional + limit: 1, // optional + offset: 0, // optional +}); +``` diff --git a/docs/examples/mysql/list-specifications.md b/docs/examples/mysql/list-specifications.md new file mode 100644 index 00000000..2fe88533 --- /dev/null +++ b/docs/examples/mysql/list-specifications.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 + .setKey(''); // Your secret API key + +const mysql = new sdk.Mysql(client); + +const result = await mysql.listSpecifications(); +``` diff --git a/docs/examples/mysql/list.md b/docs/examples/mysql/list.md new file mode 100644 index 00000000..11907b7d --- /dev/null +++ b/docs/examples/mysql/list.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 mysql = new sdk.Mysql(client); + +const result = await mysql.list({ + queries: [], // optional +}); +``` diff --git a/docs/examples/mysql/update-backup-policy.md b/docs/examples/mysql/update-backup-policy.md new file mode 100644 index 00000000..a693487f --- /dev/null +++ b/docs/examples/mysql/update-backup-policy.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 mysql = new sdk.Mysql(client); + +const result = await mysql.updateBackupPolicy({ + databaseId: '', + policyId: '', + name: '', // optional + schedule: '', // optional + retention: 1, // optional + enabled: false, // optional +}); +``` diff --git a/docs/examples/mysql/update-backup-storage.md b/docs/examples/mysql/update-backup-storage.md new file mode 100644 index 00000000..96e57e47 --- /dev/null +++ b/docs/examples/mysql/update-backup-storage.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 mysql = new sdk.Mysql(client); + +const result = await mysql.updateBackupStorage({ + databaseId: '', + provider: 's3', + bucket: '', + accessKey: '', + secretKey: '', + region: '', // optional + prefix: '', // optional + endpoint: '', // optional +}); +``` diff --git a/docs/examples/mysql/update-credentials.md b/docs/examples/mysql/update-credentials.md new file mode 100644 index 00000000..00747ff3 --- /dev/null +++ b/docs/examples/mysql/update-credentials.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 mysql = new sdk.Mysql(client); + +const result = await mysql.updateCredentials({ + databaseId: '', +}); +``` diff --git a/docs/examples/mysql/update-maintenance.md b/docs/examples/mysql/update-maintenance.md new file mode 100644 index 00000000..c47156e3 --- /dev/null +++ b/docs/examples/mysql/update-maintenance.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 mysql = new sdk.Mysql(client); + +const result = await mysql.updateMaintenance({ + databaseId: '', + day: 'sun', + hourUtc: 0, +}); +``` diff --git a/docs/examples/mysql/update-pooler.md b/docs/examples/mysql/update-pooler.md new file mode 100644 index 00000000..19af6f49 --- /dev/null +++ b/docs/examples/mysql/update-pooler.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 mysql = new sdk.Mysql(client); + +const result = await mysql.updatePooler({ + databaseId: '', + mode: 'transaction', // optional + maxConnections: 10, // optional + defaultPoolSize: 1, // optional + readWriteSplitting: false, // optional + poolerCpuRequest: '', // optional + poolerCpuLimit: '', // optional + poolerMemoryRequest: '', // optional + poolerMemoryLimit: '', // optional +}); +``` diff --git a/docs/examples/mysql/update.md b/docs/examples/mysql/update.md new file mode 100644 index 00000000..2e16df54 --- /dev/null +++ b/docs/examples/mysql/update.md @@ -0,0 +1,34 @@ +```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 mysql = new sdk.Mysql(client); + +const result = await mysql.update({ + databaseId: '', + name: '', // optional + status: 'ready', // optional + specification: '', // optional + replicas: 0, // optional + syncMode: 'async', // optional + networkIdleTimeoutSeconds: 60, // optional + networkIPAllowlist: [], // optional + idleTimeoutMinutes: 5, // optional + pitr: false, // optional + pitrRetentionDays: 1, // optional + storageAutoscaling: false, // optional + storageAutoscalingThresholdPercent: 50, // optional + storageAutoscalingMaxGb: 0, // optional + metricsTraceSampleRate: null, // optional + metricsSlowQueryLogThresholdMs: 0, // optional + sqlApiEnabled: false, // optional + sqlApiAllowedStatements: [], // optional + sqlApiMaxRows: 1, // optional + sqlApiMaxBytes: 1024, // optional + sqlApiTimeoutSeconds: 1, // optional +}); +``` diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md index 64f473bc..06ee2a8d 100644 --- a/docs/examples/oauth2/approve.md +++ b/docs/examples/oauth2/approve.md @@ -11,6 +11,6 @@ const oauth2 = new sdk.Oauth2(client); const result = await oauth2.approve({ grantId: '', authorizationDetails: '', // optional - scope: '' // optional + scope: '', // optional }); ``` diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 9d9317e9..ca9cc0a0 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -22,6 +22,6 @@ const result = await oauth2.authorizePost({ authorizationDetails: '', // optional resource: '', // optional audience: '', // optional - requestUri: '' // optional + requestUri: '', // optional }); ``` diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index 10b6f612..38047d72 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -22,6 +22,6 @@ const result = await oauth2.authorize({ authorizationDetails: '', // optional resource: '', // optional audience: '', // optional - requestUri: '' // optional + requestUri: '', // optional }); ``` diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index 19710c71..d9e2d61d 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -13,6 +13,6 @@ const result = await oauth2.createDeviceAuthorization({ scope: '', // optional authorizationDetails: '', // optional resource: '', // optional - audience: '' // optional + audience: '', // optional }); ``` diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md index 0f644eef..198af628 100644 --- a/docs/examples/oauth2/create-grant.md +++ b/docs/examples/oauth2/create-grant.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const oauth2 = new sdk.Oauth2(client); const result = await oauth2.createGrant({ - userCode: '' + userCode: '', }); ``` diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index 70623e93..f9febbaa 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -21,6 +21,6 @@ const result = await oauth2.createPAR({ maxAge: 0, // optional authorizationDetails: '', // optional resource: '', // optional - audience: '' // optional + audience: '', // optional }); ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index e27883d7..a45fa1b7 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -18,6 +18,6 @@ const result = await oauth2.createToken({ codeVerifier: '', // optional redirectUri: 'https://example.com', // optional resource: '', // optional - audience: '' // optional + audience: '', // optional }); ``` diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md index b6198128..dcd21cee 100644 --- a/docs/examples/oauth2/get-grant.md +++ b/docs/examples/oauth2/get-grant.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const oauth2 = new sdk.Oauth2(client); const result = await oauth2.getGrant({ - grantId: '' + grantId: '', }); ``` diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md index b9503c21..ddf5793f 100644 --- a/docs/examples/oauth2/list-organizations.md +++ b/docs/examples/oauth2/list-organizations.md @@ -11,6 +11,6 @@ const oauth2 = new sdk.Oauth2(client); const result = await oauth2.listOrganizations({ limit: 1, // optional offset: 0, // optional - search: '' // optional + search: '', // optional }); ``` diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md index 95e89e92..2a5acae7 100644 --- a/docs/examples/oauth2/list-projects.md +++ b/docs/examples/oauth2/list-projects.md @@ -11,6 +11,6 @@ const oauth2 = new sdk.Oauth2(client); const result = await oauth2.listProjects({ limit: 1, // optional offset: 0, // optional - search: '' // optional + search: '', // optional }); ``` diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md index 5e5a8ffb..a577dab0 100644 --- a/docs/examples/oauth2/reject.md +++ b/docs/examples/oauth2/reject.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const oauth2 = new sdk.Oauth2(client); const result = await oauth2.reject({ - grantId: '' + grantId: '', }); ``` diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md index e853410a..287d65f2 100644 --- a/docs/examples/oauth2/revoke.md +++ b/docs/examples/oauth2/revoke.md @@ -12,6 +12,6 @@ const result = await oauth2.revoke({ token: '', tokenTypeHint: 'access_token', // optional clientId: '', // optional - clientSecret: '' // optional + clientSecret: '', // optional }); ``` diff --git a/docs/examples/organization/create-installation.md b/docs/examples/organization/create-installation.md index 56558fd0..b9e6c27c 100644 --- a/docs/examples/organization/create-installation.md +++ b/docs/examples/organization/create-installation.md @@ -10,6 +10,6 @@ const organization = new sdk.Organization(client); const result = await organization.createInstallation({ appId: '', - authorizationDetails: '' // optional + authorizationDetails: '', // optional }); ``` diff --git a/docs/examples/organization/create-key.md b/docs/examples/organization/create-key.md index b4e06acf..c4183dc4 100644 --- a/docs/examples/organization/create-key.md +++ b/docs/examples/organization/create-key.md @@ -12,6 +12,6 @@ const result = await organization.createKey({ keyId: '', name: '', scopes: [sdk.OrganizationKeyScopes.ProjectsRead], - expire: '2020-10-15T06:38:00.000+00:00' // optional + expire: '2020-10-15T06:38:00.000+00:00', // optional }); ``` diff --git a/docs/examples/organization/create-membership.md b/docs/examples/organization/create-membership.md index 02450ab2..dbc5be91 100644 --- a/docs/examples/organization/create-membership.md +++ b/docs/examples/organization/create-membership.md @@ -14,6 +14,6 @@ const result = await organization.createMembership({ userId: '', // optional phone: '+12065550100', // optional url: 'https://example.com', // optional - name: '' // optional + name: '', // optional }); ``` diff --git a/docs/examples/organization/create-project.md b/docs/examples/organization/create-project.md index 0c4547c5..686773cc 100644 --- a/docs/examples/organization/create-project.md +++ b/docs/examples/organization/create-project.md @@ -9,8 +9,8 @@ const client = new sdk.Client() const organization = new sdk.Organization(client); const result = await organization.createProject({ - projectId: '', + projectId: '', name: '', - region: sdk.Region.Fra // optional + region: sdk.Region.Fra, // optional }); ``` diff --git a/docs/examples/organization/delete-installation.md b/docs/examples/organization/delete-installation.md index afc3be5a..c48c79c0 100644 --- a/docs/examples/organization/delete-installation.md +++ b/docs/examples/organization/delete-installation.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const organization = new sdk.Organization(client); const result = await organization.deleteInstallation({ - installationId: '' + installationId: '', }); ``` diff --git a/docs/examples/organization/delete-key.md b/docs/examples/organization/delete-key.md index c3bce992..5cdd4e02 100644 --- a/docs/examples/organization/delete-key.md +++ b/docs/examples/organization/delete-key.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const organization = new sdk.Organization(client); const result = await organization.deleteKey({ - keyId: '' + keyId: '', }); ``` diff --git a/docs/examples/organization/delete-membership.md b/docs/examples/organization/delete-membership.md index 174ffc3c..3a5c9190 100644 --- a/docs/examples/organization/delete-membership.md +++ b/docs/examples/organization/delete-membership.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const organization = new sdk.Organization(client); const result = await organization.deleteMembership({ - membershipId: '' + membershipId: '', }); ``` diff --git a/docs/examples/organization/delete-project.md b/docs/examples/organization/delete-project.md index 01b3b845..fcc24c80 100644 --- a/docs/examples/organization/delete-project.md +++ b/docs/examples/organization/delete-project.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const organization = new sdk.Organization(client); const result = await organization.deleteProject({ - projectId: '' + projectId: '', }); ``` diff --git a/docs/examples/organization/get-installation.md b/docs/examples/organization/get-installation.md index e5ed10ee..d48c35c1 100644 --- a/docs/examples/organization/get-installation.md +++ b/docs/examples/organization/get-installation.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const organization = new sdk.Organization(client); const result = await organization.getInstallation({ - installationId: '' + installationId: '', }); ``` diff --git a/docs/examples/organization/get-key.md b/docs/examples/organization/get-key.md index 13317b6a..84551aee 100644 --- a/docs/examples/organization/get-key.md +++ b/docs/examples/organization/get-key.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const organization = new sdk.Organization(client); const result = await organization.getKey({ - keyId: '' + keyId: '', }); ``` diff --git a/docs/examples/organization/get-membership.md b/docs/examples/organization/get-membership.md index 42f60701..e7f31712 100644 --- a/docs/examples/organization/get-membership.md +++ b/docs/examples/organization/get-membership.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const organization = new sdk.Organization(client); const result = await organization.getMembership({ - membershipId: '' + membershipId: '', }); ``` diff --git a/docs/examples/organization/get-project.md b/docs/examples/organization/get-project.md index 85576d62..a4410967 100644 --- a/docs/examples/organization/get-project.md +++ b/docs/examples/organization/get-project.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const organization = new sdk.Organization(client); const result = await organization.getProject({ - projectId: '' + projectId: '', }); ``` diff --git a/docs/examples/organization/list-installations.md b/docs/examples/organization/list-installations.md index 91f6b666..2488802e 100644 --- a/docs/examples/organization/list-installations.md +++ b/docs/examples/organization/list-installations.md @@ -10,6 +10,6 @@ const organization = new sdk.Organization(client); const result = await organization.listInstallations({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/organization/list-keys.md b/docs/examples/organization/list-keys.md index 61348e5a..d6765709 100644 --- a/docs/examples/organization/list-keys.md +++ b/docs/examples/organization/list-keys.md @@ -10,6 +10,6 @@ const organization = new sdk.Organization(client); const result = await organization.listKeys({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/organization/list-memberships.md b/docs/examples/organization/list-memberships.md index 594cfd1b..12861589 100644 --- a/docs/examples/organization/list-memberships.md +++ b/docs/examples/organization/list-memberships.md @@ -11,6 +11,6 @@ const organization = new sdk.Organization(client); const result = await organization.listMemberships({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/organization/list-projects.md b/docs/examples/organization/list-projects.md index fa7f9c00..e883082d 100644 --- a/docs/examples/organization/list-projects.md +++ b/docs/examples/organization/list-projects.md @@ -11,6 +11,6 @@ const organization = new sdk.Organization(client); const result = await organization.listProjects({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/organization/update-installation.md b/docs/examples/organization/update-installation.md index 59ccac7b..24ba74dc 100644 --- a/docs/examples/organization/update-installation.md +++ b/docs/examples/organization/update-installation.md @@ -10,6 +10,6 @@ const organization = new sdk.Organization(client); const result = await organization.updateInstallation({ installationId: '', - authorizationDetails: '' // optional + authorizationDetails: '', // optional }); ``` diff --git a/docs/examples/organization/update-key.md b/docs/examples/organization/update-key.md index ade0116e..cca30fd1 100644 --- a/docs/examples/organization/update-key.md +++ b/docs/examples/organization/update-key.md @@ -12,6 +12,6 @@ const result = await organization.updateKey({ keyId: '', name: '', scopes: [sdk.OrganizationKeyScopes.ProjectsRead], - expire: '2020-10-15T06:38:00.000+00:00' // optional + expire: '2020-10-15T06:38:00.000+00:00', // optional }); ``` diff --git a/docs/examples/organization/update-membership.md b/docs/examples/organization/update-membership.md index 17d7e174..1898509f 100644 --- a/docs/examples/organization/update-membership.md +++ b/docs/examples/organization/update-membership.md @@ -10,6 +10,6 @@ const organization = new sdk.Organization(client); const result = await organization.updateMembership({ membershipId: '', - roles: [] + roles: [], }); ``` diff --git a/docs/examples/organization/update-project.md b/docs/examples/organization/update-project.md index f457ec2e..5daee821 100644 --- a/docs/examples/organization/update-project.md +++ b/docs/examples/organization/update-project.md @@ -10,6 +10,6 @@ const organization = new sdk.Organization(client); const result = await organization.updateProject({ projectId: '', - name: '' + name: '', }); ``` diff --git a/docs/examples/organization/update.md b/docs/examples/organization/update.md index 21485ef8..c06253b4 100644 --- a/docs/examples/organization/update.md +++ b/docs/examples/organization/update.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const organization = new sdk.Organization(client); const result = await organization.update({ - name: '' + name: '', }); ``` diff --git a/docs/examples/postgresql/create-backup-policy.md b/docs/examples/postgresql/create-backup-policy.md new file mode 100644 index 00000000..be7e3a27 --- /dev/null +++ b/docs/examples/postgresql/create-backup-policy.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.createBackupPolicy({ + databaseId: '', + policyId: '', + name: '', + schedule: '', + retention: 1, + type: 'full', // optional + enabled: false, // optional +}); +``` diff --git a/docs/examples/postgresql/create-backup.md b/docs/examples/postgresql/create-backup.md new file mode 100644 index 00000000..77115813 --- /dev/null +++ b/docs/examples/postgresql/create-backup.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.createBackup({ + databaseId: '', + type: 'full', // optional +}); +``` diff --git a/docs/examples/postgresql/create-branch.md b/docs/examples/postgresql/create-branch.md new file mode 100644 index 00000000..e0bcb7be --- /dev/null +++ b/docs/examples/postgresql/create-branch.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.createBranch({ + databaseId: '', + branchId: '', // optional + ttl: 300, // optional +}); +``` diff --git a/docs/examples/postgresql/create-execution.md b/docs/examples/postgresql/create-execution.md new file mode 100644 index 00000000..28d8a93c --- /dev/null +++ b/docs/examples/postgresql/create-execution.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.createExecution({ + databaseId: '', + sql: '', + bindings: {}, // optional + timeoutSeconds: 1, // optional +}); +``` diff --git a/docs/examples/postgresql/create-extension.md b/docs/examples/postgresql/create-extension.md new file mode 100644 index 00000000..106c8279 --- /dev/null +++ b/docs/examples/postgresql/create-extension.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.createExtension({ + databaseId: '', + name: '', +}); +``` diff --git a/docs/examples/postgresql/create-failover.md b/docs/examples/postgresql/create-failover.md new file mode 100644 index 00000000..8dccf712 --- /dev/null +++ b/docs/examples/postgresql/create-failover.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.createFailover({ + databaseId: '', + targetReplicaId: '', // optional +}); +``` diff --git a/docs/examples/postgresql/create-migration.md b/docs/examples/postgresql/create-migration.md new file mode 100644 index 00000000..6f9629d1 --- /dev/null +++ b/docs/examples/postgresql/create-migration.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.createMigration({ + databaseId: '', + targetType: 'shared', + specification: '', // optional +}); +``` diff --git a/docs/examples/postgresql/create-restoration.md b/docs/examples/postgresql/create-restoration.md new file mode 100644 index 00000000..5cc8ea05 --- /dev/null +++ b/docs/examples/postgresql/create-restoration.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.createRestoration({ + databaseId: '', + type: 'backup', // optional + backupId: '', // optional + targetDatabaseId: '', // optional + targetTime: '2020-10-15T06:38:00.000+00:00', // optional +}); +``` diff --git a/docs/examples/postgresql/create-upgrade.md b/docs/examples/postgresql/create-upgrade.md new file mode 100644 index 00000000..018f1e72 --- /dev/null +++ b/docs/examples/postgresql/create-upgrade.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.createUpgrade({ + databaseId: '', + targetVersion: '', +}); +``` diff --git a/docs/examples/postgresql/create.md b/docs/examples/postgresql/create.md new file mode 100644 index 00000000..90f66cb9 --- /dev/null +++ b/docs/examples/postgresql/create.md @@ -0,0 +1,27 @@ +```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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.create({ + databaseId: '', + name: '', + version: '17', // optional + specification: '', // optional + replicas: 0, // optional + syncMode: 'async', // optional + networkIdleTimeoutSeconds: 60, // optional + networkIPAllowlist: [], // optional + idleTimeoutMinutes: 5, // optional + pitr: false, // optional + pitrRetentionDays: 1, // optional + storageAutoscaling: false, // optional + storageAutoscalingThresholdPercent: 50, // optional + storageAutoscalingMaxGb: 0, // optional +}); +``` diff --git a/docs/examples/postgresql/delete-backup-policy.md b/docs/examples/postgresql/delete-backup-policy.md new file mode 100644 index 00000000..0b19db37 --- /dev/null +++ b/docs/examples/postgresql/delete-backup-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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.deleteBackupPolicy({ + databaseId: '', + policyId: '', +}); +``` diff --git a/docs/examples/postgresql/delete-backup.md b/docs/examples/postgresql/delete-backup.md new file mode 100644 index 00000000..2574a4b8 --- /dev/null +++ b/docs/examples/postgresql/delete-backup.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.deleteBackup({ + databaseId: '', + backupId: '', +}); +``` diff --git a/docs/examples/postgresql/delete-branch.md b/docs/examples/postgresql/delete-branch.md new file mode 100644 index 00000000..dc4778b8 --- /dev/null +++ b/docs/examples/postgresql/delete-branch.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.deleteBranch({ + databaseId: '', + branchId: '', +}); +``` diff --git a/docs/examples/postgresql/delete-extension.md b/docs/examples/postgresql/delete-extension.md new file mode 100644 index 00000000..470cd12c --- /dev/null +++ b/docs/examples/postgresql/delete-extension.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.deleteExtension({ + databaseId: '', + extensionName: '', +}); +``` diff --git a/docs/examples/postgresql/delete.md b/docs/examples/postgresql/delete.md new file mode 100644 index 00000000..c3677020 --- /dev/null +++ b/docs/examples/postgresql/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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.delete({ + databaseId: '', +}); +``` diff --git a/docs/examples/postgresql/get-backup-policy.md b/docs/examples/postgresql/get-backup-policy.md new file mode 100644 index 00000000..cf54b34c --- /dev/null +++ b/docs/examples/postgresql/get-backup-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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.getBackupPolicy({ + databaseId: '', + policyId: '', +}); +``` diff --git a/docs/examples/postgresql/get-backup.md b/docs/examples/postgresql/get-backup.md new file mode 100644 index 00000000..419acb97 --- /dev/null +++ b/docs/examples/postgresql/get-backup.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.getBackup({ + databaseId: '', + backupId: '', +}); +``` diff --git a/docs/examples/postgresql/get-pitr.md b/docs/examples/postgresql/get-pitr.md new file mode 100644 index 00000000..1032b3ca --- /dev/null +++ b/docs/examples/postgresql/get-pitr.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.getPitr({ + databaseId: '', +}); +``` diff --git a/docs/examples/postgresql/get-pooler.md b/docs/examples/postgresql/get-pooler.md new file mode 100644 index 00000000..a06ae6d2 --- /dev/null +++ b/docs/examples/postgresql/get-pooler.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.getPooler({ + databaseId: '', +}); +``` diff --git a/docs/examples/postgresql/get-replicas.md b/docs/examples/postgresql/get-replicas.md new file mode 100644 index 00000000..b0c52c0e --- /dev/null +++ b/docs/examples/postgresql/get-replicas.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.getReplicas({ + databaseId: '', +}); +``` diff --git a/docs/examples/postgresql/get-restoration.md b/docs/examples/postgresql/get-restoration.md new file mode 100644 index 00000000..593f710d --- /dev/null +++ b/docs/examples/postgresql/get-restoration.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.getRestoration({ + databaseId: '', + restorationId: '', +}); +``` diff --git a/docs/examples/postgresql/get-status.md b/docs/examples/postgresql/get-status.md new file mode 100644 index 00000000..0f6d7e99 --- /dev/null +++ b/docs/examples/postgresql/get-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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.getStatus({ + databaseId: '', +}); +``` diff --git a/docs/examples/postgresql/get.md b/docs/examples/postgresql/get.md new file mode 100644 index 00000000..dc2d021d --- /dev/null +++ b/docs/examples/postgresql/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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.get({ + databaseId: '', +}); +``` diff --git a/docs/examples/postgresql/list-backup-policies.md b/docs/examples/postgresql/list-backup-policies.md new file mode 100644 index 00000000..281577f7 --- /dev/null +++ b/docs/examples/postgresql/list-backup-policies.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.listBackupPolicies({ + databaseId: '', + queries: [], // optional +}); +``` diff --git a/docs/examples/postgresql/list-backups.md b/docs/examples/postgresql/list-backups.md new file mode 100644 index 00000000..183fd59c --- /dev/null +++ b/docs/examples/postgresql/list-backups.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.listBackups({ + databaseId: '', + queries: [], // optional +}); +``` diff --git a/docs/examples/postgresql/list-branches.md b/docs/examples/postgresql/list-branches.md new file mode 100644 index 00000000..bda35d2c --- /dev/null +++ b/docs/examples/postgresql/list-branches.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.listBranches({ + databaseId: '', +}); +``` diff --git a/docs/examples/postgresql/list-extensions.md b/docs/examples/postgresql/list-extensions.md new file mode 100644 index 00000000..9e363191 --- /dev/null +++ b/docs/examples/postgresql/list-extensions.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.listExtensions({ + databaseId: '', +}); +``` diff --git a/docs/examples/postgresql/list-operations.md b/docs/examples/postgresql/list-operations.md new file mode 100644 index 00000000..3c118349 --- /dev/null +++ b/docs/examples/postgresql/list-operations.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.listOperations({ + databaseId: '', + status: 'queued', // optional + limit: 1, // optional + offset: 0, // optional +}); +``` diff --git a/docs/examples/postgresql/list-restorations.md b/docs/examples/postgresql/list-restorations.md new file mode 100644 index 00000000..9ee58d27 --- /dev/null +++ b/docs/examples/postgresql/list-restorations.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.listRestorations({ + databaseId: '', + status: 'pending', // optional + type: 'backup', // optional + limit: 1, // optional + offset: 0, // optional +}); +``` diff --git a/docs/examples/postgresql/list-specifications.md b/docs/examples/postgresql/list-specifications.md new file mode 100644 index 00000000..14b5b5d7 --- /dev/null +++ b/docs/examples/postgresql/list-specifications.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 + .setKey(''); // Your secret API key + +const postgresql = new sdk.Postgresql(client); + +const result = await postgresql.listSpecifications(); +``` diff --git a/docs/examples/postgresql/list.md b/docs/examples/postgresql/list.md new file mode 100644 index 00000000..4a6597b7 --- /dev/null +++ b/docs/examples/postgresql/list.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.list({ + queries: [], // optional +}); +``` diff --git a/docs/examples/postgresql/update-backup-policy.md b/docs/examples/postgresql/update-backup-policy.md new file mode 100644 index 00000000..9914a6ec --- /dev/null +++ b/docs/examples/postgresql/update-backup-policy.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.updateBackupPolicy({ + databaseId: '', + policyId: '', + name: '', // optional + schedule: '', // optional + retention: 1, // optional + enabled: false, // optional +}); +``` diff --git a/docs/examples/postgresql/update-backup-storage.md b/docs/examples/postgresql/update-backup-storage.md new file mode 100644 index 00000000..83ae700c --- /dev/null +++ b/docs/examples/postgresql/update-backup-storage.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.updateBackupStorage({ + databaseId: '', + provider: 's3', + bucket: '', + accessKey: '', + secretKey: '', + region: '', // optional + prefix: '', // optional + endpoint: '', // optional +}); +``` diff --git a/docs/examples/postgresql/update-credentials.md b/docs/examples/postgresql/update-credentials.md new file mode 100644 index 00000000..26898b61 --- /dev/null +++ b/docs/examples/postgresql/update-credentials.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.updateCredentials({ + databaseId: '', +}); +``` diff --git a/docs/examples/postgresql/update-maintenance.md b/docs/examples/postgresql/update-maintenance.md new file mode 100644 index 00000000..da5a12bd --- /dev/null +++ b/docs/examples/postgresql/update-maintenance.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.updateMaintenance({ + databaseId: '', + day: 'sun', + hourUtc: 0, +}); +``` diff --git a/docs/examples/postgresql/update-pooler.md b/docs/examples/postgresql/update-pooler.md new file mode 100644 index 00000000..e09e1d8a --- /dev/null +++ b/docs/examples/postgresql/update-pooler.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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.updatePooler({ + databaseId: '', + mode: 'transaction', // optional + maxConnections: 10, // optional + defaultPoolSize: 1, // optional + readWriteSplitting: false, // optional + poolerCpuRequest: '', // optional + poolerCpuLimit: '', // optional + poolerMemoryRequest: '', // optional + poolerMemoryLimit: '', // optional +}); +``` diff --git a/docs/examples/postgresql/update.md b/docs/examples/postgresql/update.md new file mode 100644 index 00000000..87de3f94 --- /dev/null +++ b/docs/examples/postgresql/update.md @@ -0,0 +1,34 @@ +```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 postgresql = new sdk.Postgresql(client); + +const result = await postgresql.update({ + databaseId: '', + name: '', // optional + status: 'ready', // optional + specification: '', // optional + replicas: 0, // optional + syncMode: 'async', // optional + networkIdleTimeoutSeconds: 60, // optional + networkIPAllowlist: [], // optional + idleTimeoutMinutes: 5, // optional + pitr: false, // optional + pitrRetentionDays: 1, // optional + storageAutoscaling: false, // optional + storageAutoscalingThresholdPercent: 50, // optional + storageAutoscalingMaxGb: 0, // optional + metricsTraceSampleRate: null, // optional + metricsSlowQueryLogThresholdMs: 0, // optional + sqlApiEnabled: false, // optional + sqlApiAllowedStatements: [], // optional + sqlApiMaxRows: 1, // optional + sqlApiMaxBytes: 1024, // optional + sqlApiTimeoutSeconds: 1, // optional +}); +``` diff --git a/docs/examples/presences/delete.md b/docs/examples/presences/delete.md index 4c1cfc24..866d674b 100644 --- a/docs/examples/presences/delete.md +++ b/docs/examples/presences/delete.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const presences = new sdk.Presences(client); const result = await presences.delete({ - presenceId: '' + presenceId: '', }); ``` diff --git a/docs/examples/presences/get.md b/docs/examples/presences/get.md index 1e8a332d..76aee598 100644 --- a/docs/examples/presences/get.md +++ b/docs/examples/presences/get.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const presences = new sdk.Presences(client); const result = await presences.get({ - presenceId: '' + presenceId: '', }); ``` diff --git a/docs/examples/presences/list.md b/docs/examples/presences/list.md index fbb18d4d..cd6e51d6 100644 --- a/docs/examples/presences/list.md +++ b/docs/examples/presences/list.md @@ -11,6 +11,6 @@ const presences = new sdk.Presences(client); const result = await presences.list({ queries: [], // optional total: false, // optional - ttl: 0 // optional + ttl: 0, // optional }); ``` diff --git a/docs/examples/presences/update.md b/docs/examples/presences/update.md index 0056a50c..e456487c 100644 --- a/docs/examples/presences/update.md +++ b/docs/examples/presences/update.md @@ -15,6 +15,6 @@ const result = await presences.update({ expiresAt: '2020-10-15T06:38:00.000+00:00', // optional metadata: {}, // optional permissions: [sdk.Permission.read(sdk.Role.any())], // optional - purge: false // optional + purge: false, // optional }); ``` diff --git a/docs/examples/presences/upsert.md b/docs/examples/presences/upsert.md index 63b9267f..646cab86 100644 --- a/docs/examples/presences/upsert.md +++ b/docs/examples/presences/upsert.md @@ -14,6 +14,6 @@ const result = await presences.upsert({ status: '', permissions: [sdk.Permission.read(sdk.Role.any())], // optional expiresAt: '2020-10-15T06:38:00.000+00:00', // optional - metadata: {} // optional + metadata: {}, // optional }); ``` diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md index 09a9f337..083eee14 100644 --- a/docs/examples/project/create-android-platform.md +++ b/docs/examples/project/create-android-platform.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.createAndroidPlatform({ platformId: '', name: '', - applicationId: '' + applicationId: '', }); ``` diff --git a/docs/examples/project/create-apple-platform.md b/docs/examples/project/create-apple-platform.md index 6ffe87b7..544e3068 100644 --- a/docs/examples/project/create-apple-platform.md +++ b/docs/examples/project/create-apple-platform.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.createApplePlatform({ platformId: '', name: '', - bundleIdentifier: '' + bundleIdentifier: '', }); ``` diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index e368a605..352c6316 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -10,6 +10,6 @@ const project = new sdk.Project(client); const result = await project.createEphemeralKey({ scopes: [sdk.ProjectKeyScopes.ProjectRead], - duration: 600 + duration: 600, }); ``` diff --git a/docs/examples/project/create-linux-platform.md b/docs/examples/project/create-linux-platform.md index aa51173c..7555da38 100644 --- a/docs/examples/project/create-linux-platform.md +++ b/docs/examples/project/create-linux-platform.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.createLinuxPlatform({ platformId: '', name: '', - packageName: '' + packageName: '', }); ``` diff --git a/docs/examples/project/create-mock-phone.md b/docs/examples/project/create-mock-phone.md index 6bb2962c..74fc6399 100644 --- a/docs/examples/project/create-mock-phone.md +++ b/docs/examples/project/create-mock-phone.md @@ -10,6 +10,6 @@ const project = new sdk.Project(client); const result = await project.createMockPhone({ number: '+12065550100', - otp: '' + otp: '', }); ``` diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index 708daf85..0246650b 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.createSMTPTest({ - emails: [] + emails: [], }); ``` diff --git a/docs/examples/project/create-variable.md b/docs/examples/project/create-variable.md index 6333b935..3f06a9e6 100644 --- a/docs/examples/project/create-variable.md +++ b/docs/examples/project/create-variable.md @@ -12,6 +12,6 @@ const result = await project.createVariable({ variableId: '', key: '', value: '', - secret: false // optional + secret: false, // optional }); ``` diff --git a/docs/examples/project/create-web-platform.md b/docs/examples/project/create-web-platform.md index 84e36ce1..50ae6db8 100644 --- a/docs/examples/project/create-web-platform.md +++ b/docs/examples/project/create-web-platform.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.createWebPlatform({ platformId: '', name: '', - hostname: 'app.example.com' + hostname: 'app.example.com', }); ``` diff --git a/docs/examples/project/create-windows-platform.md b/docs/examples/project/create-windows-platform.md index 369f0349..4bc666e0 100644 --- a/docs/examples/project/create-windows-platform.md +++ b/docs/examples/project/create-windows-platform.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.createWindowsPlatform({ platformId: '', name: '', - packageIdentifierName: '' + packageIdentifierName: '', }); ``` diff --git a/docs/examples/project/delete-key.md b/docs/examples/project/delete-key.md index bbe19c2a..10013221 100644 --- a/docs/examples/project/delete-key.md +++ b/docs/examples/project/delete-key.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.deleteKey({ - keyId: '' + keyId: '', }); ``` diff --git a/docs/examples/project/delete-mock-phone.md b/docs/examples/project/delete-mock-phone.md index 94d341a7..7270f738 100644 --- a/docs/examples/project/delete-mock-phone.md +++ b/docs/examples/project/delete-mock-phone.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.deleteMockPhone({ - number: '+12065550100' + number: '+12065550100', }); ``` diff --git a/docs/examples/project/delete-platform.md b/docs/examples/project/delete-platform.md index cb734805..f1cd0a9f 100644 --- a/docs/examples/project/delete-platform.md +++ b/docs/examples/project/delete-platform.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.deletePlatform({ - platformId: '' + platformId: '', }); ``` diff --git a/docs/examples/project/delete-variable.md b/docs/examples/project/delete-variable.md index c930811b..9db9b3a2 100644 --- a/docs/examples/project/delete-variable.md +++ b/docs/examples/project/delete-variable.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.deleteVariable({ - variableId: '' + variableId: '', }); ``` diff --git a/docs/examples/project/get-email-template.md b/docs/examples/project/get-email-template.md index d4683e56..5645f405 100644 --- a/docs/examples/project/get-email-template.md +++ b/docs/examples/project/get-email-template.md @@ -10,6 +10,6 @@ const project = new sdk.Project(client); const result = await project.getEmailTemplate({ templateId: sdk.ProjectEmailTemplateId.Verification, - locale: sdk.ProjectEmailTemplateLocale.Af // optional + locale: sdk.ProjectEmailTemplateLocale.Af, // optional }); ``` diff --git a/docs/examples/project/get-key.md b/docs/examples/project/get-key.md index 81b7e2f1..ef42cd15 100644 --- a/docs/examples/project/get-key.md +++ b/docs/examples/project/get-key.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.getKey({ - keyId: '' + keyId: '', }); ``` diff --git a/docs/examples/project/get-mock-phone.md b/docs/examples/project/get-mock-phone.md index 73082c43..d17069d9 100644 --- a/docs/examples/project/get-mock-phone.md +++ b/docs/examples/project/get-mock-phone.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.getMockPhone({ - number: '+12065550100' + number: '+12065550100', }); ``` diff --git a/docs/examples/project/get-o-auth-2-provider.md b/docs/examples/project/get-o-auth-2-provider.md index 7c1d85c5..94012a51 100644 --- a/docs/examples/project/get-o-auth-2-provider.md +++ b/docs/examples/project/get-o-auth-2-provider.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.getOAuth2Provider({ - providerId: sdk.ProjectOAuthProviderId.Amazon + providerId: sdk.ProjectOAuthProviderId.Amazon, }); ``` diff --git a/docs/examples/project/get-platform.md b/docs/examples/project/get-platform.md index 4f450e4b..bfebc6b5 100644 --- a/docs/examples/project/get-platform.md +++ b/docs/examples/project/get-platform.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.getPlatform({ - platformId: '' + platformId: '', }); ``` diff --git a/docs/examples/project/get-policy.md b/docs/examples/project/get-policy.md index e55cb859..03e43274 100644 --- a/docs/examples/project/get-policy.md +++ b/docs/examples/project/get-policy.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.getPolicy({ - policyId: sdk.ProjectPolicyId.PasswordDictionary + policyId: sdk.ProjectPolicyId.PasswordDictionary, }); ``` diff --git a/docs/examples/project/get-variable.md b/docs/examples/project/get-variable.md index 5232de86..951e5d44 100644 --- a/docs/examples/project/get-variable.md +++ b/docs/examples/project/get-variable.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.getVariable({ - variableId: '' + variableId: '', }); ``` diff --git a/docs/examples/project/list-email-templates.md b/docs/examples/project/list-email-templates.md index 34bc7778..54c3cea2 100644 --- a/docs/examples/project/list-email-templates.md +++ b/docs/examples/project/list-email-templates.md @@ -10,6 +10,6 @@ const project = new sdk.Project(client); const result = await project.listEmailTemplates({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/project/list-keys.md b/docs/examples/project/list-keys.md index e9266822..e0890bd6 100644 --- a/docs/examples/project/list-keys.md +++ b/docs/examples/project/list-keys.md @@ -10,6 +10,6 @@ const project = new sdk.Project(client); const result = await project.listKeys({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/project/list-mock-phones.md b/docs/examples/project/list-mock-phones.md index 0816b18a..024b551b 100644 --- a/docs/examples/project/list-mock-phones.md +++ b/docs/examples/project/list-mock-phones.md @@ -10,6 +10,6 @@ const project = new sdk.Project(client); const result = await project.listMockPhones({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/project/list-o-auth-2-providers.md b/docs/examples/project/list-o-auth-2-providers.md index 244767d3..50adaa04 100644 --- a/docs/examples/project/list-o-auth-2-providers.md +++ b/docs/examples/project/list-o-auth-2-providers.md @@ -10,6 +10,6 @@ const project = new sdk.Project(client); const result = await project.listOAuth2Providers({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/project/list-platforms.md b/docs/examples/project/list-platforms.md index c180b9d7..fc26d4e4 100644 --- a/docs/examples/project/list-platforms.md +++ b/docs/examples/project/list-platforms.md @@ -10,6 +10,6 @@ const project = new sdk.Project(client); const result = await project.listPlatforms({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/project/list-policies.md b/docs/examples/project/list-policies.md index f7b6260f..971552b4 100644 --- a/docs/examples/project/list-policies.md +++ b/docs/examples/project/list-policies.md @@ -10,6 +10,6 @@ const project = new sdk.Project(client); const result = await project.listPolicies({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/project/list-variables.md b/docs/examples/project/list-variables.md index 3ffd1b95..6f505250 100644 --- a/docs/examples/project/list-variables.md +++ b/docs/examples/project/list-variables.md @@ -10,6 +10,6 @@ const project = new sdk.Project(client); const result = await project.listVariables({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md index 8164b0d0..ad0d3d28 100644 --- a/docs/examples/project/update-android-platform.md +++ b/docs/examples/project/update-android-platform.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateAndroidPlatform({ platformId: '', name: '', - applicationId: '' + applicationId: '', }); ``` diff --git a/docs/examples/project/update-apple-platform.md b/docs/examples/project/update-apple-platform.md index 93abb676..7170be87 100644 --- a/docs/examples/project/update-apple-platform.md +++ b/docs/examples/project/update-apple-platform.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateApplePlatform({ platformId: '', name: '', - bundleIdentifier: '' + bundleIdentifier: '', }); ``` diff --git a/docs/examples/project/update-auth-method.md b/docs/examples/project/update-auth-method.md index 8e2e4bbb..1994e2cb 100644 --- a/docs/examples/project/update-auth-method.md +++ b/docs/examples/project/update-auth-method.md @@ -10,6 +10,6 @@ const project = new sdk.Project(client); const result = await project.updateAuthMethod({ methodId: sdk.ProjectAuthMethodId.EmailPassword, - enabled: false + enabled: false, }); ``` diff --git a/docs/examples/project/update-deny-aliased-email-policy.md b/docs/examples/project/update-deny-aliased-email-policy.md index 92b7e648..61b96ceb 100644 --- a/docs/examples/project/update-deny-aliased-email-policy.md +++ b/docs/examples/project/update-deny-aliased-email-policy.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.updateDenyAliasedEmailPolicy({ - enabled: false + enabled: false, }); ``` diff --git a/docs/examples/project/update-deny-corporate-email-policy.md b/docs/examples/project/update-deny-corporate-email-policy.md index 8335b8e9..c1b8c9fa 100644 --- a/docs/examples/project/update-deny-corporate-email-policy.md +++ b/docs/examples/project/update-deny-corporate-email-policy.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.updateDenyCorporateEmailPolicy({ - enabled: false + enabled: false, }); ``` diff --git a/docs/examples/project/update-deny-disposable-email-policy.md b/docs/examples/project/update-deny-disposable-email-policy.md index e2b25316..b707e5a6 100644 --- a/docs/examples/project/update-deny-disposable-email-policy.md +++ b/docs/examples/project/update-deny-disposable-email-policy.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.updateDenyDisposableEmailPolicy({ - enabled: false + enabled: false, }); ``` diff --git a/docs/examples/project/update-deny-free-email-policy.md b/docs/examples/project/update-deny-free-email-policy.md index 85799e8e..07b5e68b 100644 --- a/docs/examples/project/update-deny-free-email-policy.md +++ b/docs/examples/project/update-deny-free-email-policy.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.updateDenyFreeEmailPolicy({ - enabled: false + enabled: false, }); ``` diff --git a/docs/examples/project/update-email-template.md b/docs/examples/project/update-email-template.md index ddf6ca67..ae145041 100644 --- a/docs/examples/project/update-email-template.md +++ b/docs/examples/project/update-email-template.md @@ -16,6 +16,6 @@ const result = await project.updateEmailTemplate({ senderName: '', // optional senderEmail: 'email@example.com', // optional replyToEmail: 'email@example.com', // optional - replyToName: '' // optional + replyToName: '', // optional }); ``` diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index 39be329e..0505a54f 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -12,6 +12,6 @@ const result = await project.updateKey({ keyId: '', name: '', scopes: [sdk.ProjectKeyScopes.ProjectRead], - expire: '2020-10-15T06:38:00.000+00:00' // optional + expire: '2020-10-15T06:38:00.000+00:00', // optional }); ``` diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index f924ec09..1d58ef1c 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.updateLabels({ - labels: [] + labels: [], }); ``` diff --git a/docs/examples/project/update-linux-platform.md b/docs/examples/project/update-linux-platform.md index cb483d60..b1459527 100644 --- a/docs/examples/project/update-linux-platform.md +++ b/docs/examples/project/update-linux-platform.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateLinuxPlatform({ platformId: '', name: '', - packageName: '' + packageName: '', }); ``` diff --git a/docs/examples/project/update-membership-privacy-policy.md b/docs/examples/project/update-membership-privacy-policy.md index 6fda0908..9f23b9a6 100644 --- a/docs/examples/project/update-membership-privacy-policy.md +++ b/docs/examples/project/update-membership-privacy-policy.md @@ -14,6 +14,6 @@ const result = await project.updateMembershipPrivacyPolicy({ userPhone: false, // optional userName: false, // optional userMFA: false, // optional - userAccessedAt: false // optional + userAccessedAt: false, // optional }); ``` diff --git a/docs/examples/project/update-mfa-factors-policy.md b/docs/examples/project/update-mfa-factors-policy.md index 5fea9961..1d9be8f2 100644 --- a/docs/examples/project/update-mfa-factors-policy.md +++ b/docs/examples/project/update-mfa-factors-policy.md @@ -12,6 +12,6 @@ const result = await project.updateMFAFactorsPolicy({ totp: false, // optional email: false, // optional phone: false, // optional - custom: false // optional + custom: false, // optional }); ``` diff --git a/docs/examples/project/update-mock-phone.md b/docs/examples/project/update-mock-phone.md index a0c70abc..1beb2683 100644 --- a/docs/examples/project/update-mock-phone.md +++ b/docs/examples/project/update-mock-phone.md @@ -10,6 +10,6 @@ const project = new sdk.Project(client); const result = await project.updateMockPhone({ number: '+12065550100', - otp: '' + otp: '', }); ``` diff --git a/docs/examples/project/update-o-auth-2-amazon.md b/docs/examples/project/update-o-auth-2-amazon.md index 12a535ff..a6ddbdb3 100644 --- a/docs/examples/project/update-o-auth-2-amazon.md +++ b/docs/examples/project/update-o-auth-2-amazon.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Amazon({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md index ae985a4a..7c6f5590 100644 --- a/docs/examples/project/update-o-auth-2-apple.md +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -13,6 +13,6 @@ const result = await project.updateOAuth2Apple({ keyId: '', // optional teamId: '', // optional p8File: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-appwrite.md b/docs/examples/project/update-o-auth-2-appwrite.md index 6a7df87e..b48ccbba 100644 --- a/docs/examples/project/update-o-auth-2-appwrite.md +++ b/docs/examples/project/update-o-auth-2-appwrite.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Appwrite({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: 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 37bf4a56..d23fb2c5 100644 --- a/docs/examples/project/update-o-auth-2-auth-0.md +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -12,6 +12,6 @@ const result = await project.updateOAuth2Auth0({ clientId: '', // optional clientSecret: '', // optional endpoint: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-authentik.md b/docs/examples/project/update-o-auth-2-authentik.md index e500466b..ab18b29d 100644 --- a/docs/examples/project/update-o-auth-2-authentik.md +++ b/docs/examples/project/update-o-auth-2-authentik.md @@ -12,6 +12,6 @@ const result = await project.updateOAuth2Authentik({ clientId: '', // optional clientSecret: '', // optional endpoint: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-autodesk.md b/docs/examples/project/update-o-auth-2-autodesk.md index 0b8aabce..e3be0081 100644 --- a/docs/examples/project/update-o-auth-2-autodesk.md +++ b/docs/examples/project/update-o-auth-2-autodesk.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Autodesk({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-bitbucket.md b/docs/examples/project/update-o-auth-2-bitbucket.md index d3b5dc7b..d521d53c 100644 --- a/docs/examples/project/update-o-auth-2-bitbucket.md +++ b/docs/examples/project/update-o-auth-2-bitbucket.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Bitbucket({ key: '', // optional secret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-bitly.md b/docs/examples/project/update-o-auth-2-bitly.md index feecad27..2c147174 100644 --- a/docs/examples/project/update-o-auth-2-bitly.md +++ b/docs/examples/project/update-o-auth-2-bitly.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Bitly({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-box.md b/docs/examples/project/update-o-auth-2-box.md index c9724638..87a23c1c 100644 --- a/docs/examples/project/update-o-auth-2-box.md +++ b/docs/examples/project/update-o-auth-2-box.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Box({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-dailymotion.md b/docs/examples/project/update-o-auth-2-dailymotion.md index 8d176339..16942aa2 100644 --- a/docs/examples/project/update-o-auth-2-dailymotion.md +++ b/docs/examples/project/update-o-auth-2-dailymotion.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Dailymotion({ apiKey: '', // optional apiSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md index 5469509f..151b93c1 100644 --- a/docs/examples/project/update-o-auth-2-discord.md +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Discord({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-disqus.md b/docs/examples/project/update-o-auth-2-disqus.md index c71bebfe..296d1e99 100644 --- a/docs/examples/project/update-o-auth-2-disqus.md +++ b/docs/examples/project/update-o-auth-2-disqus.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Disqus({ publicKey: '', // optional secretKey: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-dropbox.md b/docs/examples/project/update-o-auth-2-dropbox.md index 9f2654dc..913b3cf0 100644 --- a/docs/examples/project/update-o-auth-2-dropbox.md +++ b/docs/examples/project/update-o-auth-2-dropbox.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Dropbox({ appKey: '', // optional appSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-etsy.md b/docs/examples/project/update-o-auth-2-etsy.md index 684c4243..a0002893 100644 --- a/docs/examples/project/update-o-auth-2-etsy.md +++ b/docs/examples/project/update-o-auth-2-etsy.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Etsy({ keyString: '', // optional sharedSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-facebook.md b/docs/examples/project/update-o-auth-2-facebook.md index 7fca48a6..ed0b5316 100644 --- a/docs/examples/project/update-o-auth-2-facebook.md +++ b/docs/examples/project/update-o-auth-2-facebook.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Facebook({ appId: '', // optional appSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-figma.md b/docs/examples/project/update-o-auth-2-figma.md index 3b805738..a81d5b1d 100644 --- a/docs/examples/project/update-o-auth-2-figma.md +++ b/docs/examples/project/update-o-auth-2-figma.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Figma({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-fusion-auth.md b/docs/examples/project/update-o-auth-2-fusion-auth.md index 654991c9..fc33b5fd 100644 --- a/docs/examples/project/update-o-auth-2-fusion-auth.md +++ b/docs/examples/project/update-o-auth-2-fusion-auth.md @@ -12,6 +12,6 @@ const result = await project.updateOAuth2FusionAuth({ clientId: '', // optional clientSecret: '', // optional endpoint: '', // optional - enabled: false // optional + enabled: false, // 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 cc2be084..0a7a757d 100644 --- a/docs/examples/project/update-o-auth-2-git-hub.md +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2GitHub({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-gitlab.md b/docs/examples/project/update-o-auth-2-gitlab.md index 40e1943e..273c1bc8 100644 --- a/docs/examples/project/update-o-auth-2-gitlab.md +++ b/docs/examples/project/update-o-auth-2-gitlab.md @@ -12,6 +12,6 @@ const result = await project.updateOAuth2Gitlab({ applicationId: '', // optional secret: '', // optional endpoint: 'https://example.com', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md index 726d6059..17696bf7 100644 --- a/docs/examples/project/update-o-auth-2-google.md +++ b/docs/examples/project/update-o-auth-2-google.md @@ -12,6 +12,6 @@ const result = await project.updateOAuth2Google({ clientId: '', // optional clientSecret: '', // optional prompt: [sdk.ProjectOAuth2GooglePrompt.None], // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-hugging-face.md b/docs/examples/project/update-o-auth-2-hugging-face.md new file mode 100644 index 00000000..ca0acbe6 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-hugging-face.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.updateOAuth2HuggingFace({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false, // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-keycloak.md b/docs/examples/project/update-o-auth-2-keycloak.md index bce76ee5..542675b8 100644 --- a/docs/examples/project/update-o-auth-2-keycloak.md +++ b/docs/examples/project/update-o-auth-2-keycloak.md @@ -13,6 +13,6 @@ const result = await project.updateOAuth2Keycloak({ clientSecret: '', // optional endpoint: '', // optional realmName: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-kick.md b/docs/examples/project/update-o-auth-2-kick.md index 1d581052..88bebd74 100644 --- a/docs/examples/project/update-o-auth-2-kick.md +++ b/docs/examples/project/update-o-auth-2-kick.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Kick({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-linkedin.md b/docs/examples/project/update-o-auth-2-linkedin.md index 02c68d99..4e08e846 100644 --- a/docs/examples/project/update-o-auth-2-linkedin.md +++ b/docs/examples/project/update-o-auth-2-linkedin.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Linkedin({ clientId: '', // optional primaryClientSecret: '', // optional - enabled: false // 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 cc5a8c27..29e18697 100644 --- a/docs/examples/project/update-o-auth-2-microsoft.md +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -12,6 +12,6 @@ const result = await project.updateOAuth2Microsoft({ applicationId: '', // optional applicationSecret: '', // optional tenant: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-notion.md b/docs/examples/project/update-o-auth-2-notion.md index c3297799..84ccf7b5 100644 --- a/docs/examples/project/update-o-auth-2-notion.md +++ b/docs/examples/project/update-o-auth-2-notion.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Notion({ oauthClientId: '', // optional oauthClientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-oidc.md b/docs/examples/project/update-o-auth-2-oidc.md index 271afcff..6f345b23 100644 --- a/docs/examples/project/update-o-auth-2-oidc.md +++ b/docs/examples/project/update-o-auth-2-oidc.md @@ -17,6 +17,6 @@ const result = await project.updateOAuth2Oidc({ userInfoURL: 'https://example.com', // optional prompt: [sdk.ProjectOAuth2OidcPrompt.None], // optional maxAge: 0, // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md index a85c9809..519f0265 100644 --- a/docs/examples/project/update-o-auth-2-okta.md +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -11,8 +11,8 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Okta({ clientId: '', // optional clientSecret: '', // optional - domain: '', // optional + domain: 'example.com', // optional authorizationServerId: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-paypal-sandbox.md b/docs/examples/project/update-o-auth-2-paypal-sandbox.md index e6b8de7f..0abb7d7e 100644 --- a/docs/examples/project/update-o-auth-2-paypal-sandbox.md +++ b/docs/examples/project/update-o-auth-2-paypal-sandbox.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2PaypalSandbox({ clientId: '', // optional secretKey: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-paypal.md b/docs/examples/project/update-o-auth-2-paypal.md index 8f7162c7..1b989c82 100644 --- a/docs/examples/project/update-o-auth-2-paypal.md +++ b/docs/examples/project/update-o-auth-2-paypal.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Paypal({ clientId: '', // optional secretKey: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-podio.md b/docs/examples/project/update-o-auth-2-podio.md index 3d6c2c44..2da41643 100644 --- a/docs/examples/project/update-o-auth-2-podio.md +++ b/docs/examples/project/update-o-auth-2-podio.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Podio({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md index a1937639..642249f1 100644 --- a/docs/examples/project/update-o-auth-2-salesforce.md +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Salesforce({ customerKey: '', // optional customerSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-server.md b/docs/examples/project/update-o-auth-2-server.md index 2ea2f48a..4dc93051 100644 --- a/docs/examples/project/update-o-auth-2-server.md +++ b/docs/examples/project/update-o-auth-2-server.md @@ -24,6 +24,6 @@ const result = await project.updateOAuth2Server({ userCodeFormat: 'numeric', // optional deviceCodeDuration: 60, // optional defaultScopes: [], // optional - installationScopes: [] // optional + installationScopes: [], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-slack.md b/docs/examples/project/update-o-auth-2-slack.md index 6dab9092..dd9b6968 100644 --- a/docs/examples/project/update-o-auth-2-slack.md +++ b/docs/examples/project/update-o-auth-2-slack.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Slack({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-spotify.md b/docs/examples/project/update-o-auth-2-spotify.md index 72ffa64d..9144b697 100644 --- a/docs/examples/project/update-o-auth-2-spotify.md +++ b/docs/examples/project/update-o-auth-2-spotify.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Spotify({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-stripe.md b/docs/examples/project/update-o-auth-2-stripe.md index 1df015f1..4621803a 100644 --- a/docs/examples/project/update-o-auth-2-stripe.md +++ b/docs/examples/project/update-o-auth-2-stripe.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Stripe({ clientId: '', // optional apiSecretKey: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md b/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md index df090e92..1be4443f 100644 --- a/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md +++ b/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2TradeshiftSandbox({ oauth2ClientId: '', // optional oauth2ClientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-tradeshift.md b/docs/examples/project/update-o-auth-2-tradeshift.md index afddd8c0..0fe5c0fb 100644 --- a/docs/examples/project/update-o-auth-2-tradeshift.md +++ b/docs/examples/project/update-o-auth-2-tradeshift.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Tradeshift({ oauth2ClientId: '', // optional oauth2ClientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-twitch.md b/docs/examples/project/update-o-auth-2-twitch.md index ad096ea9..0cc817ca 100644 --- a/docs/examples/project/update-o-auth-2-twitch.md +++ b/docs/examples/project/update-o-auth-2-twitch.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Twitch({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-word-press.md b/docs/examples/project/update-o-auth-2-word-press.md index 597ccd5b..262989f1 100644 --- a/docs/examples/project/update-o-auth-2-word-press.md +++ b/docs/examples/project/update-o-auth-2-word-press.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2WordPress({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-yahoo.md b/docs/examples/project/update-o-auth-2-yahoo.md index 79b3b021..28534ef4 100644 --- a/docs/examples/project/update-o-auth-2-yahoo.md +++ b/docs/examples/project/update-o-auth-2-yahoo.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Yahoo({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-yandex.md b/docs/examples/project/update-o-auth-2-yandex.md index 2f79c448..2618e178 100644 --- a/docs/examples/project/update-o-auth-2-yandex.md +++ b/docs/examples/project/update-o-auth-2-yandex.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Yandex({ clientId: '', // optional clientSecret: '', // optional - enabled: false // 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 031a2816..8b623cd8 100644 --- a/docs/examples/project/update-o-auth-2-zoho.md +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Zoho({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-zoom.md b/docs/examples/project/update-o-auth-2-zoom.md index 985400b1..76d43262 100644 --- a/docs/examples/project/update-o-auth-2-zoom.md +++ b/docs/examples/project/update-o-auth-2-zoom.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Zoom({ clientId: '', // optional clientSecret: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2x.md b/docs/examples/project/update-o-auth-2x.md index 183e2257..4e37f134 100644 --- a/docs/examples/project/update-o-auth-2x.md +++ b/docs/examples/project/update-o-auth-2x.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2X({ customerKey: '', // optional secretKey: '', // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-password-dictionary-policy.md b/docs/examples/project/update-password-dictionary-policy.md index 8b8bdd02..859aa6ea 100644 --- a/docs/examples/project/update-password-dictionary-policy.md +++ b/docs/examples/project/update-password-dictionary-policy.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.updatePasswordDictionaryPolicy({ - enabled: false + enabled: false, }); ``` diff --git a/docs/examples/project/update-password-history-policy.md b/docs/examples/project/update-password-history-policy.md index b8ab9d03..e7c01853 100644 --- a/docs/examples/project/update-password-history-policy.md +++ b/docs/examples/project/update-password-history-policy.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.updatePasswordHistoryPolicy({ - total: 1 + total: 1, }); ``` diff --git a/docs/examples/project/update-password-personal-data-policy.md b/docs/examples/project/update-password-personal-data-policy.md index df490a4a..b0669c53 100644 --- a/docs/examples/project/update-password-personal-data-policy.md +++ b/docs/examples/project/update-password-personal-data-policy.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.updatePasswordPersonalDataPolicy({ - enabled: false + enabled: false, }); ``` diff --git a/docs/examples/project/update-password-strength-policy.md b/docs/examples/project/update-password-strength-policy.md index 3d2648df..9fc9359f 100644 --- a/docs/examples/project/update-password-strength-policy.md +++ b/docs/examples/project/update-password-strength-policy.md @@ -13,6 +13,6 @@ const result = await project.updatePasswordStrengthPolicy({ uppercase: false, // optional lowercase: false, // optional number: false, // optional - symbols: false // optional + symbols: false, // optional }); ``` diff --git a/docs/examples/project/update-protocol.md b/docs/examples/project/update-protocol.md index 373e9178..89d117e0 100644 --- a/docs/examples/project/update-protocol.md +++ b/docs/examples/project/update-protocol.md @@ -10,6 +10,6 @@ const project = new sdk.Project(client); const result = await project.updateProtocol({ protocolId: sdk.ProjectProtocolId.Rest, - enabled: false + enabled: false, }); ``` diff --git a/docs/examples/project/update-service.md b/docs/examples/project/update-service.md index ded8eb76..2140085c 100644 --- a/docs/examples/project/update-service.md +++ b/docs/examples/project/update-service.md @@ -10,6 +10,6 @@ const project = new sdk.Project(client); const result = await project.updateService({ serviceId: sdk.ProjectServiceId.Account, - enabled: false + enabled: false, }); ``` diff --git a/docs/examples/project/update-session-alert-policy.md b/docs/examples/project/update-session-alert-policy.md index 54546084..5a713438 100644 --- a/docs/examples/project/update-session-alert-policy.md +++ b/docs/examples/project/update-session-alert-policy.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.updateSessionAlertPolicy({ - enabled: false + enabled: false, }); ``` diff --git a/docs/examples/project/update-session-duration-policy.md b/docs/examples/project/update-session-duration-policy.md index 35ae13df..12544efe 100644 --- a/docs/examples/project/update-session-duration-policy.md +++ b/docs/examples/project/update-session-duration-policy.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.updateSessionDurationPolicy({ - duration: 60 + duration: 60, }); ``` diff --git a/docs/examples/project/update-session-invalidation-policy.md b/docs/examples/project/update-session-invalidation-policy.md index a5840bc2..c4234ff8 100644 --- a/docs/examples/project/update-session-invalidation-policy.md +++ b/docs/examples/project/update-session-invalidation-policy.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.updateSessionInvalidationPolicy({ - enabled: false + enabled: false, }); ``` diff --git a/docs/examples/project/update-session-limit-policy.md b/docs/examples/project/update-session-limit-policy.md index 514d77aa..0c4c8a39 100644 --- a/docs/examples/project/update-session-limit-policy.md +++ b/docs/examples/project/update-session-limit-policy.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.updateSessionLimitPolicy({ - total: 1 + total: 1, }); ``` diff --git a/docs/examples/project/update-smtp.md b/docs/examples/project/update-smtp.md index d7ace099..869ab607 100644 --- a/docs/examples/project/update-smtp.md +++ b/docs/examples/project/update-smtp.md @@ -9,8 +9,8 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.updateSMTP({ - host: '', // optional - port: null, // optional + host: 'example.com', // optional + port: 587, // optional username: '', // optional password: 'password', // optional senderEmail: 'email@example.com', // optional @@ -18,6 +18,6 @@ const result = await project.updateSMTP({ replyToEmail: 'email@example.com', // optional replyToName: '', // optional secure: sdk.ProjectSMTPSecure.Tls, // optional - enabled: false // optional + enabled: false, // optional }); ``` diff --git a/docs/examples/project/update-user-limit-policy.md b/docs/examples/project/update-user-limit-policy.md index a631e0fa..44451f8b 100644 --- a/docs/examples/project/update-user-limit-policy.md +++ b/docs/examples/project/update-user-limit-policy.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const project = new sdk.Project(client); const result = await project.updateUserLimitPolicy({ - total: 0 + total: 0, }); ``` diff --git a/docs/examples/project/update-variable.md b/docs/examples/project/update-variable.md index 58e738ed..b53da55d 100644 --- a/docs/examples/project/update-variable.md +++ b/docs/examples/project/update-variable.md @@ -12,6 +12,6 @@ const result = await project.updateVariable({ variableId: '', key: '', // optional value: '', // optional - secret: false // optional + secret: false, // optional }); ``` diff --git a/docs/examples/project/update-web-platform.md b/docs/examples/project/update-web-platform.md index 9c4f9bd1..8dcdca76 100644 --- a/docs/examples/project/update-web-platform.md +++ b/docs/examples/project/update-web-platform.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateWebPlatform({ platformId: '', name: '', - hostname: 'app.example.com' + hostname: 'app.example.com', }); ``` diff --git a/docs/examples/project/update-windows-platform.md b/docs/examples/project/update-windows-platform.md index 3fd19d7d..0fc1f537 100644 --- a/docs/examples/project/update-windows-platform.md +++ b/docs/examples/project/update-windows-platform.md @@ -11,6 +11,6 @@ const project = new sdk.Project(client); const result = await project.updateWindowsPlatform({ platformId: '', name: '', - packageIdentifierName: '' + packageIdentifierName: '', }); ``` diff --git a/docs/examples/proxy/create-api-rule.md b/docs/examples/proxy/create-api-rule.md index 25fcf691..2d615fe9 100644 --- a/docs/examples/proxy/create-api-rule.md +++ b/docs/examples/proxy/create-api-rule.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const proxy = new sdk.Proxy(client); const result = await proxy.createAPIRule({ - domain: '' + domain: 'example.com', }); ``` diff --git a/docs/examples/proxy/create-function-rule.md b/docs/examples/proxy/create-function-rule.md index cf225f67..67203df7 100644 --- a/docs/examples/proxy/create-function-rule.md +++ b/docs/examples/proxy/create-function-rule.md @@ -9,8 +9,8 @@ const client = new sdk.Client() const proxy = new sdk.Proxy(client); const result = await proxy.createFunctionRule({ - domain: '', + domain: 'example.com', functionId: '', - branch: '' // optional + branch: '', // optional }); ``` diff --git a/docs/examples/proxy/create-invalidation.md b/docs/examples/proxy/create-invalidation.md index 8239fc40..a2e46078 100644 --- a/docs/examples/proxy/create-invalidation.md +++ b/docs/examples/proxy/create-invalidation.md @@ -9,8 +9,8 @@ const client = new sdk.Client() const proxy = new sdk.Proxy(client); const result = await proxy.createInvalidation({ - domain: '', + domain: 'example.com', type: sdk.InvalidationType.Tag, - reference: '' // optional + reference: '', // optional }); ``` diff --git a/docs/examples/proxy/create-redirect-rule.md b/docs/examples/proxy/create-redirect-rule.md index bb028c15..28370b5e 100644 --- a/docs/examples/proxy/create-redirect-rule.md +++ b/docs/examples/proxy/create-redirect-rule.md @@ -9,10 +9,10 @@ const client = new sdk.Client() const proxy = new sdk.Proxy(client); const result = await proxy.createRedirectRule({ - domain: '', + domain: 'example.com', url: 'https://example.com', statusCode: sdk.StatusCode.MovedPermanently, resourceId: '', - resourceType: sdk.ProxyResourceType.Site + resourceType: sdk.ProxyResourceType.Site, }); ``` diff --git a/docs/examples/proxy/create-site-rule.md b/docs/examples/proxy/create-site-rule.md index bafbee3d..74b033f3 100644 --- a/docs/examples/proxy/create-site-rule.md +++ b/docs/examples/proxy/create-site-rule.md @@ -9,8 +9,8 @@ const client = new sdk.Client() const proxy = new sdk.Proxy(client); const result = await proxy.createSiteRule({ - domain: '', + domain: 'example.com', siteId: '', - branch: '' // optional + branch: '', // optional }); ``` diff --git a/docs/examples/proxy/delete-rule.md b/docs/examples/proxy/delete-rule.md index 2d07a110..b4c2c901 100644 --- a/docs/examples/proxy/delete-rule.md +++ b/docs/examples/proxy/delete-rule.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const proxy = new sdk.Proxy(client); const result = await proxy.deleteRule({ - ruleId: '' + ruleId: '', }); ``` diff --git a/docs/examples/proxy/get-rule.md b/docs/examples/proxy/get-rule.md index e89612dc..26d05426 100644 --- a/docs/examples/proxy/get-rule.md +++ b/docs/examples/proxy/get-rule.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const proxy = new sdk.Proxy(client); const result = await proxy.getRule({ - ruleId: '' + ruleId: '', }); ``` diff --git a/docs/examples/proxy/list-rules.md b/docs/examples/proxy/list-rules.md index b161a085..50e4adef 100644 --- a/docs/examples/proxy/list-rules.md +++ b/docs/examples/proxy/list-rules.md @@ -10,6 +10,6 @@ const proxy = new sdk.Proxy(client); const result = await proxy.listRules({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/proxy/update-rule-status.md b/docs/examples/proxy/update-rule-status.md index 9e050fc7..62bc0dac 100644 --- a/docs/examples/proxy/update-rule-status.md +++ b/docs/examples/proxy/update-rule-status.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const proxy = new sdk.Proxy(client); const result = await proxy.updateRuleStatus({ - ruleId: '' + ruleId: '', }); ``` diff --git a/docs/examples/sites/create-deployment.md b/docs/examples/sites/create-deployment.md index 2603dda9..a07dedee 100644 --- a/docs/examples/sites/create-deployment.md +++ b/docs/examples/sites/create-deployment.md @@ -15,6 +15,6 @@ const result = await sites.createDeployment({ installCommand: '', // optional buildCommand: '', // optional outputDirectory: '', // optional - activate: false // optional + activate: false, // optional }); ``` diff --git a/docs/examples/sites/create-duplicate-deployment.md b/docs/examples/sites/create-duplicate-deployment.md index e14d8585..84e57866 100644 --- a/docs/examples/sites/create-duplicate-deployment.md +++ b/docs/examples/sites/create-duplicate-deployment.md @@ -10,6 +10,6 @@ const sites = new sdk.Sites(client); const result = await sites.createDuplicateDeployment({ siteId: '', - deploymentId: '' + deploymentId: '', }); ``` diff --git a/docs/examples/sites/create-template-deployment.md b/docs/examples/sites/create-template-deployment.md index b08d94ab..f78ae972 100644 --- a/docs/examples/sites/create-template-deployment.md +++ b/docs/examples/sites/create-template-deployment.md @@ -15,6 +15,6 @@ const result = await sites.createTemplateDeployment({ rootDirectory: '', type: sdk.TemplateReferenceType.Branch, reference: '', - activate: false // optional + activate: false, // optional }); ``` diff --git a/docs/examples/sites/create-variable.md b/docs/examples/sites/create-variable.md index cad7be76..b6acc61e 100644 --- a/docs/examples/sites/create-variable.md +++ b/docs/examples/sites/create-variable.md @@ -13,6 +13,6 @@ const result = await sites.createVariable({ variableId: '', key: '', value: '', - secret: false // optional + secret: false, // optional }); ``` diff --git a/docs/examples/sites/create-vcs-deployment.md b/docs/examples/sites/create-vcs-deployment.md index 6d28546e..5e0b68aa 100644 --- a/docs/examples/sites/create-vcs-deployment.md +++ b/docs/examples/sites/create-vcs-deployment.md @@ -12,6 +12,6 @@ const result = await sites.createVcsDeployment({ siteId: '', type: sdk.VCSReferenceType.Branch, reference: '', - activate: false // optional + activate: false, // optional }); ``` diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md index dc4e3ef7..686e7377 100644 --- a/docs/examples/sites/create.md +++ b/docs/examples/sites/create.md @@ -29,8 +29,9 @@ const result = await sites.create({ providerRootDirectory: '', // optional providerBranches: [], // optional providerPaths: [], // optional - buildSpecification: '', // optional - runtimeSpecification: '', // optional - deploymentRetention: 0 // optional + buildSpecification: 's-1vcpu-512mb', // optional + runtimeSpecification: 's-1vcpu-512mb', // optional + deploymentRetention: 0, // optional + scopes: [sdk.ProjectKeyScopes.ProjectRead], // optional }); ``` diff --git a/docs/examples/sites/delete-deployment.md b/docs/examples/sites/delete-deployment.md index 533f2985..cf508cc8 100644 --- a/docs/examples/sites/delete-deployment.md +++ b/docs/examples/sites/delete-deployment.md @@ -10,6 +10,6 @@ const sites = new sdk.Sites(client); const result = await sites.deleteDeployment({ siteId: '', - deploymentId: '' + deploymentId: '', }); ``` diff --git a/docs/examples/sites/delete-log.md b/docs/examples/sites/delete-log.md index 38f7c3a3..e198a5aa 100644 --- a/docs/examples/sites/delete-log.md +++ b/docs/examples/sites/delete-log.md @@ -10,6 +10,6 @@ const sites = new sdk.Sites(client); const result = await sites.deleteLog({ siteId: '', - logId: '' + logId: '', }); ``` diff --git a/docs/examples/sites/delete-variable.md b/docs/examples/sites/delete-variable.md index 11ebaca9..b47b7acd 100644 --- a/docs/examples/sites/delete-variable.md +++ b/docs/examples/sites/delete-variable.md @@ -10,6 +10,6 @@ const sites = new sdk.Sites(client); const result = await sites.deleteVariable({ siteId: '', - variableId: '' + variableId: '', }); ``` diff --git a/docs/examples/sites/delete.md b/docs/examples/sites/delete.md index 03bd1a57..45fdb0df 100644 --- a/docs/examples/sites/delete.md +++ b/docs/examples/sites/delete.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); const result = await sites.delete({ - siteId: '' + siteId: '', }); ``` diff --git a/docs/examples/sites/get-deployment-download.md b/docs/examples/sites/get-deployment-download.md index 1d62d288..0cd6d782 100644 --- a/docs/examples/sites/get-deployment-download.md +++ b/docs/examples/sites/get-deployment-download.md @@ -12,6 +12,6 @@ const result = await sites.getDeploymentDownload({ siteId: '', deploymentId: '', type: sdk.DeploymentDownloadType.Source, // optional - token: '' // optional + token: '', // optional }); ``` diff --git a/docs/examples/sites/get-deployment.md b/docs/examples/sites/get-deployment.md index 1f1430ca..b12fa8d1 100644 --- a/docs/examples/sites/get-deployment.md +++ b/docs/examples/sites/get-deployment.md @@ -10,6 +10,6 @@ const sites = new sdk.Sites(client); const result = await sites.getDeployment({ siteId: '', - deploymentId: '' + deploymentId: '', }); ``` diff --git a/docs/examples/sites/get-log.md b/docs/examples/sites/get-log.md index f8190b4a..74233128 100644 --- a/docs/examples/sites/get-log.md +++ b/docs/examples/sites/get-log.md @@ -10,6 +10,6 @@ const sites = new sdk.Sites(client); const result = await sites.getLog({ siteId: '', - logId: '' + logId: '', }); ``` diff --git a/docs/examples/sites/get-variable.md b/docs/examples/sites/get-variable.md index cafb71b1..1403faea 100644 --- a/docs/examples/sites/get-variable.md +++ b/docs/examples/sites/get-variable.md @@ -10,6 +10,6 @@ const sites = new sdk.Sites(client); const result = await sites.getVariable({ siteId: '', - variableId: '' + variableId: '', }); ``` diff --git a/docs/examples/sites/get.md b/docs/examples/sites/get.md index 0b21b2bb..e5a6ef69 100644 --- a/docs/examples/sites/get.md +++ b/docs/examples/sites/get.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); const result = await sites.get({ - siteId: '' + siteId: '', }); ``` diff --git a/docs/examples/sites/list-deployments.md b/docs/examples/sites/list-deployments.md index 1b544a0a..dec9ad4b 100644 --- a/docs/examples/sites/list-deployments.md +++ b/docs/examples/sites/list-deployments.md @@ -12,6 +12,6 @@ const result = await sites.listDeployments({ siteId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/sites/list-logs.md b/docs/examples/sites/list-logs.md index 62b16945..967b3fe4 100644 --- a/docs/examples/sites/list-logs.md +++ b/docs/examples/sites/list-logs.md @@ -11,6 +11,6 @@ const sites = new sdk.Sites(client); const result = await sites.listLogs({ siteId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/sites/list-specifications.md b/docs/examples/sites/list-specifications.md index 208c8278..85a1a84f 100644 --- a/docs/examples/sites/list-specifications.md +++ b/docs/examples/sites/list-specifications.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); const result = await sites.listSpecifications({ - type: 'runtimes' // optional + type: 'runtimes', // optional }); ``` diff --git a/docs/examples/sites/list-variables.md b/docs/examples/sites/list-variables.md index 26ae3212..41339962 100644 --- a/docs/examples/sites/list-variables.md +++ b/docs/examples/sites/list-variables.md @@ -11,6 +11,6 @@ const sites = new sdk.Sites(client); const result = await sites.listVariables({ siteId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/sites/list.md b/docs/examples/sites/list.md index 518aa709..4b00cd02 100644 --- a/docs/examples/sites/list.md +++ b/docs/examples/sites/list.md @@ -11,6 +11,6 @@ const sites = new sdk.Sites(client); const result = await sites.list({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/sites/update-deployment-status.md b/docs/examples/sites/update-deployment-status.md index 73a74758..6a468012 100644 --- a/docs/examples/sites/update-deployment-status.md +++ b/docs/examples/sites/update-deployment-status.md @@ -10,6 +10,6 @@ const sites = new sdk.Sites(client); const result = await sites.updateDeploymentStatus({ siteId: '', - deploymentId: '' + deploymentId: '', }); ``` diff --git a/docs/examples/sites/update-site-deployment.md b/docs/examples/sites/update-site-deployment.md index 1221d370..5b23fbe6 100644 --- a/docs/examples/sites/update-site-deployment.md +++ b/docs/examples/sites/update-site-deployment.md @@ -10,6 +10,6 @@ const sites = new sdk.Sites(client); const result = await sites.updateSiteDeployment({ siteId: '', - deploymentId: '' + deploymentId: '', }); ``` diff --git a/docs/examples/sites/update-variable.md b/docs/examples/sites/update-variable.md index 2853a180..d489347c 100644 --- a/docs/examples/sites/update-variable.md +++ b/docs/examples/sites/update-variable.md @@ -13,6 +13,6 @@ const result = await sites.updateVariable({ variableId: '', key: '', // optional value: '', // optional - secret: false // optional + secret: false, // optional }); ``` diff --git a/docs/examples/sites/update.md b/docs/examples/sites/update.md index 30928f1d..932cf002 100644 --- a/docs/examples/sites/update.md +++ b/docs/examples/sites/update.md @@ -29,8 +29,9 @@ const result = await sites.update({ providerRootDirectory: '', // optional providerBranches: [], // optional providerPaths: [], // optional - buildSpecification: '', // optional - runtimeSpecification: '', // optional - deploymentRetention: 0 // optional + buildSpecification: 's-1vcpu-512mb', // optional + runtimeSpecification: 's-1vcpu-512mb', // optional + deploymentRetention: 0, // optional + scopes: [sdk.ProjectKeyScopes.ProjectRead], // optional }); ``` diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md index 47dc8b31..fe16a23b 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -19,6 +19,6 @@ const result = await storage.createBucket({ compression: sdk.Compression.None, // optional encryption: false, // optional antivirus: false, // optional - transformations: false // optional + transformations: false, // optional }); ``` diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index 6a09ee7c..d69727e1 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -14,6 +14,6 @@ const result = await storage.createFile({ fileId: '', file: InputFile.fromPath('/path/to/file', 'filename'), permissions: [sdk.Permission.read(sdk.Role.any())], // optional - folder: '' // optional + folder: 'photos/2026', // optional }); ``` diff --git a/docs/examples/storage/delete-bucket.md b/docs/examples/storage/delete-bucket.md index bf6fa1b6..50fb3197 100644 --- a/docs/examples/storage/delete-bucket.md +++ b/docs/examples/storage/delete-bucket.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const storage = new sdk.Storage(client); const result = await storage.deleteBucket({ - bucketId: '' + bucketId: '', }); ``` diff --git a/docs/examples/storage/delete-file.md b/docs/examples/storage/delete-file.md index d49838e1..da276533 100644 --- a/docs/examples/storage/delete-file.md +++ b/docs/examples/storage/delete-file.md @@ -10,6 +10,6 @@ const storage = new sdk.Storage(client); const result = await storage.deleteFile({ bucketId: '', - fileId: '' + fileId: '', }); ``` diff --git a/docs/examples/storage/get-bucket.md b/docs/examples/storage/get-bucket.md index 380db535..6608f90a 100644 --- a/docs/examples/storage/get-bucket.md +++ b/docs/examples/storage/get-bucket.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const storage = new sdk.Storage(client); const result = await storage.getBucket({ - bucketId: '' + bucketId: '', }); ``` diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index c0a10d96..6282691a 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -11,6 +11,6 @@ const storage = new sdk.Storage(client); const result = await storage.getFileDownload({ bucketId: '', fileId: '', - token: '' // optional + token: '', // optional }); ``` diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index 984333db..5e13a0ba 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -16,12 +16,12 @@ const result = await storage.getFilePreview({ gravity: sdk.ImageGravity.Center, // optional quality: -1, // optional borderWidth: 0, // optional - borderColor: '', // optional + borderColor: 'FFFFFF', // optional borderRadius: 0, // optional opacity: 0, // optional rotation: -360, // optional - background: '', // optional + background: 'FFFFFF', // optional output: sdk.ImageFormat.Jpg, // optional - token: '' // optional + token: '', // optional }); ``` diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index a20c4ac2..ad9a9d1e 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -11,6 +11,6 @@ const storage = new sdk.Storage(client); const result = await storage.getFileView({ bucketId: '', fileId: '', - token: '' // optional + token: '', // optional }); ``` diff --git a/docs/examples/storage/get-file.md b/docs/examples/storage/get-file.md index d8bdf4dd..f1aca864 100644 --- a/docs/examples/storage/get-file.md +++ b/docs/examples/storage/get-file.md @@ -10,6 +10,6 @@ const storage = new sdk.Storage(client); const result = await storage.getFile({ bucketId: '', - fileId: '' + fileId: '', }); ``` diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md index c17389e5..109ff903 100644 --- a/docs/examples/storage/list-buckets.md +++ b/docs/examples/storage/list-buckets.md @@ -11,6 +11,6 @@ const storage = new sdk.Storage(client); const result = await storage.listBuckets({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index f51fad9d..476da76c 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -12,6 +12,6 @@ const result = await storage.listFiles({ bucketId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md index c17c9691..baddf9cf 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -19,6 +19,6 @@ const result = await storage.updateBucket({ compression: sdk.Compression.None, // optional encryption: false, // optional antivirus: false, // optional - transformations: false // optional + transformations: false, // optional }); ``` diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md index 8d2294ff..e178b087 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -12,6 +12,6 @@ const result = await storage.updateFile({ bucketId: '', fileId: '', name: '', // optional - permissions: [sdk.Permission.read(sdk.Role.any())] // optional + permissions: [sdk.Permission.read(sdk.Role.any())], // optional }); ``` diff --git a/docs/examples/tablesdb/create-big-int-column.md b/docs/examples/tablesdb/create-big-int-column.md index 21ca0bfd..914c27a3 100644 --- a/docs/examples/tablesdb/create-big-int-column.md +++ b/docs/examples/tablesdb/create-big-int-column.md @@ -11,11 +11,11 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createBigIntColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - min: null, // optional - max: null, // optional - xdefault: null, // optional - array: false // optional + min: 0, // optional + max: 1000000, // optional + xdefault: 0, // optional + array: false, // optional }); ``` diff --git a/docs/examples/tablesdb/create-boolean-column.md b/docs/examples/tablesdb/create-boolean-column.md index b9df8ba8..c8c89558 100644 --- a/docs/examples/tablesdb/create-boolean-column.md +++ b/docs/examples/tablesdb/create-boolean-column.md @@ -11,9 +11,9 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createBooleanColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: false, // optional - array: false // optional + array: false, // optional }); ``` diff --git a/docs/examples/tablesdb/create-datetime-column.md b/docs/examples/tablesdb/create-datetime-column.md index 602c2a1a..7c0d259b 100644 --- a/docs/examples/tablesdb/create-datetime-column.md +++ b/docs/examples/tablesdb/create-datetime-column.md @@ -11,9 +11,9 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createDatetimeColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: '2020-10-15T06:38:00.000+00:00', // optional - array: false // optional + array: false, // optional }); ``` diff --git a/docs/examples/tablesdb/create-email-column.md b/docs/examples/tablesdb/create-email-column.md index bdd59341..95775987 100644 --- a/docs/examples/tablesdb/create-email-column.md +++ b/docs/examples/tablesdb/create-email-column.md @@ -11,9 +11,9 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createEmailColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: 'email@example.com', // optional - array: false // optional + array: false, // optional }); ``` diff --git a/docs/examples/tablesdb/create-enum-column.md b/docs/examples/tablesdb/create-enum-column.md index 4016ce71..d3b878a5 100644 --- a/docs/examples/tablesdb/create-enum-column.md +++ b/docs/examples/tablesdb/create-enum-column.md @@ -11,10 +11,10 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createEnumColumn({ databaseId: '', tableId: '', - key: '', - elements: [], + key: '', + elements: ['active', 'inactive'], required: false, - xdefault: '', // optional - array: false // optional + xdefault: 'active', // optional + array: false, // optional }); ``` diff --git a/docs/examples/tablesdb/create-failover.md b/docs/examples/tablesdb/create-failover.md index 0ad64376..b95a5191 100644 --- a/docs/examples/tablesdb/create-failover.md +++ b/docs/examples/tablesdb/create-failover.md @@ -10,6 +10,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createFailover({ databaseId: '', - targetReplicaId: '' // optional + targetReplicaId: '', // optional }); ``` diff --git a/docs/examples/tablesdb/create-float-column.md b/docs/examples/tablesdb/create-float-column.md index b533f38a..5a284bea 100644 --- a/docs/examples/tablesdb/create-float-column.md +++ b/docs/examples/tablesdb/create-float-column.md @@ -11,11 +11,11 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createFloatColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - min: null, // optional - max: null, // optional - xdefault: null, // optional - array: false // optional + min: 0, // optional + max: 100, // optional + xdefault: 10.5, // optional + array: false, // optional }); ``` diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index 6a7523ba..2bd4818e 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -11,10 +11,10 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createIndex({ databaseId: '', tableId: '', - key: '', + key: '', type: sdk.TablesDBIndexType.Key, columns: [], orders: [sdk.OrderBy.Asc], // optional - lengths: [] // optional + lengths: [], // optional }); ``` diff --git a/docs/examples/tablesdb/create-integer-column.md b/docs/examples/tablesdb/create-integer-column.md index 6e99e93e..a7d37f77 100644 --- a/docs/examples/tablesdb/create-integer-column.md +++ b/docs/examples/tablesdb/create-integer-column.md @@ -11,11 +11,11 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createIntegerColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - min: null, // optional - max: null, // optional - xdefault: null, // optional - array: false // optional + min: 0, // optional + max: 100, // optional + xdefault: 10, // optional + array: false, // optional }); ``` diff --git a/docs/examples/tablesdb/create-ip-column.md b/docs/examples/tablesdb/create-ip-column.md index 7d176b6a..b6be4f14 100644 --- a/docs/examples/tablesdb/create-ip-column.md +++ b/docs/examples/tablesdb/create-ip-column.md @@ -11,9 +11,9 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createIpColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', // optional - array: false // optional + xdefault: '192.0.2.0', // optional + array: false, // optional }); ``` diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md index f99194c6..f23523ea 100644 --- a/docs/examples/tablesdb/create-line-column.md +++ b/docs/examples/tablesdb/create-line-column.md @@ -11,8 +11,12 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createLineColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: [[1, 2], [3, 4], [5, 6]] // optional + xdefault: [ + [1, 2], + [3, 4], + [5, 6], + ], // optional }); ``` diff --git a/docs/examples/tablesdb/create-longtext-column.md b/docs/examples/tablesdb/create-longtext-column.md index 89d37c47..04dde8ed 100644 --- a/docs/examples/tablesdb/create-longtext-column.md +++ b/docs/examples/tablesdb/create-longtext-column.md @@ -11,10 +11,10 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createLongtextColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); ``` diff --git a/docs/examples/tablesdb/create-mediumtext-column.md b/docs/examples/tablesdb/create-mediumtext-column.md index daa59589..5c9ec6df 100644 --- a/docs/examples/tablesdb/create-mediumtext-column.md +++ b/docs/examples/tablesdb/create-mediumtext-column.md @@ -11,10 +11,10 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createMediumtextColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); ``` diff --git a/docs/examples/tablesdb/create-migration.md b/docs/examples/tablesdb/create-migration.md index 8338b362..5b67e91f 100644 --- a/docs/examples/tablesdb/create-migration.md +++ b/docs/examples/tablesdb/create-migration.md @@ -11,6 +11,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createMigration({ databaseId: '', specification: 's-1vcpu-1gb', - autoCutover: false // optional + autoCutover: false, // optional }); ``` diff --git a/docs/examples/tablesdb/create-operations.md b/docs/examples/tablesdb/create-operations.md index d1823aa8..80ae6359 100644 --- a/docs/examples/tablesdb/create-operations.md +++ b/docs/examples/tablesdb/create-operations.md @@ -11,15 +11,15 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createOperations({ transactionId: '', operations: [ - { - "action": "create", - "databaseId": "", - "tableId": "", - "rowId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional + { + action: 'create', + databaseId: '', + tableId: '', + rowId: '', + data: { + name: "Walter O'Brien", + }, + }, + ], // optional }); ``` diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md index a68d1e43..9783951d 100644 --- a/docs/examples/tablesdb/create-point-column.md +++ b/docs/examples/tablesdb/create-point-column.md @@ -11,8 +11,8 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createPointColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: [1, 2] // optional + xdefault: [1, 2], // optional }); ``` diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md index 0f4631bc..71f14061 100644 --- a/docs/examples/tablesdb/create-polygon-column.md +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -11,8 +11,15 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createPolygonColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: [[[1, 2], [3, 4], [5, 6], [1, 2]]] // optional + xdefault: [ + [ + [1, 2], + [3, 4], + [5, 6], + [1, 2], + ], + ], // optional }); ``` diff --git a/docs/examples/tablesdb/create-relationship-column.md b/docs/examples/tablesdb/create-relationship-column.md index 6f2c0fa9..0f40996e 100644 --- a/docs/examples/tablesdb/create-relationship-column.md +++ b/docs/examples/tablesdb/create-relationship-column.md @@ -14,8 +14,8 @@ const result = await tablesDB.createRelationshipColumn({ relatedTableId: '', type: sdk.RelationshipType.OneToOne, twoWay: false, // optional - key: '', // optional - twoWayKey: '', // optional - onDelete: sdk.RelationMutate.Cascade // optional + key: '', // optional + twoWayKey: '', // optional + onDelete: sdk.RelationMutate.Cascade, // optional }); ``` diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 485afcde..c1181b1a 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -13,13 +13,13 @@ const result = await tablesDB.createRow({ tableId: '', rowId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 30, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 30, + isAdmin: false, }, permissions: [sdk.Permission.read(sdk.Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index 05364214..af17e879 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -12,6 +12,6 @@ const result = await tablesDB.createRows({ databaseId: '', tableId: '', rows: [], - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/tablesdb/create-string-column.md b/docs/examples/tablesdb/create-string-column.md index 255701ce..217c050b 100644 --- a/docs/examples/tablesdb/create-string-column.md +++ b/docs/examples/tablesdb/create-string-column.md @@ -11,11 +11,11 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createStringColumn({ databaseId: '', tableId: '', - key: '', + key: '', size: 1, required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); ``` diff --git a/docs/examples/tablesdb/create-table.md b/docs/examples/tablesdb/create-table.md index b429f797..cd898df0 100644 --- a/docs/examples/tablesdb/create-table.md +++ b/docs/examples/tablesdb/create-table.md @@ -16,6 +16,6 @@ const result = await tablesDB.createTable({ rowSecurity: false, // optional enabled: false, // optional columns: [], // optional - indexes: [] // optional + indexes: [], // optional }); ``` diff --git a/docs/examples/tablesdb/create-text-column.md b/docs/examples/tablesdb/create-text-column.md index e7b9a479..4ac2fe7d 100644 --- a/docs/examples/tablesdb/create-text-column.md +++ b/docs/examples/tablesdb/create-text-column.md @@ -11,10 +11,10 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createTextColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); ``` diff --git a/docs/examples/tablesdb/create-transaction.md b/docs/examples/tablesdb/create-transaction.md index c737347f..467ae167 100644 --- a/docs/examples/tablesdb/create-transaction.md +++ b/docs/examples/tablesdb/create-transaction.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createTransaction({ - ttl: 60 // optional + ttl: 60, // optional }); ``` diff --git a/docs/examples/tablesdb/create-url-column.md b/docs/examples/tablesdb/create-url-column.md index 01e27e7d..ba037a62 100644 --- a/docs/examples/tablesdb/create-url-column.md +++ b/docs/examples/tablesdb/create-url-column.md @@ -11,9 +11,9 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createUrlColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: 'https://example.com', // optional - array: false // optional + array: false, // optional }); ``` diff --git a/docs/examples/tablesdb/create-varchar-column.md b/docs/examples/tablesdb/create-varchar-column.md index 9cfc6fa6..3c3ae8ab 100644 --- a/docs/examples/tablesdb/create-varchar-column.md +++ b/docs/examples/tablesdb/create-varchar-column.md @@ -11,11 +11,11 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createVarcharColumn({ databaseId: '', tableId: '', - key: '', + key: '', size: 1, required: false, - xdefault: '', // optional + xdefault: 'Hello World', // optional array: false, // optional - encrypt: false // optional + encrypt: false, // optional }); ``` diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md index cd18253c..c7b47594 100644 --- a/docs/examples/tablesdb/create.md +++ b/docs/examples/tablesdb/create.md @@ -14,6 +14,6 @@ const result = await tablesDB.create({ enabled: false, // optional specification: 'serverless', // optional replicas: 0, // optional - syncMode: 'async' // optional + syncMode: 'async', // optional }); ``` diff --git a/docs/examples/tablesdb/cutover-migration.md b/docs/examples/tablesdb/cutover-migration.md index 1cf02168..08403b9f 100644 --- a/docs/examples/tablesdb/cutover-migration.md +++ b/docs/examples/tablesdb/cutover-migration.md @@ -10,6 +10,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.cutoverMigration({ databaseId: '', - migrationId: '' + migrationId: '', }); ``` diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md index 2fafbbbf..86e3bec4 100644 --- a/docs/examples/tablesdb/decrement-row-column.md +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -12,9 +12,9 @@ const result = await tablesDB.decrementRowColumn({ databaseId: '', tableId: '', rowId: '', - column: '', - value: null, // optional - min: null, // optional - transactionId: '' // optional + column: '', + value: 1, // optional + min: 0, // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/tablesdb/delete-column.md b/docs/examples/tablesdb/delete-column.md index 51fd96e3..abe3d764 100644 --- a/docs/examples/tablesdb/delete-column.md +++ b/docs/examples/tablesdb/delete-column.md @@ -11,6 +11,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.deleteColumn({ databaseId: '', tableId: '', - key: '' + key: '', }); ``` diff --git a/docs/examples/tablesdb/delete-index.md b/docs/examples/tablesdb/delete-index.md index 4c7ad1ee..88252ddc 100644 --- a/docs/examples/tablesdb/delete-index.md +++ b/docs/examples/tablesdb/delete-index.md @@ -11,6 +11,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.deleteIndex({ databaseId: '', tableId: '', - key: '' + key: '', }); ``` diff --git a/docs/examples/tablesdb/delete-migration.md b/docs/examples/tablesdb/delete-migration.md index 7a85305c..9895352b 100644 --- a/docs/examples/tablesdb/delete-migration.md +++ b/docs/examples/tablesdb/delete-migration.md @@ -10,6 +10,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.deleteMigration({ databaseId: '', - migrationId: '' + migrationId: '', }); ``` diff --git a/docs/examples/tablesdb/delete-row.md b/docs/examples/tablesdb/delete-row.md index 20d4e95b..7bf02f6b 100644 --- a/docs/examples/tablesdb/delete-row.md +++ b/docs/examples/tablesdb/delete-row.md @@ -12,6 +12,6 @@ const result = await tablesDB.deleteRow({ databaseId: '', tableId: '', rowId: '', - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 3dd8f1e0..ccc97155 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -12,6 +12,6 @@ const result = await tablesDB.deleteRows({ databaseId: '', tableId: '', queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/tablesdb/delete-table.md b/docs/examples/tablesdb/delete-table.md index f3071a45..519c1622 100644 --- a/docs/examples/tablesdb/delete-table.md +++ b/docs/examples/tablesdb/delete-table.md @@ -10,6 +10,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.deleteTable({ databaseId: '', - tableId: '' + tableId: '', }); ``` diff --git a/docs/examples/tablesdb/delete-transaction.md b/docs/examples/tablesdb/delete-transaction.md index 3daa0bd6..2b91f54c 100644 --- a/docs/examples/tablesdb/delete-transaction.md +++ b/docs/examples/tablesdb/delete-transaction.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.deleteTransaction({ - transactionId: '' + transactionId: '', }); ``` diff --git a/docs/examples/tablesdb/delete.md b/docs/examples/tablesdb/delete.md index 018b3a9c..f31f624d 100644 --- a/docs/examples/tablesdb/delete.md +++ b/docs/examples/tablesdb/delete.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.delete({ - databaseId: '' + databaseId: '', }); ``` diff --git a/docs/examples/tablesdb/get-column.md b/docs/examples/tablesdb/get-column.md index 8daf93d4..36159efe 100644 --- a/docs/examples/tablesdb/get-column.md +++ b/docs/examples/tablesdb/get-column.md @@ -11,6 +11,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.getColumn({ databaseId: '', tableId: '', - key: '' + key: '', }); ``` diff --git a/docs/examples/tablesdb/get-index.md b/docs/examples/tablesdb/get-index.md index 164f833e..8a47a395 100644 --- a/docs/examples/tablesdb/get-index.md +++ b/docs/examples/tablesdb/get-index.md @@ -11,6 +11,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.getIndex({ databaseId: '', tableId: '', - key: '' + key: '', }); ``` diff --git a/docs/examples/tablesdb/get-migration.md b/docs/examples/tablesdb/get-migration.md index 8900aa69..6d55824f 100644 --- a/docs/examples/tablesdb/get-migration.md +++ b/docs/examples/tablesdb/get-migration.md @@ -10,6 +10,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.getMigration({ databaseId: '', - migrationId: '' + migrationId: '', }); ``` diff --git a/docs/examples/tablesdb/get-replicas.md b/docs/examples/tablesdb/get-replicas.md index ab402963..4d10f1dc 100644 --- a/docs/examples/tablesdb/get-replicas.md +++ b/docs/examples/tablesdb/get-replicas.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.getReplicas({ - databaseId: '' + databaseId: '', }); ``` diff --git a/docs/examples/tablesdb/get-row.md b/docs/examples/tablesdb/get-row.md index 6cbf26f0..5847c699 100644 --- a/docs/examples/tablesdb/get-row.md +++ b/docs/examples/tablesdb/get-row.md @@ -13,6 +13,6 @@ const result = await tablesDB.getRow({ tableId: '', rowId: '', queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/tablesdb/get-status.md b/docs/examples/tablesdb/get-status.md index 3b858219..3dfa7de0 100644 --- a/docs/examples/tablesdb/get-status.md +++ b/docs/examples/tablesdb/get-status.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.getStatus({ - databaseId: '' + databaseId: '', }); ``` diff --git a/docs/examples/tablesdb/get-table.md b/docs/examples/tablesdb/get-table.md index e8254356..74c79385 100644 --- a/docs/examples/tablesdb/get-table.md +++ b/docs/examples/tablesdb/get-table.md @@ -10,6 +10,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.getTable({ databaseId: '', - tableId: '' + tableId: '', }); ``` diff --git a/docs/examples/tablesdb/get-transaction.md b/docs/examples/tablesdb/get-transaction.md index c39cfe11..e14fe040 100644 --- a/docs/examples/tablesdb/get-transaction.md +++ b/docs/examples/tablesdb/get-transaction.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.getTransaction({ - transactionId: '' + transactionId: '', }); ``` diff --git a/docs/examples/tablesdb/get.md b/docs/examples/tablesdb/get.md index 38d5ce7a..18187de8 100644 --- a/docs/examples/tablesdb/get.md +++ b/docs/examples/tablesdb/get.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.get({ - databaseId: '' + databaseId: '', }); ``` diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md index 1388043a..626b84f5 100644 --- a/docs/examples/tablesdb/increment-row-column.md +++ b/docs/examples/tablesdb/increment-row-column.md @@ -12,9 +12,9 @@ const result = await tablesDB.incrementRowColumn({ databaseId: '', tableId: '', rowId: '', - column: '', - value: null, // optional - max: null, // optional - transactionId: '' // optional + column: '', + value: 1, // optional + max: 100, // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/tablesdb/list-columns.md b/docs/examples/tablesdb/list-columns.md index 59b2bfbf..f14d02b7 100644 --- a/docs/examples/tablesdb/list-columns.md +++ b/docs/examples/tablesdb/list-columns.md @@ -12,6 +12,6 @@ const result = await tablesDB.listColumns({ databaseId: '', tableId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/tablesdb/list-indexes.md b/docs/examples/tablesdb/list-indexes.md index 7ff6df55..4d5f71ba 100644 --- a/docs/examples/tablesdb/list-indexes.md +++ b/docs/examples/tablesdb/list-indexes.md @@ -12,6 +12,6 @@ const result = await tablesDB.listIndexes({ databaseId: '', tableId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/tablesdb/list-migrations.md b/docs/examples/tablesdb/list-migrations.md index c3275a5a..c8df807d 100644 --- a/docs/examples/tablesdb/list-migrations.md +++ b/docs/examples/tablesdb/list-migrations.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.listMigrations({ - databaseId: '' + databaseId: '', }); ``` diff --git a/docs/examples/tablesdb/list-operations.md b/docs/examples/tablesdb/list-operations.md index 62fcb0ce..b2962782 100644 --- a/docs/examples/tablesdb/list-operations.md +++ b/docs/examples/tablesdb/list-operations.md @@ -10,8 +10,8 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.listOperations({ databaseId: '', - status: 'running', // optional + status: 'queued', // optional limit: 1, // optional - offset: 0 // optional + offset: 0, // optional }); ``` diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md index 2777730b..4a8c1b5e 100644 --- a/docs/examples/tablesdb/list-rows.md +++ b/docs/examples/tablesdb/list-rows.md @@ -14,6 +14,6 @@ const result = await tablesDB.listRows({ queries: [], // optional transactionId: '', // optional total: false, // optional - ttl: 0 // optional + ttl: 0, // optional }); ``` diff --git a/docs/examples/tablesdb/list-tables.md b/docs/examples/tablesdb/list-tables.md index 82779015..f59133f3 100644 --- a/docs/examples/tablesdb/list-tables.md +++ b/docs/examples/tablesdb/list-tables.md @@ -12,6 +12,6 @@ const result = await tablesDB.listTables({ databaseId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/tablesdb/list-transactions.md b/docs/examples/tablesdb/list-transactions.md index 892bd288..51a3fc45 100644 --- a/docs/examples/tablesdb/list-transactions.md +++ b/docs/examples/tablesdb/list-transactions.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.listTransactions({ - queries: [] // optional + queries: [], // optional }); ``` diff --git a/docs/examples/tablesdb/list.md b/docs/examples/tablesdb/list.md index 3514e2dc..48e0e018 100644 --- a/docs/examples/tablesdb/list.md +++ b/docs/examples/tablesdb/list.md @@ -11,6 +11,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.list({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/tablesdb/update-big-int-column.md b/docs/examples/tablesdb/update-big-int-column.md index 4defcb4c..51ba71ab 100644 --- a/docs/examples/tablesdb/update-big-int-column.md +++ b/docs/examples/tablesdb/update-big-int-column.md @@ -11,11 +11,11 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateBigIntColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: null, - min: null, // optional - max: null, // optional - newKey: '' // optional + xdefault: 0, + min: 0, // optional + max: 1000000, // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-boolean-column.md b/docs/examples/tablesdb/update-boolean-column.md index 6ad62691..0f292d00 100644 --- a/docs/examples/tablesdb/update-boolean-column.md +++ b/docs/examples/tablesdb/update-boolean-column.md @@ -11,9 +11,9 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateBooleanColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: false, - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-datetime-column.md b/docs/examples/tablesdb/update-datetime-column.md index ff93b140..162f2f72 100644 --- a/docs/examples/tablesdb/update-datetime-column.md +++ b/docs/examples/tablesdb/update-datetime-column.md @@ -11,9 +11,9 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateDatetimeColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: '2020-10-15T06:38:00.000+00:00', - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-email-column.md b/docs/examples/tablesdb/update-email-column.md index fc6c764b..4c4f1e8e 100644 --- a/docs/examples/tablesdb/update-email-column.md +++ b/docs/examples/tablesdb/update-email-column.md @@ -11,9 +11,9 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateEmailColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: 'email@example.com', - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-enum-column.md b/docs/examples/tablesdb/update-enum-column.md index b97a4c58..0b1bf8d6 100644 --- a/docs/examples/tablesdb/update-enum-column.md +++ b/docs/examples/tablesdb/update-enum-column.md @@ -11,10 +11,10 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateEnumColumn({ databaseId: '', tableId: '', - key: '', - elements: [], + key: '', + elements: ['active', 'inactive'], required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'active', + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-float-column.md b/docs/examples/tablesdb/update-float-column.md index d332d81f..ee1f80a8 100644 --- a/docs/examples/tablesdb/update-float-column.md +++ b/docs/examples/tablesdb/update-float-column.md @@ -11,11 +11,11 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateFloatColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: null, - min: null, // optional - max: null, // optional - newKey: '' // optional + xdefault: 10.5, + min: 0, // optional + max: 100, // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-integer-column.md b/docs/examples/tablesdb/update-integer-column.md index 4a49705d..16284f3e 100644 --- a/docs/examples/tablesdb/update-integer-column.md +++ b/docs/examples/tablesdb/update-integer-column.md @@ -11,11 +11,11 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateIntegerColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: null, - min: null, // optional - max: null, // optional - newKey: '' // optional + xdefault: 10, + min: 0, // optional + max: 100, // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-ip-column.md b/docs/examples/tablesdb/update-ip-column.md index 00dfce17..99b0a3c8 100644 --- a/docs/examples/tablesdb/update-ip-column.md +++ b/docs/examples/tablesdb/update-ip-column.md @@ -11,9 +11,9 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateIpColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: '192.0.2.0', + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md index 0a6bd255..f1d3573d 100644 --- a/docs/examples/tablesdb/update-line-column.md +++ b/docs/examples/tablesdb/update-line-column.md @@ -11,9 +11,13 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateLineColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: [[1, 2], [3, 4], [5, 6]], // optional - newKey: '' // optional + xdefault: [ + [1, 2], + [3, 4], + [5, 6], + ], // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-longtext-column.md b/docs/examples/tablesdb/update-longtext-column.md index cdb20747..e1035934 100644 --- a/docs/examples/tablesdb/update-longtext-column.md +++ b/docs/examples/tablesdb/update-longtext-column.md @@ -11,9 +11,9 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateLongtextColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'Hello World', + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-mediumtext-column.md b/docs/examples/tablesdb/update-mediumtext-column.md index 7c84b920..32921519 100644 --- a/docs/examples/tablesdb/update-mediumtext-column.md +++ b/docs/examples/tablesdb/update-mediumtext-column.md @@ -11,9 +11,9 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateMediumtextColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'Hello World', + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md index c2e10506..d5ec4725 100644 --- a/docs/examples/tablesdb/update-point-column.md +++ b/docs/examples/tablesdb/update-point-column.md @@ -11,9 +11,9 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updatePointColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: [1, 2], // optional - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md index 0a38cd0a..41b65bf3 100644 --- a/docs/examples/tablesdb/update-polygon-column.md +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -11,9 +11,16 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updatePolygonColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: [[[1, 2], [3, 4], [5, 6], [1, 2]]], // optional - newKey: '' // optional + xdefault: [ + [ + [1, 2], + [3, 4], + [5, 6], + [1, 2], + ], + ], // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-relationship-column.md b/docs/examples/tablesdb/update-relationship-column.md index 86f935a5..88b17f10 100644 --- a/docs/examples/tablesdb/update-relationship-column.md +++ b/docs/examples/tablesdb/update-relationship-column.md @@ -11,8 +11,8 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateRelationshipColumn({ databaseId: '', tableId: '', - key: '', + key: '', onDelete: sdk.RelationMutate.Cascade, // optional - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index bac92af2..c88e3ea7 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -13,13 +13,13 @@ const result = await tablesDB.updateRow({ tableId: '', rowId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 33, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 33, + isAdmin: false, }, // optional permissions: [sdk.Permission.read(sdk.Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 09ab8601..c8bb76ae 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -12,13 +12,13 @@ const result = await tablesDB.updateRows({ databaseId: '', tableId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 33, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 33, + isAdmin: false, }, // optional queries: [], // optional - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-string-column.md b/docs/examples/tablesdb/update-string-column.md index 757aa6cf..368d97c1 100644 --- a/docs/examples/tablesdb/update-string-column.md +++ b/docs/examples/tablesdb/update-string-column.md @@ -11,10 +11,10 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateStringColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', + xdefault: 'Hello World', size: 1, // optional - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md index 6aa65c2e..dd37e42d 100644 --- a/docs/examples/tablesdb/update-table.md +++ b/docs/examples/tablesdb/update-table.md @@ -15,6 +15,6 @@ const result = await tablesDB.updateTable({ permissions: [sdk.Permission.read(sdk.Role.any())], // optional rowSecurity: false, // optional enabled: false, // optional - purge: false // optional + purge: false, // optional }); ``` diff --git a/docs/examples/tablesdb/update-text-column.md b/docs/examples/tablesdb/update-text-column.md index 69970d63..4a132e66 100644 --- a/docs/examples/tablesdb/update-text-column.md +++ b/docs/examples/tablesdb/update-text-column.md @@ -11,9 +11,9 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateTextColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', - newKey: '' // optional + xdefault: 'Hello World', + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-transaction.md b/docs/examples/tablesdb/update-transaction.md index d0607478..a955d48b 100644 --- a/docs/examples/tablesdb/update-transaction.md +++ b/docs/examples/tablesdb/update-transaction.md @@ -11,6 +11,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateTransaction({ transactionId: '', commit: false, // optional - rollback: false // optional + rollback: false, // optional }); ``` diff --git a/docs/examples/tablesdb/update-url-column.md b/docs/examples/tablesdb/update-url-column.md index 08392f5d..72f285cf 100644 --- a/docs/examples/tablesdb/update-url-column.md +++ b/docs/examples/tablesdb/update-url-column.md @@ -11,9 +11,9 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateUrlColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, xdefault: 'https://example.com', - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update-varchar-column.md b/docs/examples/tablesdb/update-varchar-column.md index 58f94220..e2e7714e 100644 --- a/docs/examples/tablesdb/update-varchar-column.md +++ b/docs/examples/tablesdb/update-varchar-column.md @@ -11,10 +11,10 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateVarcharColumn({ databaseId: '', tableId: '', - key: '', + key: '', required: false, - xdefault: '', + xdefault: 'Hello World', size: 1, // optional - newKey: '' // optional + newKey: '', // optional }); ``` diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md index 8be0bfda..2eb06473 100644 --- a/docs/examples/tablesdb/update.md +++ b/docs/examples/tablesdb/update.md @@ -14,6 +14,6 @@ const result = await tablesDB.update({ enabled: false, // optional specification: 'serverless', // optional replicas: 0, // optional - syncMode: 'async' // optional + syncMode: 'async', // optional }); ``` diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index f544bc06..38257ec6 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -13,13 +13,13 @@ const result = await tablesDB.upsertRow({ tableId: '', rowId: '', data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 33, - "isAdmin": false + username: 'walter.obrien', + email: 'walter.obrien@example.com', + fullName: "Walter O'Brien", + age: 33, + isAdmin: false, }, // optional permissions: [sdk.Permission.read(sdk.Role.any())], // optional - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index 7bbf2ed3..fea4cbcb 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -12,6 +12,6 @@ const result = await tablesDB.upsertRows({ databaseId: '', tableId: '', rows: [], - transactionId: '' // optional + transactionId: '', // optional }); ``` diff --git a/docs/examples/teams/create-installation.md b/docs/examples/teams/create-installation.md index e84f9d89..30015e7a 100644 --- a/docs/examples/teams/create-installation.md +++ b/docs/examples/teams/create-installation.md @@ -11,6 +11,6 @@ const teams = new sdk.Teams(client); const result = await teams.createInstallation({ teamId: '', appId: '', - authorizationDetails: '' // optional + authorizationDetails: '', // optional }); ``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 910bb757..3aa45e3b 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -15,6 +15,6 @@ const result = await teams.createMembership({ userId: '', // optional phone: '+12065550100', // optional url: 'https://example.com', // optional - name: '' // optional + name: '', // optional }); ``` diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md index 8e5702b2..a26fdd0f 100644 --- a/docs/examples/teams/create.md +++ b/docs/examples/teams/create.md @@ -11,6 +11,6 @@ const teams = new sdk.Teams(client); const result = await teams.create({ teamId: '', name: '', - roles: [] // optional + roles: [], // optional }); ``` diff --git a/docs/examples/teams/delete-installation.md b/docs/examples/teams/delete-installation.md index d3631290..dd235d01 100644 --- a/docs/examples/teams/delete-installation.md +++ b/docs/examples/teams/delete-installation.md @@ -10,6 +10,6 @@ const teams = new sdk.Teams(client); const result = await teams.deleteInstallation({ teamId: '', - installationId: '' + installationId: '', }); ``` diff --git a/docs/examples/teams/delete-membership.md b/docs/examples/teams/delete-membership.md index 7dd11603..018a8da4 100644 --- a/docs/examples/teams/delete-membership.md +++ b/docs/examples/teams/delete-membership.md @@ -10,6 +10,6 @@ const teams = new sdk.Teams(client); const result = await teams.deleteMembership({ teamId: '', - membershipId: '' + membershipId: '', }); ``` diff --git a/docs/examples/teams/delete.md b/docs/examples/teams/delete.md index 8593956f..eb1c1dac 100644 --- a/docs/examples/teams/delete.md +++ b/docs/examples/teams/delete.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); const result = await teams.delete({ - teamId: '' + teamId: '', }); ``` diff --git a/docs/examples/teams/get-installation.md b/docs/examples/teams/get-installation.md index 47c71f3a..69456136 100644 --- a/docs/examples/teams/get-installation.md +++ b/docs/examples/teams/get-installation.md @@ -10,6 +10,6 @@ const teams = new sdk.Teams(client); const result = await teams.getInstallation({ teamId: '', - installationId: '' + installationId: '', }); ``` diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md index 4ecf078d..d0e27b6c 100644 --- a/docs/examples/teams/get-membership.md +++ b/docs/examples/teams/get-membership.md @@ -10,6 +10,6 @@ const teams = new sdk.Teams(client); const result = await teams.getMembership({ teamId: '', - membershipId: '' + membershipId: '', }); ``` diff --git a/docs/examples/teams/get-prefs.md b/docs/examples/teams/get-prefs.md index 0238bdba..fc121f7c 100644 --- a/docs/examples/teams/get-prefs.md +++ b/docs/examples/teams/get-prefs.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); const result = await teams.getPrefs({ - teamId: '' + teamId: '', }); ``` diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md index bd01c5c5..bc613444 100644 --- a/docs/examples/teams/get.md +++ b/docs/examples/teams/get.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); const result = await teams.get({ - teamId: '' + teamId: '', }); ``` diff --git a/docs/examples/teams/list-installations.md b/docs/examples/teams/list-installations.md index ecd4c420..07d25e91 100644 --- a/docs/examples/teams/list-installations.md +++ b/docs/examples/teams/list-installations.md @@ -11,6 +11,6 @@ const teams = new sdk.Teams(client); const result = await teams.listInstallations({ teamId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md index 1185380b..80269505 100644 --- a/docs/examples/teams/list-memberships.md +++ b/docs/examples/teams/list-memberships.md @@ -12,6 +12,6 @@ const result = await teams.listMemberships({ teamId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index b4525fba..3484c295 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -11,6 +11,6 @@ const teams = new sdk.Teams(client); const result = await teams.list({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/teams/update-installation.md b/docs/examples/teams/update-installation.md index f62bdfc7..b97c7c8b 100644 --- a/docs/examples/teams/update-installation.md +++ b/docs/examples/teams/update-installation.md @@ -11,6 +11,6 @@ const teams = new sdk.Teams(client); const result = await teams.updateInstallation({ teamId: '', installationId: '', - authorizationDetails: '' // optional + authorizationDetails: '', // optional }); ``` diff --git a/docs/examples/teams/update-membership-status.md b/docs/examples/teams/update-membership-status.md index 614737ec..51d22226 100644 --- a/docs/examples/teams/update-membership-status.md +++ b/docs/examples/teams/update-membership-status.md @@ -12,6 +12,6 @@ const result = await teams.updateMembershipStatus({ teamId: '', membershipId: '', userId: '', - secret: '' + secret: '', }); ``` diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 95a5c375..7b6fe57f 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -11,6 +11,6 @@ const teams = new sdk.Teams(client); const result = await teams.updateMembership({ teamId: '', membershipId: '', - roles: [] + roles: [], }); ``` diff --git a/docs/examples/teams/update-name.md b/docs/examples/teams/update-name.md index 0c64d2ba..e92a921c 100644 --- a/docs/examples/teams/update-name.md +++ b/docs/examples/teams/update-name.md @@ -10,6 +10,6 @@ const teams = new sdk.Teams(client); const result = await teams.updateName({ teamId: '', - name: '' + name: '', }); ``` diff --git a/docs/examples/teams/update-prefs.md b/docs/examples/teams/update-prefs.md index 180e3224..3f3e90d7 100644 --- a/docs/examples/teams/update-prefs.md +++ b/docs/examples/teams/update-prefs.md @@ -10,6 +10,6 @@ const teams = new sdk.Teams(client); const result = await teams.updatePrefs({ teamId: '', - prefs: {} + prefs: {}, }); ``` diff --git a/docs/examples/tokens/create-file-token.md b/docs/examples/tokens/create-file-token.md index bfb5d8d0..9161ed91 100644 --- a/docs/examples/tokens/create-file-token.md +++ b/docs/examples/tokens/create-file-token.md @@ -11,6 +11,6 @@ const tokens = new sdk.Tokens(client); const result = await tokens.createFileToken({ bucketId: '', fileId: '', - expire: '2020-10-15T06:38:00.000+00:00' // optional + expire: '2020-10-15T06:38:00.000+00:00', // optional }); ``` diff --git a/docs/examples/tokens/delete.md b/docs/examples/tokens/delete.md index f3b40894..01d424b6 100644 --- a/docs/examples/tokens/delete.md +++ b/docs/examples/tokens/delete.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const tokens = new sdk.Tokens(client); const result = await tokens.delete({ - tokenId: '' + tokenId: '', }); ``` diff --git a/docs/examples/tokens/get.md b/docs/examples/tokens/get.md index 383ea5f3..bd06de12 100644 --- a/docs/examples/tokens/get.md +++ b/docs/examples/tokens/get.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const tokens = new sdk.Tokens(client); const result = await tokens.get({ - tokenId: '' + tokenId: '', }); ``` diff --git a/docs/examples/tokens/list.md b/docs/examples/tokens/list.md index 13e48480..cd8bd9ea 100644 --- a/docs/examples/tokens/list.md +++ b/docs/examples/tokens/list.md @@ -12,6 +12,6 @@ const result = await tokens.list({ bucketId: '', fileId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/tokens/update.md b/docs/examples/tokens/update.md index 0ab3b168..3f3ddde7 100644 --- a/docs/examples/tokens/update.md +++ b/docs/examples/tokens/update.md @@ -10,6 +10,6 @@ const tokens = new sdk.Tokens(client); const result = await tokens.update({ tokenId: '', - expire: '2020-10-15T06:38:00.000+00:00' // optional + expire: '2020-10-15T06:38:00.000+00:00', // optional }); ``` diff --git a/docs/examples/users/create-argon-2-user.md b/docs/examples/users/create-argon-2-user.md index 4f45f7fd..7035e6d5 100644 --- a/docs/examples/users/create-argon-2-user.md +++ b/docs/examples/users/create-argon-2-user.md @@ -12,6 +12,6 @@ const result = await users.createArgon2User({ userId: '', email: 'email@example.com', password: 'password', - name: '' // optional + name: '', // optional }); ``` diff --git a/docs/examples/users/create-bcrypt-user.md b/docs/examples/users/create-bcrypt-user.md index 55100412..bbe9a74c 100644 --- a/docs/examples/users/create-bcrypt-user.md +++ b/docs/examples/users/create-bcrypt-user.md @@ -12,6 +12,6 @@ const result = await users.createBcryptUser({ userId: '', email: 'email@example.com', password: 'password', - name: '' // optional + name: '', // optional }); ``` diff --git a/docs/examples/users/create-jwt.md b/docs/examples/users/create-jwt.md index c2e6eaa4..cd0c49f0 100644 --- a/docs/examples/users/create-jwt.md +++ b/docs/examples/users/create-jwt.md @@ -10,7 +10,7 @@ const users = new sdk.Users(client); const result = await users.createJWT({ userId: '', - sessionId: '', // optional - duration: 0 // optional + sessionId: 'recent()', // optional + duration: 0, // optional }); ``` diff --git a/docs/examples/users/create-md-5-user.md b/docs/examples/users/create-md-5-user.md index 004c3b74..578ba7bc 100644 --- a/docs/examples/users/create-md-5-user.md +++ b/docs/examples/users/create-md-5-user.md @@ -12,6 +12,6 @@ const result = await users.createMD5User({ userId: '', email: 'email@example.com', password: 'password', - name: '' // optional + name: '', // optional }); ``` diff --git a/docs/examples/users/create-mfa-recovery-codes.md b/docs/examples/users/create-mfa-recovery-codes.md index 2f712022..e16cd645 100644 --- a/docs/examples/users/create-mfa-recovery-codes.md +++ b/docs/examples/users/create-mfa-recovery-codes.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); const result = await users.createMFARecoveryCodes({ - userId: '' + userId: '', }); ``` diff --git a/docs/examples/users/create-ph-pass-user.md b/docs/examples/users/create-ph-pass-user.md index 945f7476..b55fa428 100644 --- a/docs/examples/users/create-ph-pass-user.md +++ b/docs/examples/users/create-ph-pass-user.md @@ -12,6 +12,6 @@ const result = await users.createPHPassUser({ userId: '', email: 'email@example.com', password: 'password', - name: '' // optional + name: '', // optional }); ``` diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md index fc8a5e00..f574a9ed 100644 --- a/docs/examples/users/create-scrypt-modified-user.md +++ b/docs/examples/users/create-scrypt-modified-user.md @@ -15,6 +15,6 @@ const result = await users.createScryptModifiedUser({ passwordSalt: '', passwordSaltSeparator: '', passwordSignerKey: '', - name: '' // optional + name: '', // optional }); ``` diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md index e9a35358..e0d72dd5 100644 --- a/docs/examples/users/create-scrypt-user.md +++ b/docs/examples/users/create-scrypt-user.md @@ -13,10 +13,10 @@ const result = await users.createScryptUser({ email: 'email@example.com', password: 'password', passwordSalt: '', - passwordCpu: null, - passwordMemory: null, - passwordParallel: null, - passwordLength: null, - name: '' // optional + passwordCpu: 8, + passwordMemory: 65536, + passwordParallel: 1, + passwordLength: 64, + name: '', // optional }); ``` diff --git a/docs/examples/users/create-session.md b/docs/examples/users/create-session.md index 04e37680..2a06e1fa 100644 --- a/docs/examples/users/create-session.md +++ b/docs/examples/users/create-session.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); const result = await users.createSession({ - userId: '' + userId: '', }); ``` diff --git a/docs/examples/users/create-sha-user.md b/docs/examples/users/create-sha-user.md index 47c0d74b..97a0e4b8 100644 --- a/docs/examples/users/create-sha-user.md +++ b/docs/examples/users/create-sha-user.md @@ -13,6 +13,6 @@ const result = await users.createSHAUser({ email: 'email@example.com', password: 'password', passwordVersion: sdk.PasswordHash.Sha1, // optional - name: '' // optional + name: '', // optional }); ``` diff --git a/docs/examples/users/create-target.md b/docs/examples/users/create-target.md index bc19f2bf..e8e1053d 100644 --- a/docs/examples/users/create-target.md +++ b/docs/examples/users/create-target.md @@ -14,6 +14,6 @@ const result = await users.createTarget({ providerType: sdk.MessagingProviderType.Email, identifier: '', providerId: '', // optional - name: '' // optional + name: '', // optional }); ``` diff --git a/docs/examples/users/create-token.md b/docs/examples/users/create-token.md index 5978df65..6bfe5147 100644 --- a/docs/examples/users/create-token.md +++ b/docs/examples/users/create-token.md @@ -11,6 +11,6 @@ const users = new sdk.Users(client); const result = await users.createToken({ userId: '', length: 4, // optional - expire: 60 // optional + expire: 60, // optional }); ``` diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md index c93772d2..d552ca3c 100644 --- a/docs/examples/users/create.md +++ b/docs/examples/users/create.md @@ -13,6 +13,6 @@ const result = await users.create({ email: 'email@example.com', // optional phone: '+12065550100', // optional password: 'password', // optional - name: '' // optional + name: '', // optional }); ``` diff --git a/docs/examples/users/delete-identity.md b/docs/examples/users/delete-identity.md index 1a730d8d..2cd96a13 100644 --- a/docs/examples/users/delete-identity.md +++ b/docs/examples/users/delete-identity.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); const result = await users.deleteIdentity({ - identityId: '' + identityId: '', }); ``` diff --git a/docs/examples/users/delete-mfa-authenticator.md b/docs/examples/users/delete-mfa-authenticator.md index a5d4e3d0..5edacd77 100644 --- a/docs/examples/users/delete-mfa-authenticator.md +++ b/docs/examples/users/delete-mfa-authenticator.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.deleteMFAAuthenticator({ userId: '', - type: sdk.AuthenticatorType.Totp + type: sdk.AuthenticatorType.Totp, }); ``` diff --git a/docs/examples/users/delete-session.md b/docs/examples/users/delete-session.md index d39eccd0..dbc81ca9 100644 --- a/docs/examples/users/delete-session.md +++ b/docs/examples/users/delete-session.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.deleteSession({ userId: '', - sessionId: '' + sessionId: '', }); ``` diff --git a/docs/examples/users/delete-sessions.md b/docs/examples/users/delete-sessions.md index 9331435b..abde055f 100644 --- a/docs/examples/users/delete-sessions.md +++ b/docs/examples/users/delete-sessions.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); const result = await users.deleteSessions({ - userId: '' + userId: '', }); ``` diff --git a/docs/examples/users/delete-target.md b/docs/examples/users/delete-target.md index 3f579302..1136fad5 100644 --- a/docs/examples/users/delete-target.md +++ b/docs/examples/users/delete-target.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.deleteTarget({ userId: '', - targetId: '' + targetId: '', }); ``` diff --git a/docs/examples/users/delete.md b/docs/examples/users/delete.md index 8714dc59..326ac2a5 100644 --- a/docs/examples/users/delete.md +++ b/docs/examples/users/delete.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); const result = await users.delete({ - userId: '' + userId: '', }); ``` diff --git a/docs/examples/users/get-mfa-challenge.md b/docs/examples/users/get-mfa-challenge.md index b20e2c22..a782f349 100644 --- a/docs/examples/users/get-mfa-challenge.md +++ b/docs/examples/users/get-mfa-challenge.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.getMFAChallenge({ userId: '', - challengeId: '' + challengeId: '', }); ``` diff --git a/docs/examples/users/get-mfa-recovery-codes.md b/docs/examples/users/get-mfa-recovery-codes.md index 3e379926..45bd7a96 100644 --- a/docs/examples/users/get-mfa-recovery-codes.md +++ b/docs/examples/users/get-mfa-recovery-codes.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); const result = await users.getMFARecoveryCodes({ - userId: '' + userId: '', }); ``` diff --git a/docs/examples/users/get-prefs.md b/docs/examples/users/get-prefs.md index d81539e9..ce4fa9e2 100644 --- a/docs/examples/users/get-prefs.md +++ b/docs/examples/users/get-prefs.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); const result = await users.getPrefs({ - userId: '' + userId: '', }); ``` diff --git a/docs/examples/users/get-target.md b/docs/examples/users/get-target.md index 97ee9647..33a86401 100644 --- a/docs/examples/users/get-target.md +++ b/docs/examples/users/get-target.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.getTarget({ userId: '', - targetId: '' + targetId: '', }); ``` diff --git a/docs/examples/users/get.md b/docs/examples/users/get.md index 3f86f8c9..fa2bd0e9 100644 --- a/docs/examples/users/get.md +++ b/docs/examples/users/get.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); const result = await users.get({ - userId: '' + userId: '', }); ``` diff --git a/docs/examples/users/list-identities.md b/docs/examples/users/list-identities.md index e25c26f4..f2ecf287 100644 --- a/docs/examples/users/list-identities.md +++ b/docs/examples/users/list-identities.md @@ -11,6 +11,6 @@ const users = new sdk.Users(client); const result = await users.listIdentities({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md index 7cb97e27..9ed271f2 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/users/list-logs.md @@ -11,6 +11,6 @@ const users = new sdk.Users(client); const result = await users.listLogs({ userId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md index 0a758c00..b8cdcdae 100644 --- a/docs/examples/users/list-memberships.md +++ b/docs/examples/users/list-memberships.md @@ -12,6 +12,6 @@ const result = await users.listMemberships({ userId: '', queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/users/list-mfa-factors.md b/docs/examples/users/list-mfa-factors.md index 9272a20c..9685721f 100644 --- a/docs/examples/users/list-mfa-factors.md +++ b/docs/examples/users/list-mfa-factors.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); const result = await users.listMFAFactors({ - userId: '' + userId: '', }); ``` diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md index d941dcfb..fb163e25 100644 --- a/docs/examples/users/list-sessions.md +++ b/docs/examples/users/list-sessions.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.listSessions({ userId: '', - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/users/list-targets.md b/docs/examples/users/list-targets.md index aa7be748..9ec0bb0f 100644 --- a/docs/examples/users/list-targets.md +++ b/docs/examples/users/list-targets.md @@ -11,6 +11,6 @@ const users = new sdk.Users(client); const result = await users.listTargets({ userId: '', queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index 916dabc0..04b3ead4 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -11,6 +11,6 @@ const users = new sdk.Users(client); const result = await users.list({ queries: [], // optional search: '', // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/users/update-email-verification.md b/docs/examples/users/update-email-verification.md index 7a43202d..2fcca5df 100644 --- a/docs/examples/users/update-email-verification.md +++ b/docs/examples/users/update-email-verification.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.updateEmailVerification({ userId: '', - emailVerification: false + emailVerification: false, }); ``` diff --git a/docs/examples/users/update-email.md b/docs/examples/users/update-email.md index 10cf0027..f465f32d 100644 --- a/docs/examples/users/update-email.md +++ b/docs/examples/users/update-email.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.updateEmail({ userId: '', - email: 'email@example.com' + email: 'email@example.com', }); ``` diff --git a/docs/examples/users/update-impersonator.md b/docs/examples/users/update-impersonator.md index a41d11dc..7fe71a37 100644 --- a/docs/examples/users/update-impersonator.md +++ b/docs/examples/users/update-impersonator.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.updateImpersonator({ userId: '', - impersonator: false + impersonator: false, }); ``` diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 28f28931..e74ec102 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.updateLabels({ userId: '', - labels: [] + labels: [], }); ``` diff --git a/docs/examples/users/update-mfa-recovery-codes.md b/docs/examples/users/update-mfa-recovery-codes.md index 41fa921e..5f5f3c40 100644 --- a/docs/examples/users/update-mfa-recovery-codes.md +++ b/docs/examples/users/update-mfa-recovery-codes.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); const result = await users.updateMFARecoveryCodes({ - userId: '' + userId: '', }); ``` diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md index c62e10fc..e6dc0ec2 100644 --- a/docs/examples/users/update-mfa.md +++ b/docs/examples/users/update-mfa.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.updateMFA({ userId: '', - mfa: false + mfa: false, }); ``` diff --git a/docs/examples/users/update-name.md b/docs/examples/users/update-name.md index 03369c9c..16816e3a 100644 --- a/docs/examples/users/update-name.md +++ b/docs/examples/users/update-name.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.updateName({ userId: '', - name: '' + name: '', }); ``` diff --git a/docs/examples/users/update-password.md b/docs/examples/users/update-password.md index 5cadfdba..fe8f33aa 100644 --- a/docs/examples/users/update-password.md +++ b/docs/examples/users/update-password.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.updatePassword({ userId: '', - password: 'password' + password: 'password', }); ``` diff --git a/docs/examples/users/update-phone-verification.md b/docs/examples/users/update-phone-verification.md index 4489902d..b850d97f 100644 --- a/docs/examples/users/update-phone-verification.md +++ b/docs/examples/users/update-phone-verification.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.updatePhoneVerification({ userId: '', - phoneVerification: false + phoneVerification: false, }); ``` diff --git a/docs/examples/users/update-phone.md b/docs/examples/users/update-phone.md index d45d5ed0..e29f7960 100644 --- a/docs/examples/users/update-phone.md +++ b/docs/examples/users/update-phone.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.updatePhone({ userId: '', - number: '+12065550100' + number: '+12065550100', }); ``` diff --git a/docs/examples/users/update-prefs.md b/docs/examples/users/update-prefs.md index 3bb011ae..c041e37c 100644 --- a/docs/examples/users/update-prefs.md +++ b/docs/examples/users/update-prefs.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.updatePrefs({ userId: '', - prefs: {} + prefs: {}, }); ``` diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md index ec7d5bdb..87c273c8 100644 --- a/docs/examples/users/update-status.md +++ b/docs/examples/users/update-status.md @@ -10,6 +10,6 @@ const users = new sdk.Users(client); const result = await users.updateStatus({ userId: '', - status: false + status: false, }); ``` diff --git a/docs/examples/users/update-target.md b/docs/examples/users/update-target.md index d1dcf74a..f6ab1624 100644 --- a/docs/examples/users/update-target.md +++ b/docs/examples/users/update-target.md @@ -13,6 +13,6 @@ const result = await users.updateTarget({ targetId: '', identifier: '', // optional providerId: '', // optional - name: '' // optional + name: '', // optional }); ``` diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md new file mode 100644 index 00000000..d7ccf535 --- /dev/null +++ b/docs/examples/vectorsdb/create-collection.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.createCollection({ + databaseId: '', + collectionId: '', + name: '', + dimension: 1, + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + documentSecurity: false, // optional + enabled: false, // optional +}); +``` diff --git a/docs/examples/vectorsdb/create-document.md b/docs/examples/vectorsdb/create-document.md new file mode 100644 index 00000000..fc9114a2 --- /dev/null +++ b/docs/examples/vectorsdb/create-document.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 + .setSession(''); // The user session to authenticate with + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.createDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: { + embeddings: [0.12, -0.55, 0.88, 1.02], + metadata: { + key: 'value', + }, + }, + permissions: [sdk.Permission.read(sdk.Role.any())], // optional +}); +``` diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md new file mode 100644 index 00000000..906ec6ae --- /dev/null +++ b/docs/examples/vectorsdb/create-documents.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.createDocuments({ + databaseId: '', + collectionId: '', + documents: [], +}); +``` diff --git a/docs/examples/vectorsdb/create-failover.md b/docs/examples/vectorsdb/create-failover.md new file mode 100644 index 00000000..1fe5b24e --- /dev/null +++ b/docs/examples/vectorsdb/create-failover.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.createFailover({ + databaseId: '', + targetReplicaId: '', // optional +}); +``` diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md new file mode 100644 index 00000000..4b092220 --- /dev/null +++ b/docs/examples/vectorsdb/create-index.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.createIndex({ + databaseId: '', + collectionId: '', + key: '', + type: sdk.VectorsDBIndexType.HnswEuclidean, + attributes: [], + orders: [sdk.OrderBy.Asc], // optional + lengths: [], // optional +}); +``` diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md new file mode 100644 index 00000000..3804aeed --- /dev/null +++ b/docs/examples/vectorsdb/create-operations.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.createOperations({ + transactionId: '', + operations: [ + { + action: 'create', + databaseId: '', + collectionId: '', + documentId: '', + data: { + name: "Walter O'Brien", + }, + }, + ], // optional +}); +``` diff --git a/docs/examples/vectorsdb/create-query.md b/docs/examples/vectorsdb/create-query.md new file mode 100644 index 00000000..cf98dd23 --- /dev/null +++ b/docs/examples/vectorsdb/create-query.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.createQuery({ + databaseId: '', + collectionId: '', + queries: [], // optional + transactionId: '', // optional + total: false, // optional + ttl: 0, // optional +}); +``` diff --git a/docs/examples/vectorsdb/create-transaction.md b/docs/examples/vectorsdb/create-transaction.md new file mode 100644 index 00000000..1e4fd6d4 --- /dev/null +++ b/docs/examples/vectorsdb/create-transaction.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.createTransaction({ + ttl: 60, // optional +}); +``` diff --git a/docs/examples/vectorsdb/create.md b/docs/examples/vectorsdb/create.md new file mode 100644 index 00000000..8fbd31da --- /dev/null +++ b/docs/examples/vectorsdb/create.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.create({ + databaseId: '', + name: '', + enabled: false, // optional + specification: 'serverless', // optional + replicas: 0, // optional + syncMode: 'async', // optional +}); +``` diff --git a/docs/examples/vectorsdb/delete-collection.md b/docs/examples/vectorsdb/delete-collection.md new file mode 100644 index 00000000..21aa353d --- /dev/null +++ b/docs/examples/vectorsdb/delete-collection.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.deleteCollection({ + databaseId: '', + collectionId: '', +}); +``` diff --git a/docs/examples/vectorsdb/delete-document.md b/docs/examples/vectorsdb/delete-document.md new file mode 100644 index 00000000..c2f27c3b --- /dev/null +++ b/docs/examples/vectorsdb/delete-document.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 + .setSession(''); // The user session to authenticate with + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.deleteDocument({ + databaseId: '', + collectionId: '', + documentId: '', + transactionId: '', // optional +}); +``` diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md new file mode 100644 index 00000000..a3905b37 --- /dev/null +++ b/docs/examples/vectorsdb/delete-documents.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.deleteDocuments({ + databaseId: '', + collectionId: '', + queries: [], // optional + transactionId: '', // optional +}); +``` diff --git a/docs/examples/vectorsdb/delete-index.md b/docs/examples/vectorsdb/delete-index.md new file mode 100644 index 00000000..2362e3fc --- /dev/null +++ b/docs/examples/vectorsdb/delete-index.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.deleteIndex({ + databaseId: '', + collectionId: '', + key: '', +}); +``` diff --git a/docs/examples/vectorsdb/delete-transaction.md b/docs/examples/vectorsdb/delete-transaction.md new file mode 100644 index 00000000..4871cf84 --- /dev/null +++ b/docs/examples/vectorsdb/delete-transaction.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.deleteTransaction({ + transactionId: '', +}); +``` diff --git a/docs/examples/vectorsdb/delete.md b/docs/examples/vectorsdb/delete.md new file mode 100644 index 00000000..486889a5 --- /dev/null +++ b/docs/examples/vectorsdb/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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.delete({ + databaseId: '', +}); +``` diff --git a/docs/examples/vectorsdb/get-collection.md b/docs/examples/vectorsdb/get-collection.md new file mode 100644 index 00000000..147cfa8b --- /dev/null +++ b/docs/examples/vectorsdb/get-collection.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.getCollection({ + databaseId: '', + collectionId: '', +}); +``` diff --git a/docs/examples/vectorsdb/get-document.md b/docs/examples/vectorsdb/get-document.md new file mode 100644 index 00000000..a414c9cd --- /dev/null +++ b/docs/examples/vectorsdb/get-document.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 + .setSession(''); // The user session to authenticate with + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.getDocument({ + databaseId: '', + collectionId: '', + documentId: '', + queries: [], // optional + transactionId: '', // optional +}); +``` diff --git a/docs/examples/vectorsdb/get-index.md b/docs/examples/vectorsdb/get-index.md new file mode 100644 index 00000000..9b7abb04 --- /dev/null +++ b/docs/examples/vectorsdb/get-index.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.getIndex({ + databaseId: '', + collectionId: '', + key: '', +}); +``` diff --git a/docs/examples/vectorsdb/get-replicas.md b/docs/examples/vectorsdb/get-replicas.md new file mode 100644 index 00000000..7ce16fa6 --- /dev/null +++ b/docs/examples/vectorsdb/get-replicas.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.getReplicas({ + databaseId: '', +}); +``` diff --git a/docs/examples/vectorsdb/get-status.md b/docs/examples/vectorsdb/get-status.md new file mode 100644 index 00000000..cb2b35d5 --- /dev/null +++ b/docs/examples/vectorsdb/get-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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.getStatus({ + databaseId: '', +}); +``` diff --git a/docs/examples/vectorsdb/get-transaction.md b/docs/examples/vectorsdb/get-transaction.md new file mode 100644 index 00000000..68437bc0 --- /dev/null +++ b/docs/examples/vectorsdb/get-transaction.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.getTransaction({ + transactionId: '', +}); +``` diff --git a/docs/examples/vectorsdb/get.md b/docs/examples/vectorsdb/get.md new file mode 100644 index 00000000..3ea49d65 --- /dev/null +++ b/docs/examples/vectorsdb/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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.get({ + databaseId: '', +}); +``` diff --git a/docs/examples/vectorsdb/list-collections.md b/docs/examples/vectorsdb/list-collections.md new file mode 100644 index 00000000..e3a509eb --- /dev/null +++ b/docs/examples/vectorsdb/list-collections.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.listCollections({ + databaseId: '', + queries: [], // optional + search: '', // optional + total: false, // optional +}); +``` diff --git a/docs/examples/vectorsdb/list-documents.md b/docs/examples/vectorsdb/list-documents.md new file mode 100644 index 00000000..c2b4b6ed --- /dev/null +++ b/docs/examples/vectorsdb/list-documents.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.listDocuments({ + databaseId: '', + collectionId: '', + queries: [], // optional + transactionId: '', // optional + total: false, // optional + ttl: 0, // optional +}); +``` diff --git a/docs/examples/vectorsdb/list-indexes.md b/docs/examples/vectorsdb/list-indexes.md new file mode 100644 index 00000000..b0c5b8e2 --- /dev/null +++ b/docs/examples/vectorsdb/list-indexes.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.listIndexes({ + databaseId: '', + collectionId: '', + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/vectorsdb/list-operations.md b/docs/examples/vectorsdb/list-operations.md new file mode 100644 index 00000000..a28e8f4d --- /dev/null +++ b/docs/examples/vectorsdb/list-operations.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.listOperations({ + databaseId: '', + status: 'queued', // optional + limit: 1, // optional + offset: 0, // optional +}); +``` diff --git a/docs/examples/vectorsdb/list-specifications.md b/docs/examples/vectorsdb/list-specifications.md new file mode 100644 index 00000000..1c281fa4 --- /dev/null +++ b/docs/examples/vectorsdb/list-specifications.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 + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.listSpecifications(); +``` diff --git a/docs/examples/vectorsdb/list-transactions.md b/docs/examples/vectorsdb/list-transactions.md new file mode 100644 index 00000000..3dfb2732 --- /dev/null +++ b/docs/examples/vectorsdb/list-transactions.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.listTransactions({ + queries: [], // optional +}); +``` diff --git a/docs/examples/vectorsdb/list.md b/docs/examples/vectorsdb/list.md new file mode 100644 index 00000000..55418e83 --- /dev/null +++ b/docs/examples/vectorsdb/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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.list({ + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md new file mode 100644 index 00000000..4f546542 --- /dev/null +++ b/docs/examples/vectorsdb/update-collection.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.updateCollection({ + databaseId: '', + collectionId: '', + name: '', + dimension: 1, // optional + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + documentSecurity: false, // optional + enabled: false, // optional +}); +``` diff --git a/docs/examples/vectorsdb/update-document.md b/docs/examples/vectorsdb/update-document.md new file mode 100644 index 00000000..2c9fe650 --- /dev/null +++ b/docs/examples/vectorsdb/update-document.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.updateDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: {}, // optional + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + transactionId: '', // optional +}); +``` diff --git a/docs/examples/vectorsdb/update-documents.md b/docs/examples/vectorsdb/update-documents.md new file mode 100644 index 00000000..70278246 --- /dev/null +++ b/docs/examples/vectorsdb/update-documents.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.updateDocuments({ + databaseId: '', + collectionId: '', + data: {}, // optional + queries: [], // optional + transactionId: '', // optional +}); +``` diff --git a/docs/examples/vectorsdb/update-transaction.md b/docs/examples/vectorsdb/update-transaction.md new file mode 100644 index 00000000..5543dfce --- /dev/null +++ b/docs/examples/vectorsdb/update-transaction.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.updateTransaction({ + transactionId: '', + commit: false, // optional + rollback: false, // optional +}); +``` diff --git a/docs/examples/vectorsdb/update.md b/docs/examples/vectorsdb/update.md new file mode 100644 index 00000000..09108e70 --- /dev/null +++ b/docs/examples/vectorsdb/update.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.update({ + databaseId: '', + name: '', + enabled: false, // optional + specification: 'serverless', // optional + replicas: 0, // optional + syncMode: 'async', // optional +}); +``` diff --git a/docs/examples/vectorsdb/upsert-document.md b/docs/examples/vectorsdb/upsert-document.md new file mode 100644 index 00000000..26ec74e6 --- /dev/null +++ b/docs/examples/vectorsdb/upsert-document.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.upsertDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: {}, // optional + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + transactionId: '', // optional +}); +``` diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md new file mode 100644 index 00000000..38079b97 --- /dev/null +++ b/docs/examples/vectorsdb/upsert-documents.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 vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.upsertDocuments({ + databaseId: '', + collectionId: '', + documents: [], + transactionId: '', // optional +}); +``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index 75c778c3..21ecaccc 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -10,13 +10,13 @@ const webhooks = new sdk.Webhooks(client); const result = await webhooks.create({ webhookId: '', - url: '', + url: 'https://example.com/webhook', name: '', events: [], enabled: false, // optional tls: false, // optional authUsername: '', // optional authPassword: 'password', // optional - secret: '' // optional + secret: '', // optional }); ``` diff --git a/docs/examples/webhooks/delete.md b/docs/examples/webhooks/delete.md index 51639e22..ecdfcd08 100644 --- a/docs/examples/webhooks/delete.md +++ b/docs/examples/webhooks/delete.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const webhooks = new sdk.Webhooks(client); const result = await webhooks.delete({ - webhookId: '' + webhookId: '', }); ``` diff --git a/docs/examples/webhooks/get.md b/docs/examples/webhooks/get.md index 07d1ecda..02c4eac3 100644 --- a/docs/examples/webhooks/get.md +++ b/docs/examples/webhooks/get.md @@ -9,6 +9,6 @@ const client = new sdk.Client() const webhooks = new sdk.Webhooks(client); const result = await webhooks.get({ - webhookId: '' + webhookId: '', }); ``` diff --git a/docs/examples/webhooks/list.md b/docs/examples/webhooks/list.md index f509df71..cab8f126 100644 --- a/docs/examples/webhooks/list.md +++ b/docs/examples/webhooks/list.md @@ -10,6 +10,6 @@ const webhooks = new sdk.Webhooks(client); const result = await webhooks.list({ queries: [], // optional - total: false // optional + total: false, // optional }); ``` diff --git a/docs/examples/webhooks/update-secret.md b/docs/examples/webhooks/update-secret.md index 7c0e504c..73a41aab 100644 --- a/docs/examples/webhooks/update-secret.md +++ b/docs/examples/webhooks/update-secret.md @@ -10,6 +10,6 @@ const webhooks = new sdk.Webhooks(client); const result = await webhooks.updateSecret({ webhookId: '', - secret: '' // optional + secret: '', // optional }); ``` diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index f83021c4..25362bf1 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -11,11 +11,11 @@ const webhooks = new sdk.Webhooks(client); const result = await webhooks.update({ webhookId: '', name: '', - url: '', + url: 'https://example.com/webhook', events: [], enabled: false, // optional tls: false, // optional authUsername: '', // optional - authPassword: 'password' // optional + authPassword: 'password', // optional }); ``` diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..714d2380 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,43 @@ +import eslint from '@eslint/js'; +import globals from 'globals'; +import tseslint from 'typescript-eslint'; + +export default tseslint.config( + eslint.configs.recommended, + tseslint.configs.recommended, + { + ignores: ['dist/', 'types/', 'docs/', 'rollup.config.mjs'], + }, + { + // The generated Jest suite is CommonJS and runs against the build + // output, so it needs Node globals and `require`. + files: ['test/**/*.js'], + languageOptions: { + globals: { ...globals.node, ...globals.jest }, + }, + rules: { + '@typescript-eslint/no-require-imports': 'off', + }, + }, + { + rules: { + // The SDK deliberately exposes loosely-typed surfaces (payloads, + // model generics defaulting to open records), so `any` is part of + // its public contract rather than an oversight. + '@typescript-eslint/no-explicit-any': 'off', + // Empty responses are typed `Promise<{}>` and the models are + // published under the `Models` namespace; both are part of the + // SDK's public API and cannot change without a breaking release. + '@typescript-eslint/no-empty-object-type': 'off', + '@typescript-eslint/no-namespace': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { + argsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', + destructuredArrayIgnorePattern: '^_', + }, + ], + }, + }, +); diff --git a/package-lock.json b/package-lock.json index ddaddf75..d1bb80e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,25 +1,30 @@ { "name": "node-appwrite", - "version": "28.0.0", + "version": "29.0.0-rc.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-appwrite", - "version": "28.0.0", + "version": "29.0.0-rc.1", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0", "undici": "^6.27.0" }, "devDependencies": { + "@eslint/js": "10.0.1", "@types/json-bigint": "1.0.4", "@types/node": "26.2.0", "esbuild-plugin-file-path-extensions": "^2.0.0", + "eslint": "10.9.0", + "globals": "16.5.0", "jest": "^30.4.2", + "prettier": "3.9.6", "tslib": "2.8.1", "tsup": "^8.5.1", - "typescript": "5.9.3" + "typescript": "5.9.3", + "typescript-eslint": "8.67.0" }, "overrides": { "esbuild": "^0.28.1", @@ -999,6 +1004,200 @@ "node": ">=18" } }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.10.1.tgz", + "integrity": "sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.2.tgz", + "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.23.5", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.5.tgz", + "integrity": "sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^3.0.5", + "debug": "^4.3.1", + "minimatch": "^10.2.4" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/config-helpers": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.7.0.tgz", + "integrity": "sha512-DObd/KKUsU+FaFv4PLxSRenpXfQWmPXXP3pPZ6/K1PCrMu2vQpMDMuQe/BqYeoLcz8ro0bVDF1RxOJgfVEdhUw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^1.2.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/core": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-1.2.1.tgz", + "integrity": "sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/js": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-10.0.1.tgz", + "integrity": "sha512-zeR9k5pd4gxjZ0abRoIaxdc7I3nDktoXZk2qOv9gCNWx3mVwEn32VRhyLaRsDiJjTs0xq/T8mfPtyuXu7GWBcA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "eslint": "^10.0.0" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "node_modules/@eslint/object-schema": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-3.0.5.tgz", + "integrity": "sha512-vqTaUEgxzm+YDSdElad6PiRoX4t8VGDjCtt05zn4nU810UIx/uNEV7/lZJ6KwFThKZOzOxzXy48da+No7HZaMw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.7.2.tgz", + "integrity": "sha512-+CNAzxglkrpNf/kKywqQfk74QjtceuOE7Qm+AF8miRvPF/wmmK5+OJOgVh3AVTT3RP2mH3+FOaxlE5v72owk0A==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^1.2.1", + "levn": "^0.4.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@humanfs/core": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz", + "integrity": "sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/types": "^0.15.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.8", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.8.tgz", + "integrity": "sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.2", + "@humanfs/types": "^0.15.0", + "@humanwhocodes/retry": "^0.4.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/types": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@humanfs/types/-/types-0.15.0.tgz", + "integrity": "sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", + "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -1034,6 +1233,62 @@ "node": ">=8" } }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@istanbuljs/schema": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.6.tgz", @@ -1443,9 +1698,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1456,9 +1708,9 @@ } }, "node_modules/@napi-rs/wasm-runtime": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.2.tgz", - "integrity": "sha512-JfB4kuJQjaoHuCTseIINHtHWeJnvgEcxjwA5t/Y00ZgaOO1Crz3fjT/p8kT28zA/Caz7oiUMn3d6H2yOVCVwuw==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.3.tgz", + "integrity": "sha512-UMduMbqO5s5zF2NkNacMT/yK5Y5QiKvWr2+50bzIIxFDwVJ2h49b+oyjaCGPhJxd2/gC2x39EHv/gHVuu36x2Q==", "dev": true, "license": "MIT", "optional": true, @@ -1473,8 +1725,8 @@ "url": "https://github.com/sponsors/Brooooooklyn" }, "peerDependencies": { - "@emnapi/core": "^1.7.1 || ^2.0.0-alpha.3", - "@emnapi/runtime": "^1.7.1 || ^2.0.0-alpha.3" + "@emnapi/core": "^1.7.1 || ^2.0.0-alpha.4", + "@emnapi/runtime": "^1.7.1 || ^2.0.0-alpha.4" } }, "node_modules/@pkgjs/parseargs": { @@ -1502,9 +1754,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.62.4.tgz", - "integrity": "sha512-RrPokAb7dmbxFoeO3TloqHyOjgye8RkBhSqmp4aJMIex4c9r46ZstPnleDQOq1t46VOVjwIuwNogIqbodV1Vvg==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.62.5.tgz", + "integrity": "sha512-jfkGfTwhQpsiSckPF8r9bU3pn3vyd72NlWaO+TgEO6WPSDnUhXzrNYCHBMOYj0ACaUgjm6eERLF+XV9a6RstoA==", "cpu": [ "arm" ], @@ -1516,9 +1768,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.62.4.tgz", - "integrity": "sha512-JKuJc+pnpks2pjy7L/N3v/cAkZxYlnmuZoD840ldbMI5KDbC4iO9NKwPKYdjYFCMAIIlBzYSFHxIJVYzRo2/8A==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.62.5.tgz", + "integrity": "sha512-oGVqyQlxnrz9/ty89oHpU857VUHEl5/Xu4R2lS+aivCTrNnSsbiENzTnNaBsjxH0CNWGPhzHArOLFwo+oKXveA==", "cpu": [ "arm64" ], @@ -1530,9 +1782,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.62.4.tgz", - "integrity": "sha512-krw5uS2STmvJ02x0uTXHbqQNuz+9eZ1iw+qXk9dmW2gvV4jV7O2hEoOnuhFrpOPiel1mBFtqbxYZZtC46hXLOw==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.62.5.tgz", + "integrity": "sha512-bW7B8xMEq8n99Q3ieEcPRGuphurdZAaFzQc9Efyyw3FL6DZO6pMy9xhdN+kBoD7Sy05xNXSr4OyPPnpkYriS/A==", "cpu": [ "arm64" ], @@ -1544,9 +1796,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.62.4.tgz", - "integrity": "sha512-wsTxtgApb4PrOsNJIm0FZ1h3WvCC+k9uxLJ4ad75hgoS4NiRes2SoJFlDAyMwiUY8IssDqGcHbXuN0sx1tfF1A==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.62.5.tgz", + "integrity": "sha512-YSwBS86QeHOGlrxJ1PSOIZSkzRL/JmKeunhc+lV6M1a6En8QuVCD/T/qIA0J4Gd2Y86RIOBYrLcOUtqGh9+/1w==", "cpu": [ "x64" ], @@ -1558,9 +1810,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.62.4.tgz", - "integrity": "sha512-GUOnQlyZe3yAXhWOtOMsn5Qkrv5E5mZXa0thbARWi5Ei2szlVXJFQhddZ4HbAzh8q92w5twp+CQvs/eFanz9YQ==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.62.5.tgz", + "integrity": "sha512-2fST8lILgl7cKbme/1KDdPCmbXbG+gqoV3bHp19L0ypX/3akYMBVdOunPleRCwonoLnXOZ/0F+Mt/v8POFmfcQ==", "cpu": [ "arm64" ], @@ -1572,9 +1824,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.62.4.tgz", - "integrity": "sha512-/Y7f3QuxjzPKsjA/rfEDa3+0vXqyjmJ50Ln8dPpCmWkKTrUoWHG1cWhTqaAMLob2m2nESWuC7yGrREz019Ztqg==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.62.5.tgz", + "integrity": "sha512-cpIxQCP9J+EVad0a6LO1kY3ZGODlk80VlI+2I96B8xMcdHZ4pLVhfQ49JFpYqjPF91FFkQWftf57YlDcTiw9yQ==", "cpu": [ "x64" ], @@ -1586,16 +1838,13 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.62.4.tgz", - "integrity": "sha512-81wiiX3v7aqy+T+bT61TJ78yJjRquqFFTTbAPt08imfQQzkPIW8t6aJbkTagtCCrXMNc9D66+geqlK7ydLPNqA==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.62.5.tgz", + "integrity": "sha512-r9fGh3eFs3e/udWh5ZjXQtxiYK/xoFxQaYR/cELxac/Udkl5Th+IsFm0CX3Kl9hmUH/we7EoMpjJgeQNnE0+IA==", "cpu": [ "arm" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1603,16 +1852,13 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.62.4.tgz", - "integrity": "sha512-9kmDIvNZqdoHOBZgNtpTBeLWYO/LVipM3H/j62P8848/l/VPEQL6N3uxU9pvP1oZAsXyC2MEnFP3ovRjo7WYNQ==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.62.5.tgz", + "integrity": "sha512-xdvFdp7OM6KLJviJT2g/YuRSUjnZgGHk4RNgwIbN7X6cPugOucV60DdHXWzsBVCUdrGb6qSXnJQrrAKMmQuj3Q==", "cpu": [ "arm" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1620,16 +1866,13 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.62.4.tgz", - "integrity": "sha512-CcnXHWnXg69g+DX5VWL3FHts3qMRN2uVEHX+BZvGLdd07/gXkn3ePjYtO1LDJvxkGKVHMclKBRa1QUTH+6toYQ==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.62.5.tgz", + "integrity": "sha512-rRqILAndyzHzP7T9NFQrq+4HFWNhqkqkKur7eiBpfLmz01PO0JKx5Vchu3YllE4YXI/Ftgq/szrDWg5GJ0mI8g==", "cpu": [ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1637,16 +1880,13 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.62.4.tgz", - "integrity": "sha512-iFOibiHnTRuhrWLlRsOQFdZJJIa7S8OwkneJr4ocALP16u5yk6lWLINFwhHaEqBFMsKDUZofLkGos7+CPzGB3g==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.62.5.tgz", + "integrity": "sha512-Gf4X3qVMucayUvux6aXXPgXovocSFUC0rrffDuPI/S2nHhNMhjcZxsrAFYCOF350PRreW1XwzFj3CT/3bKsWCw==", "cpu": [ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1654,16 +1894,13 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-gnu": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.62.4.tgz", - "integrity": "sha512-XnWYMI7euHlb5a871xPja+Gm7DRCFU+FGRrtS2sMq9N8FvqtpagUy6gD4YOemC5MRk9xbh8+jYMEJbigFQwsgA==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.62.5.tgz", + "integrity": "sha512-+s5qA0TNM0qm8PK/a5gt/1Hpx+NV08uSuCncvhziIlQzT6AEV2fnUQo7eBtFTFO0nA9scauvoR2HusfXmQnO4w==", "cpu": [ "loong64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1671,16 +1908,13 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-musl": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.62.4.tgz", - "integrity": "sha512-qGDAlO0U8xedCcsdRm9oaoQY8DAx/QT7uIxJWhCdx0ceIWX783UC9QSYkdpzAe29wNiVfp24+bZdQmn49o45SQ==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.62.5.tgz", + "integrity": "sha512-ybb6QvWwWJCbBWqERpc8K3pYVGIrXlG8MEQ8IIuJY6Y9KdHQxoFoNyfkAOtKn1VHu3KuLidXvwrvGR1mEjeWCw==", "cpu": [ "loong64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1688,16 +1922,13 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-gnu": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.62.4.tgz", - "integrity": "sha512-ru4H6ezD7ysA5EiEK6qkkaEb4modH8CTej6kUy/gQi20u3kB3G7Zn8snXXkeJSCOFKG/rbPPtM/+9Wgas1961w==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.62.5.tgz", + "integrity": "sha512-nZb1DtnOyhCmYvsC8A2CwOkopVg+IS1+fPUa7rMOAXtNw5+lLCLLPqd6XAiNrGtoQKsbvIBOwsHnBH/3wnb4HQ==", "cpu": [ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1705,16 +1936,13 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-musl": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.62.4.tgz", - "integrity": "sha512-2W4MO5WQVJnbJaZdvDb9rhBDuFU1nKIepPFpJUBsTh2k1YY2g+ODViaWuyOAjQ5cOP7NvrvLzt3wvHOoiAvc7w==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.62.5.tgz", + "integrity": "sha512-yMbj63Sp89ryrXLWyz+sy+fYD2HpOnMCLGbe4Oa1smclFSUukdtD/BgdiHaAetJNb74URD8U4hM+qG5KVzMEkg==", "cpu": [ "ppc64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1722,16 +1950,13 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.62.4.tgz", - "integrity": "sha512-+fxjfuoAmVMCYV5QyjoIpu0cp5DOiOTeqYFk1AVaxGr+/ravWLX89XfQmptsoWcaVy/TGf2hexzbUOrCQIL1CQ==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.62.5.tgz", + "integrity": "sha512-mhoan3OJw2kYV/e1jtIdmvUZgyBFeA6zGWsOswmR0Tg19TQbowZuR+JMLID6spbbBN7Zee2ejrgmy3+FxGrIdA==", "cpu": [ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1739,16 +1964,13 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.62.4.tgz", - "integrity": "sha512-jTn8JfHGL4djjFxPuM06LmNUJDsst2jeVlsd9OmIH6zc5sC9K6rIuO4YajXatLUpBmBKl6b35ro1QZocLi+tcA==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.62.5.tgz", + "integrity": "sha512-5ZTLmjWbb1VZdjuyhe83K/8QO0/h11midQCBP+X5OYn32ra7eOBoM0ZqtaY4nkgNsYgmdVhMYPoyVPTjUpHf3w==", "cpu": [ "riscv64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1756,16 +1978,13 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.62.4.tgz", - "integrity": "sha512-oCJCJL4pXsoDcP2QZ+JVlPTIRc6266zsIaeJJsWImmF7HO0W8nb6HuSgZlMWxJwaPf8ehbSw8yo0EUw925hKsA==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.62.5.tgz", + "integrity": "sha512-m53kG+br6PGxOTmgBEM2DHSDs9RVjsyEbUwjJPJGTFm1grWOG8EKJggDCTb60unD4Tjby8fi7/m9XfkEWasVWg==", "cpu": [ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1773,16 +1992,13 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.62.4.tgz", - "integrity": "sha512-W69hukhZ3KKNRCaMIEzKvcFye42hh0FE1+YoYaf5+Ikacuftoco6yO/xouz0hc5d5W/s3yBro5jRiuEE/Q5vUw==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.62.5.tgz", + "integrity": "sha512-6RHPJR1g/uvdYU8uXBnfq3nlqyZCP82Fr6NHgfGoaIeSh0YEqnX/x6uA9MmJJbnSH7swqX4F+CkGdUF+6doiQA==", "cpu": [ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1790,16 +2006,13 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.62.4.tgz", - "integrity": "sha512-qiXbGG2jkjXhzXpsFZSR2Xpb8DN/UaxYsbb/STbuR/6fpaDgRmmaq1B/LmtF2wQFOFOSsK2jdE0RZ3a0zHn4QA==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.62.5.tgz", + "integrity": "sha512-xs+OXQtEXgpXT0DmA5+U3qnRZHdCST/5HRQxS8wSPZTUZN/EMWeHuSIod32LQklTBZBV9DyfncKBQ8n5V3eFdw==", "cpu": [ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1807,9 +2020,9 @@ ] }, "node_modules/@rollup/rollup-openbsd-x64": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.62.4.tgz", - "integrity": "sha512-nWeM//hxv8mIo6jD7Hu4o48DVmV9pbV6gsKaWU+4NFyqHoPKwrkRiZGLKUhOBk8qNmDmpwFtPKg80Bo/Tn4xiQ==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.62.5.tgz", + "integrity": "sha512-e7hD+sl3s+mcLQDZ8pbudBVsdG6r5yN4w3LqG2TJ8sQHDpblWj5lrJs/3m01Cvlxbt4x13zu5thLjgypgtkYzw==", "cpu": [ "x64" ], @@ -1821,9 +2034,9 @@ ] }, "node_modules/@rollup/rollup-openharmony-arm64": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.62.4.tgz", - "integrity": "sha512-s62SQ/vgsRSvMwDkOEfTqfgASF0f26ZNaQuTA6Aok5lrikf89yI2W0gFHvZb2Jpgc6N8JnOKZgCK2iciO3CsxQ==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.62.5.tgz", + "integrity": "sha512-GiyJaCf+WpMub/17aPcKk27QMl5W6f+KhdPTjlFOn5akH5Wa/DCM9Stdx5cDfmasyKB08MqpVQ1uJE2RkkpbXg==", "cpu": [ "arm64" ], @@ -1835,9 +2048,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.62.4.tgz", - "integrity": "sha512-J6wGf8TVGbXJq+HH+ttTvrcfNKPbuZecV6KT1B8I18BC5IURUh5kl4Yl5OEP5eFIUoI5BWxCsyYMhFsDx8kekw==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.62.5.tgz", + "integrity": "sha512-+OQ8U2DdoEfXl8T4Fb18AjmEwbXMerKDKCL8yCPAYhKCEEKoul7rkbeGCBFCbAlaGaa7pmtRTpkAJM2LE/i5FA==", "cpu": [ "arm64" ], @@ -1849,9 +2062,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.62.4.tgz", - "integrity": "sha512-zmfrQd/0wu6oJs8Vq8KwY/YtsKSsLtKe/HwAP4Wqy8LhWjeT55fHRAkOhYQ12wI3ayS4Tt12d5CDRD7N96SAYQ==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.62.5.tgz", + "integrity": "sha512-KanvAZrPKbDBFwrgiU9yEVpQoox9QPV1WZOXX7HudJQY+eSlu82CtWxDU8WtuRRvtN5EGkLczkd6Y6DTcvm9wA==", "cpu": [ "ia32" ], @@ -1863,9 +2076,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-gnu": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.62.4.tgz", - "integrity": "sha512-qPzHqdj9rfUD+w79dtE07zi/kFwKyCJqplp5K5ygeLTp7jLpAoc16OAH39HSmRC9UpozaecsleI8uAdEj6v2yw==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.62.5.tgz", + "integrity": "sha512-1aC3UEWTtRl3RK3VpDJ/Tqk1XI4SLTmXIthAq6wRWo8XiSXJNd+VprJM4/1P4+i6HIaFEFlVi9sTTziniD2tOQ==", "cpu": [ "x64" ], @@ -1877,9 +2090,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.62.4.tgz", - "integrity": "sha512-zD6NdeWEByGE9QF9vCrlJ5YQB4oq9q91kPZS37Jwj5hOkvR1lTBSpsKhKDw4IJtbQ35LsTS1HD9DZYGKIshU1Q==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.62.5.tgz", + "integrity": "sha512-/gDJaRs4gl0NPIwqCz+6PkpmhhjRAD2j6P4rSNHBzUkO3naEx2mIU0pRle1vUNRQ7mE/+8OOeXLTv/J56FKiQg==", "cpu": [ "x64" ], @@ -1973,6 +2186,13 @@ "@babel/types": "^7.28.2" } }, + "node_modules/@types/esrecurse": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@types/esrecurse/-/esrecurse-4.3.1.tgz", + "integrity": "sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/estree": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", @@ -2014,6 +2234,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/node": { "version": "26.2.0", "resolved": "https://registry.npmjs.org/@types/node/-/node-26.2.0.tgz", @@ -2048,6 +2275,249 @@ "dev": true, "license": "MIT" }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.67.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.67.0.tgz", + "integrity": "sha512-Un7Heoyj65NREbKAyIrFxeM143NZpExWmy1Nep4DLeQOeLlTeumPjoNKnBrU5D5moWXbPJgRa5Uwcdu0faVNGQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.12.2", + "@typescript-eslint/scope-manager": "8.67.0", + "@typescript-eslint/type-utils": "8.67.0", + "@typescript-eslint/utils": "8.67.0", + "@typescript-eslint/visitor-keys": "8.67.0", + "ignore": "^7.0.5", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.67.0", + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.6.tgz", + "integrity": "sha512-BAg6QkE8W+TuQLrrw0Ugr7HegXduRuuj8/ti2kSOc+jz1dmx8/WNcjr6XGnq5YpDWxFwwaavqD0+jIUOKelTsw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.67.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.67.0.tgz", + "integrity": "sha512-fUBfTuuEulWqX6V8+O3PtScV01tzYYRUDTAirHFKoRAt7nOzoGiPt0M/bB47wWNy0coOOcgEwAMUtBpykMxl6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/scope-manager": "8.67.0", + "@typescript-eslint/types": "8.67.0", + "@typescript-eslint/typescript-estree": "8.67.0", + "@typescript-eslint/visitor-keys": "8.67.0", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/project-service": { + "version": "8.67.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.67.0.tgz", + "integrity": "sha512-cvE8c7ulYeXN9fYuszhCeCsbzyVEXuhrRCybnBre7TUmqb5nRmBfQAwCj0O3WJFDeyAZt4VYv51vMCC9LHSdYw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.67.0", + "@typescript-eslint/types": "^8.67.0", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.67.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.67.0.tgz", + "integrity": "sha512-EgvsleTwS4E+WzzSvem8fAUubLwatMNF1B5hHSLQxcvs7q2dtRhGyujHwLJSYlG41niJ7GP24Aha2+0mb1b2kg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.67.0", + "@typescript-eslint/visitor-keys": "8.67.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/tsconfig-utils": { + "version": "8.67.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.67.0.tgz", + "integrity": "sha512-vV+LUSv5njUWsknE71fqKTlXUva+R76SaeORd6Zojcunk/6DvKFXONU3BrAs2H49mbygUXt6gbYunzwqNwlhdg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.67.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.67.0.tgz", + "integrity": "sha512-aVWDXbRmdXO9siTfX4ditQI1T9+zVcNazT48EJCD0v40/9RIFoUgZ05CmGEq9H2gixRpjUn/iplwvlcvutJW/Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.67.0", + "@typescript-eslint/typescript-estree": "8.67.0", + "@typescript-eslint/utils": "8.67.0", + "debug": "^4.4.3", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.67.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.67.0.tgz", + "integrity": "sha512-sBtgslww8nsMYUjhdPBiSyUqSzT8uR6g93A2QXnQC8+cGdjz0CyaOdqHDRJb1AtORbZCNUJBBeFA/tNR2uQmww==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.67.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.67.0.tgz", + "integrity": "sha512-EKQBCE9yNlRJYm7jdTW5AhDacDUmSwQb0FAJAmK2EKYrNXIsa2vxcSZx6PvJ/dEdI6lS+Y9W+EXckLj0iPFGcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/project-service": "8.67.0", + "@typescript-eslint/tsconfig-utils": "8.67.0", + "@typescript-eslint/types": "8.67.0", + "@typescript-eslint/visitor-keys": "8.67.0", + "debug": "^4.4.3", + "minimatch": "^10.2.2", + "semver": "^7.7.3", + "tinyglobby": "^0.2.15", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.67.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.67.0.tgz", + "integrity": "sha512-U9D1FdwEWBwok3hxxSdhclMb0twvt9QnjIQ0VfQ1AiX2epnpSgv2ubVDsayOFyY8K6FX+AQ7E0FKWVG3iKsj1A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.9.1", + "@typescript-eslint/scope-manager": "8.67.0", + "@typescript-eslint/types": "8.67.0", + "@typescript-eslint/typescript-estree": "8.67.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.67.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.67.0.tgz", + "integrity": "sha512-fkv8dHRDqfGtTHuJeebdrQ7cX6Ad4WAS00rgHh9UGvMycF1mjBfsxry1XsLIFhWZ6Judlh6UdzK+TYlbpCXgnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.67.0", + "eslint-visitor-keys": "^5.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@ungap/structured-clone": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.3.tgz", @@ -2161,9 +2631,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2178,9 +2645,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2195,9 +2659,6 @@ "loong64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2212,9 +2673,6 @@ "loong64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2229,9 +2687,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2246,9 +2701,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2263,9 +2715,6 @@ "riscv64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2280,9 +2729,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2297,9 +2743,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2314,9 +2757,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2411,6 +2851,33 @@ "node": ">=0.4.0" } }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, "node_modules/ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", @@ -2428,9 +2895,9 @@ } }, "node_modules/ansi-regex": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", - "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.3.0.tgz", + "integrity": "sha512-WpDfL7NO6j7tH88IDBNVdUJxDh9nmCteAVW9dsep846XdwF4naCBK+/tGLX3KJgcpgMRXCFlTM2hKGoK9FsdrQ==", "dev": true, "license": "MIT", "engines": { @@ -2607,9 +3074,9 @@ } }, "node_modules/baseline-browser-mapping": { - "version": "2.11.13", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.13.tgz", - "integrity": "sha512-k9HNuUVMlqVjQ9UHzfPjIqiDbWw7WqT1AoT7GL8VwvF3r0ZfArtgiSPAlmupyNquNgOJHTuH4CKYf8ttMTWBTQ==", + "version": "2.11.19", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.19.tgz", + "integrity": "sha512-Grytf1xOxOEMTGRwx6rLGKkTabd4vMg3VrKdj/7joCmV0qgh4QwMMO6xh34YEXQqirAuUdgQGa5orJQQ+69RBw==", "dev": true, "license": "Apache-2.0", "bin": { @@ -2739,9 +3206,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001809", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001809.tgz", - "integrity": "sha512-xxWVywk6a6Arlk+hymeycyn/VgqEfLDxupvhH/xiY5SJ/18kmi9o6MiO320DCUzypORHLtvh0I4i04tUhCNHNQ==", + "version": "1.0.30001810", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz", + "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==", "dev": true, "funding": [ { @@ -2819,9 +3286,9 @@ } }, "node_modules/cjs-module-lexer": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-2.2.0.tgz", - "integrity": "sha512-4bHTS2YuzUvtoLjdy+98ykbNB5jS0+07EvFNXerqZQJ89F7DI6ET7OQo/HJuW6K0aVsKA9hj9/RVb2kQVOrPDQ==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-2.2.1.tgz", + "integrity": "sha512-Ca8swihM+/4yKecYHY52kgJd300hi2lADU/a1RxNTRe+RJ9jvqQlESpbz9DnG9mowez8qwXHB8qYdIUw9e+F5Q==", "dev": true, "license": "MIT" }, @@ -3023,6 +3490,13 @@ } } }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, "node_modules/deepmerge": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", @@ -3051,9 +3525,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.5.404", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.404.tgz", - "integrity": "sha512-3WJtd7/lVq2Jnuz6wed1l9+1ZD2u2Tet1/1NBc4Iedkmgbu+I7YuAqdAQ8T+VZtnwysMsAf3IqSq9D1gyZjA2g==", + "version": "1.5.413", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.413.tgz", + "integrity": "sha512-F1XPKvt7HVfly5WND90ec16nFsdr4g5x/cVUP3EqjeyXynupabGDqpMa84wwvuYGDnldXLBz6DLXyZXWO9TPvw==", "dev": true, "license": "ISC" }, @@ -3151,13 +3625,171 @@ } }, "node_modules/escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, "license": "MIT", "engines": { - "node": ">=8" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "10.9.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.9.0.tgz", + "integrity": "sha512-5KeEOJZBfEVA47boFiBsf+6MmmJpffM7qEBg4pLla2e4nlKgdKlqCW0oSLOGsT8Wl5uCGJptLV1bkaiShj90Gw==", + "dev": true, + "license": "MIT", + "workspaces": [ + "packages/*" + ], + "dependencies": { + "@eslint-community/eslint-utils": "^4.8.0", + "@eslint-community/regexpp": "^4.12.2", + "@eslint/config-array": "^0.23.5", + "@eslint/config-helpers": "^0.7.0", + "@eslint/core": "^1.2.1", + "@eslint/plugin-kit": "^0.7.2", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.2", + "@types/estree": "^1.0.6", + "ajv": "^6.14.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^9.1.2", + "eslint-visitor-keys": "^5.0.1", + "espree": "^11.2.0", + "esquery": "^1.7.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "minimatch": "^10.2.5", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-scope": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-9.1.2.tgz", + "integrity": "sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@types/esrecurse": "^4.3.1", + "@types/estree": "^1.0.8", + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", + "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-11.2.0.tgz", + "integrity": "sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.16.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^5.0.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz", + "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" } }, "node_modules/execa": { @@ -3219,6 +3851,13 @@ "node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0" } }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -3226,6 +3865,13 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, "node_modules/fb-watchman": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", @@ -3254,18 +3900,34 @@ } } }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, "node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", "dev": true, "license": "MIT", "dependencies": { - "locate-path": "^5.0.0", + "locate-path": "^6.0.0", "path-exists": "^4.0.0" }, "engines": { - "node": ">=8" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/fix-dts-default-cjs-exports": { @@ -3280,6 +3942,27 @@ "rollup": "^4.34.8" } }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.4.tgz", + "integrity": "sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==", + "dev": true, + "license": "ISC" + }, "node_modules/foreground-child": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", @@ -3384,6 +4067,48 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "9.0.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", + "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.2" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/globals": { + "version": "16.5.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-16.5.0.tgz", + "integrity": "sha512-c/c15i26VrJ4IRt5Z89DnIzCGDn9EcebibhAOjw5ibqEHsE1wLUgkPn9RDmNcUKyU87GeaL633nyJ+pplFR2ZQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", @@ -3418,6 +4143,16 @@ "node": ">=10.17.0" } }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, "node_modules/import-local": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.2.0.tgz", @@ -3474,6 +4209,16 @@ "dev": true, "license": "MIT" }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -3494,6 +4239,19 @@ "node": ">=6" } }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-stream": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", @@ -4269,6 +5027,13 @@ "bignumber.js": "^9.0.0" } }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true, + "license": "MIT" + }, "node_modules/json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", @@ -4276,6 +5041,20 @@ "dev": true, "license": "MIT" }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -4289,6 +5068,16 @@ "node": ">=6" } }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" + } + }, "node_modules/leven": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", @@ -4299,6 +5088,20 @@ "node": ">=6" } }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/lilconfig": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.3.tgz", @@ -4330,16 +5133,19 @@ } }, "node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dev": true, "license": "MIT", "dependencies": { - "p-locate": "^4.1.0" + "p-locate": "^5.0.0" }, "engines": { - "node": ">=8" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/lru-cache": { @@ -4419,16 +5225,16 @@ } }, "node_modules/minimatch": { - "version": "9.0.9", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", - "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", "dev": true, - "license": "ISC", + "license": "BlueOak-1.0.0", "dependencies": { - "brace-expansion": "^2.0.2" + "brace-expansion": "^5.0.8" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": "18 || 20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -4575,6 +5381,24 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -4592,29 +5416,16 @@ } }, "node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/p-locate/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", "dev": true, "license": "MIT", "dependencies": { - "p-try": "^2.0.0" + "p-limit": "^3.0.2" }, "engines": { - "node": ">=6" + "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -4725,9 +5536,9 @@ "license": "ISC" }, "node_modules/picomatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz", - "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", "dev": true, "license": "MIT", "engines": { @@ -4760,6 +5571,62 @@ "node": ">=8" } }, + "node_modules/pkg-dir/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pkg-dir/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/pkg-types": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.3.1.tgz", @@ -4815,6 +5682,32 @@ } } }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prettier": { + "version": "3.9.6", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.6.tgz", + "integrity": "sha512-OpN0zzVdiaiAhxpuuj5efpIS4sY9j7bY6uR5mnj5yPzGkdkjNKSJeUThPb60Jw29QuAZgA4o+/iB49kFiaBX6g==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-format": { "version": "30.4.1", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-30.4.1.tgz", @@ -4844,6 +5737,16 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/pure-rand": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-7.0.1.tgz", @@ -4925,9 +5828,9 @@ } }, "node_modules/rollup": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.4.tgz", - "integrity": "sha512-RXOqwaPsBGjMNMa4sQjDjHieHEZDFoj/Rdr46l2MU5DfEs16wHJPC2RPTPHWhNl+M3aI472LLqFkFKut4SblOg==", + "version": "4.62.5", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.5.tgz", + "integrity": "sha512-/tqMfgP7GPA3PHhCmuiS4vIjrSVhHLgY++i+dhbG462euyAj7FpM4D9uq1X3BgjlqRdpcOrYhcQtfiQLNc8tqw==", "dev": true, "license": "MIT", "dependencies": { @@ -4942,31 +5845,31 @@ }, "optionalDependencies": { "@napi-rs/lzma-linux-x64-gnu": "1.5.1", - "@rollup/rollup-android-arm-eabi": "4.62.4", - "@rollup/rollup-android-arm64": "4.62.4", - "@rollup/rollup-darwin-arm64": "4.62.4", - "@rollup/rollup-darwin-x64": "4.62.4", - "@rollup/rollup-freebsd-arm64": "4.62.4", - "@rollup/rollup-freebsd-x64": "4.62.4", - "@rollup/rollup-linux-arm-gnueabihf": "4.62.4", - "@rollup/rollup-linux-arm-musleabihf": "4.62.4", - "@rollup/rollup-linux-arm64-gnu": "4.62.4", - "@rollup/rollup-linux-arm64-musl": "4.62.4", - "@rollup/rollup-linux-loong64-gnu": "4.62.4", - "@rollup/rollup-linux-loong64-musl": "4.62.4", - "@rollup/rollup-linux-ppc64-gnu": "4.62.4", - "@rollup/rollup-linux-ppc64-musl": "4.62.4", - "@rollup/rollup-linux-riscv64-gnu": "4.62.4", - "@rollup/rollup-linux-riscv64-musl": "4.62.4", - "@rollup/rollup-linux-s390x-gnu": "4.62.4", - "@rollup/rollup-linux-x64-gnu": "4.62.4", - "@rollup/rollup-linux-x64-musl": "4.62.4", - "@rollup/rollup-openbsd-x64": "4.62.4", - "@rollup/rollup-openharmony-arm64": "4.62.4", - "@rollup/rollup-win32-arm64-msvc": "4.62.4", - "@rollup/rollup-win32-ia32-msvc": "4.62.4", - "@rollup/rollup-win32-x64-gnu": "4.62.4", - "@rollup/rollup-win32-x64-msvc": "4.62.4", + "@rollup/rollup-android-arm-eabi": "4.62.5", + "@rollup/rollup-android-arm64": "4.62.5", + "@rollup/rollup-darwin-arm64": "4.62.5", + "@rollup/rollup-darwin-x64": "4.62.5", + "@rollup/rollup-freebsd-arm64": "4.62.5", + "@rollup/rollup-freebsd-x64": "4.62.5", + "@rollup/rollup-linux-arm-gnueabihf": "4.62.5", + "@rollup/rollup-linux-arm-musleabihf": "4.62.5", + "@rollup/rollup-linux-arm64-gnu": "4.62.5", + "@rollup/rollup-linux-arm64-musl": "4.62.5", + "@rollup/rollup-linux-loong64-gnu": "4.62.5", + "@rollup/rollup-linux-loong64-musl": "4.62.5", + "@rollup/rollup-linux-ppc64-gnu": "4.62.5", + "@rollup/rollup-linux-ppc64-musl": "4.62.5", + "@rollup/rollup-linux-riscv64-gnu": "4.62.5", + "@rollup/rollup-linux-riscv64-musl": "4.62.5", + "@rollup/rollup-linux-s390x-gnu": "4.62.5", + "@rollup/rollup-linux-x64-gnu": "4.62.5", + "@rollup/rollup-linux-x64-musl": "4.62.5", + "@rollup/rollup-openbsd-x64": "4.62.5", + "@rollup/rollup-openharmony-arm64": "4.62.5", + "@rollup/rollup-win32-arm64-msvc": "4.62.5", + "@rollup/rollup-win32-ia32-msvc": "4.62.5", + "@rollup/rollup-win32-x64-gnu": "4.62.5", + "@rollup/rollup-win32-x64-msvc": "4.62.5", "fsevents": "~2.3.2" } }, @@ -5060,6 +5963,16 @@ "node": ">=10" } }, + "node_modules/stack-utils/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/string-length": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", @@ -5400,6 +6313,19 @@ "tree-kill": "cli.js" } }, + "node_modules/ts-api-utils": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz", + "integrity": "sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, "node_modules/ts-interface-checker": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", @@ -5477,6 +6403,19 @@ "node": ">= 12" } }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -5514,6 +6453,30 @@ "node": ">=14.17" } }, + "node_modules/typescript-eslint": { + "version": "8.67.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.67.0.tgz", + "integrity": "sha512-S2udFs8tCKEKffuJ4TB1idGUZiXdCPGi3IPBGWXarbLQ5UPXORV8QEVzJ4gCRduURMb5EkpNCdjbk0eDIuI8Yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.67.0", + "@typescript-eslint/parser": "8.67.0", + "@typescript-eslint/typescript-estree": "8.67.0", + "@typescript-eslint/utils": "8.67.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, "node_modules/ufo": { "version": "1.6.4", "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.6.4.tgz", @@ -5606,6 +6569,16 @@ "browserslist": ">= 4.21.0" } }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, "node_modules/v8-to-istanbul": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", @@ -5647,6 +6620,16 @@ "node": ">= 8" } }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", diff --git a/package.json b/package.json index 7187f8b4..baec7865 100644 --- a/package.json +++ b/package.json @@ -1,62 +1,72 @@ { - "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": "28.0.0", - "license": "BSD-3-Clause", - "main": "dist/index.js", - "type": "commonjs", - "scripts": { - "build": "tsup", - "test": "jest" - }, - "exports": { - ".": { - "import": { - "types": "./dist/index.d.mts", - "default": "./dist/index.mjs" - }, - "require": { - "types": "./dist/index.d.ts", - "default": "./dist/index.js" - } + "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.0.0-rc.1", + "license": "BSD-3-Clause", + "main": "dist/index.js", + "type": "commonjs", + "scripts": { + "build": "tsup", + "test": "jest", + "format": "prettier --write .", + "format:check": "prettier --check .", + "lint": "eslint .", + "lint:fix": "eslint --fix .", + "analyse": "tsc --noEmit" }, - "./file": { - "import": { - "types": "./dist/inputFile.d.mts", - "default": "./dist/inputFile.mjs" - }, - "require": { - "types": "./dist/inputFile.d.ts", - "default": "./dist/inputFile.js" - } + "exports": { + ".": { + "import": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + }, + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + } + }, + "./file": { + "import": { + "types": "./dist/inputFile.d.mts", + "default": "./dist/inputFile.mjs" + }, + "require": { + "types": "./dist/inputFile.d.ts", + "default": "./dist/inputFile.js" + } + } + }, + "files": [ + "dist" + ], + "module": "dist/index.mjs", + "types": "dist/index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/appwrite/sdk-for-node" + }, + "devDependencies": { + "@eslint/js": "10.0.1", + "eslint": "10.9.0", + "globals": "16.5.0", + "@types/json-bigint": "1.0.4", + "@types/node": "26.2.0", + "tsup": "^8.5.1", + "esbuild-plugin-file-path-extensions": "^2.0.0", + "tslib": "2.8.1", + "typescript": "5.9.3", + "typescript-eslint": "8.67.0", + "jest": "^30.4.2", + "prettier": "3.9.6" + }, + "dependencies": { + "json-bigint": "1.0.0", + "undici": "^6.27.0" + }, + "overrides": { + "esbuild": "^0.28.1", + "js-yaml": "^4.2.0", + "brace-expansion": "5.0.9" } - }, - "files": [ - "dist" - ], - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "repository": { - "type": "git", - "url": "https://github.com/appwrite/sdk-for-node" - }, - "devDependencies": { - "@types/json-bigint": "1.0.4", - "@types/node": "26.2.0", - "tsup": "^8.5.1", - "esbuild-plugin-file-path-extensions": "^2.0.0", - "tslib": "2.8.1", - "typescript": "5.9.3", - "jest": "^30.4.2" - }, - "dependencies": { - "json-bigint": "1.0.0", - "undici": "^6.27.0" - }, - "overrides": { - "esbuild": "^0.28.1", - "js-yaml": "^4.2.0", - "brace-expansion": "5.0.9" - } } diff --git a/src/client.ts b/src/client.ts index 3575fc6a..e83744d9 100644 --- a/src/client.ts +++ b/src/client.ts @@ -11,12 +11,14 @@ const MAX_INT64 = BigInt('9223372036854775807'); const MIN_INT64 = BigInt('-9223372036854775808'); function isBigNumber(value: any): boolean { - return value !== null - && typeof value === 'object' - && value._isBigNumber === true - && typeof value.isInteger === 'function' - && typeof value.toFixed === 'function' - && typeof value.toNumber === 'function'; + return ( + value !== null && + typeof value === 'object' && + value._isBigNumber === true && + typeof value.isInteger === 'function' && + typeof value.toFixed === 'function' && + typeof value.toNumber === 'function' + ); } function reviver(_key: string, value: any): any { @@ -39,12 +41,12 @@ function reviver(_key: string, value: any): any { const JSONbig = { parse: (text: string) => JSONbigParser.parse(text, reviver), - stringify: JSONbigSerializer.stringify + stringify: JSONbigSerializer.stringify, }; type Payload = { [key: string]: any; -} +}; type UploadProgress = { $id: string; @@ -52,17 +54,22 @@ type UploadProgress = { sizeUploaded: number; chunksTotal: number; chunksUploaded: number; -} +}; type Headers = { [key: string]: string; -} +}; class AppwriteException extends Error { code: number; response: string; type: string; - constructor(message: string, code: number = 0, type: string = '', response: string = '') { + constructor( + message: string, + code: number = 0, + type: string = '', + response: string = '', + ) { super(message); this.name = 'AppwriteException'; this.message = message; @@ -73,14 +80,15 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/28.0.0'; + let ua = 'AppwriteNodeJSSDK/29.0.0-rc.1'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; if (typeof process !== 'undefined') { - if (typeof process.platform === 'string') platform.push(process.platform); + if (typeof process.platform === 'string') + platform.push(process.platform); if (typeof process.arch === 'string') platform.push(process.arch); - } + } if (platform.length > 0) { ua += ` (${platform.join('; ')})`; } @@ -88,17 +96,21 @@ function getUserAgent() { // `navigator.userAgent` is available in Node.js 21 and later. // It's also part of the WinterCG spec, so many edge runtimes provide it. // https://common-min-api.proposal.wintercg.org/#requirements-for-navigatoruseragent - // @ts-ignore - if (typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string') { - // @ts-ignore + if ( + typeof navigator !== 'undefined' && + typeof navigator.userAgent === 'string' + ) { ua += ` ${navigator.userAgent}`; - // @ts-ignore + // @ts-expect-error EdgeRuntime is injected by edge runtimes only. } else if (typeof globalThis.EdgeRuntime === 'string') { ua += ` EdgeRuntime`; - // Older Node.js versions don't have `navigator.userAgent`, so we have to use `process.version`. - } else if (typeof process !== 'undefined' && typeof process.version === 'string') { + // Older Node.js versions don't have `navigator.userAgent`, so we have to use `process.version`. + } else if ( + typeof process !== 'undefined' && + typeof process.version === 'string' + ) { ua += ` Node.js/${process.version}`; } @@ -130,8 +142,8 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '28.0.0', - 'user-agent' : getUserAgent(), + 'x-sdk-version': '29.0.0-rc.1', + 'user-agent': getUserAgent(), 'X-Appwrite-Response-Format': '1.9.6', }; @@ -149,7 +161,10 @@ class Client { throw new AppwriteException('Endpoint must be a valid string'); } - if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) { + if ( + !endpoint.startsWith('http://') && + !endpoint.startsWith('https://') + ) { throw new AppwriteException('Invalid endpoint URL: ' + endpoint); } @@ -165,7 +180,7 @@ class Client { * @returns {this} */ setSelfSigned(selfSigned: boolean): this { - // @ts-ignore + // @ts-expect-error EdgeRuntime is injected by edge runtimes only. if (typeof globalThis.EdgeRuntime !== 'undefined') { console.warn('setSelfSigned is not supported in edge runtimes.'); } @@ -386,12 +401,17 @@ class Client { return this; } - prepareRequest(method: string, url: URL, headers: Headers = {}, params: Payload = {}): { uri: string, options: RequestInit } { + prepareRequest( + method: string, + url: URL, + headers: Headers = {}, + params: Payload = {}, + ): { uri: string; options: RequestInit } { method = method.toUpperCase(); headers = Object.assign({}, this.headers, headers); - let options: RequestInit = { + const options: RequestInit = { method, headers, }; @@ -417,7 +437,7 @@ class Client { options.body = JSONbig.stringify(params); break; - case 'multipart/form-data': + case 'multipart/form-data': { const formData = new FormData(); for (const [key, value] of Object.entries(params)) { @@ -435,16 +455,25 @@ class Client { options.body = formData; delete headers['content-type']; break; + } } } return { uri: url.toString(), options }; } - async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) { - const [fileParam, file] = Object.entries(originalPayload).find( - ([_, value]) => value instanceof File || value instanceof InputFile - ) ?? []; + async chunkedUpload( + method: string, + url: URL, + headers: Headers = {}, + originalPayload: Payload = {}, + onProgress: (progress: UploadProgress) => void, + ) { + const [fileParam, file] = + Object.entries(originalPayload).find( + ([_, value]) => + value instanceof File || value instanceof InputFile, + ) ?? []; if (!file || !fileParam) { throw new Error('File not found in payload'); @@ -463,12 +492,20 @@ class Client { // Upload first chunk alone to get the upload ID const firstChunkEnd = Math.min(Client.CHUNK_SIZE, size); - const firstChunkHeaders = { ...headers, 'content-range': `bytes 0-${firstChunkEnd - 1}/${size}` }; + const firstChunkHeaders = { + ...headers, + 'content-range': `bytes 0-${firstChunkEnd - 1}/${size}`, + }; const firstChunk = await file.slice(0, firstChunkEnd); const firstPayload = { ...originalPayload }; firstPayload[fileParam] = new File([firstChunk], file.filename); - let response = await this.call(method, url, firstChunkHeaders, firstPayload); + const response = await this.call( + method, + url, + firstChunkHeaders, + firstPayload, + ); const uploadId = response?.$id; if (onProgress && typeof onProgress === 'function') { @@ -477,7 +514,7 @@ class Client { progress: Math.round((firstChunkEnd / size) * 100), sizeUploaded: firstChunkEnd, chunksTotal: totalChunks, - chunksUploaded: 1 + chunksUploaded: 1, }); } @@ -504,29 +541,39 @@ class Client { const isUploadComplete = (chunkResponse: any) => { const chunksUploaded = chunkResponse?.chunksUploaded; const chunksTotal = chunkResponse?.chunksTotal ?? totalChunks; - return typeof chunksUploaded === 'number' && typeof chunksTotal === 'number' && chunksUploaded >= chunksTotal; + return ( + typeof chunksUploaded === 'number' && + typeof chunksTotal === 'number' && + chunksUploaded >= chunksTotal + ); }; - const uploadChunk = async (chunk: typeof chunks[0]) => { + const uploadChunk = async (chunk: (typeof chunks)[0]) => { const chunkHeaders = { ...headers }; if (uploadId) { chunkHeaders['x-appwrite-id'] = uploadId; } - chunkHeaders['content-range'] = `bytes ${chunk.start}-${chunk.end - 1}/${size}`; - + chunkHeaders['content-range'] = + `bytes ${chunk.start}-${chunk.end - 1}/${size}`; + const chunkBlob = await file.slice(chunk.start, chunk.end); const chunkPayload = { ...originalPayload }; chunkPayload[fileParam] = new File([chunkBlob], file.filename); - const chunkResponse = await this.call(method, url, chunkHeaders, chunkPayload); + const chunkResponse = await this.call( + method, + url, + chunkHeaders, + chunkPayload, + ); if (failed) { return chunkResponse; } - + completedCount++; - uploadedBytes += (chunk.end - chunk.start); - + uploadedBytes += chunk.end - chunk.start; + lastResponse = chunkResponse; if (isUploadComplete(chunkResponse)) { finalResponse = chunkResponse; @@ -538,7 +585,7 @@ class Client { progress: Math.round((uploadedBytes / size) * 100), sizeUploaded: uploadedBytes, chunksTotal: totalChunks, - chunksUploaded: completedCount + chunksUploaded: completedCount, }); } @@ -562,7 +609,7 @@ class Client { throw error; } } - })() + })(), ); } @@ -579,12 +626,20 @@ class Client { // Upload first chunk alone to get the upload ID const firstChunkEnd = Math.min(Client.CHUNK_SIZE, file.size); - const firstChunkHeaders = { ...headers, 'content-range': `bytes 0-${firstChunkEnd - 1}/${file.size}` }; + const firstChunkHeaders = { + ...headers, + 'content-range': `bytes 0-${firstChunkEnd - 1}/${file.size}`, + }; const firstChunk = file.slice(0, firstChunkEnd); const firstPayload = { ...originalPayload }; firstPayload[fileParam] = new File([firstChunk], file.name); - let response = await this.call(method, url, firstChunkHeaders, firstPayload); + const response = await this.call( + method, + url, + firstChunkHeaders, + firstPayload, + ); const uploadId = response?.$id; if (onProgress && typeof onProgress === 'function') { @@ -593,7 +648,7 @@ class Client { progress: Math.round((firstChunkEnd / file.size) * 100), sizeUploaded: firstChunkEnd, chunksTotal: totalChunks, - chunksUploaded: 1 + chunksUploaded: 1, }); } @@ -620,29 +675,39 @@ class Client { const isUploadComplete = (chunkResponse: any) => { const chunksUploaded = chunkResponse?.chunksUploaded; const chunksTotal = chunkResponse?.chunksTotal ?? totalChunks; - return typeof chunksUploaded === 'number' && typeof chunksTotal === 'number' && chunksUploaded >= chunksTotal; + return ( + typeof chunksUploaded === 'number' && + typeof chunksTotal === 'number' && + chunksUploaded >= chunksTotal + ); }; - const uploadChunk = async (chunk: typeof chunks[0]) => { + const uploadChunk = async (chunk: (typeof chunks)[0]) => { const chunkHeaders = { ...headers }; if (uploadId) { chunkHeaders['x-appwrite-id'] = uploadId; } - chunkHeaders['content-range'] = `bytes ${chunk.start}-${chunk.end - 1}/${file.size}`; - + chunkHeaders['content-range'] = + `bytes ${chunk.start}-${chunk.end - 1}/${file.size}`; + const chunkBlob = file.slice(chunk.start, chunk.end); const chunkPayload = { ...originalPayload }; chunkPayload[fileParam] = new File([chunkBlob], file.name); - const chunkResponse = await this.call(method, url, chunkHeaders, chunkPayload); + const chunkResponse = await this.call( + method, + url, + chunkHeaders, + chunkPayload, + ); if (failed) { return chunkResponse; } - + completedCount++; - uploadedBytes += (chunk.end - chunk.start); - + uploadedBytes += chunk.end - chunk.start; + lastResponse = chunkResponse; if (isUploadComplete(chunkResponse)) { finalResponse = chunkResponse; @@ -654,7 +719,7 @@ class Client { progress: Math.round((uploadedBytes / file.size) * 100), sizeUploaded: uploadedBytes, chunksTotal: totalChunks, - chunksUploaded: completedCount + chunksUploaded: completedCount, }); } @@ -678,7 +743,7 @@ class Client { throw error; } } - })() + })(), ); } @@ -690,16 +755,26 @@ class Client { async ping(): Promise { return this.call('GET', new URL(this.config.endpoint + '/ping'), { 'X-Appwrite-Project': this.config.project, - 'accept': 'application/json', + accept: 'application/json', }); } - async redirect(method: string, url: URL, headers: Headers = {}, params: Payload = {}): Promise { - const { uri, options } = this.prepareRequest(method, url, headers, params); - + async redirect( + method: string, + url: URL, + headers: Headers = {}, + params: Payload = {}, + ): Promise { + const { uri, options } = this.prepareRequest( + method, + url, + headers, + params, + ); + const response = await fetch(uri, { ...options, - redirect: 'manual' + redirect: 'manual', }); if (response.status !== 301 && response.status !== 302) { @@ -709,8 +784,19 @@ class Client { return response.headers.get('location') || ''; } - async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise { - const { uri, options } = this.prepareRequest(method, url, headers, params); + async call( + method: string, + url: URL, + headers: Headers = {}, + params: Payload = {}, + responseType = 'json', + ): Promise { + const { uri, options } = this.prepareRequest( + method, + url, + headers, + params, + ); let data: any = null; @@ -718,27 +804,43 @@ class Client { const warnings = response.headers.get('x-appwrite-warning'); if (warnings) { - warnings.split(';').forEach((warning: string) => console.warn('Warning: ' + warning)); + warnings + .split(';') + .forEach((warning: string) => + console.warn('Warning: ' + warning), + ); } - if (response.headers.get('content-type')?.includes('application/json')) { + if ( + response.headers.get('content-type')?.includes('application/json') + ) { data = JSONbig.parse(await response.text()); } else if (responseType === 'arrayBuffer') { data = await response.arrayBuffer(); } else { data = { - message: await response.text() + message: await response.text(), }; } if (400 <= response.status) { - let responseText = ''; - if (response.headers.get('content-type')?.includes('application/json') || responseType === 'arrayBuffer') { + let responseText: string; + if ( + response.headers + .get('content-type') + ?.includes('application/json') || + responseType === 'arrayBuffer' + ) { responseText = JSONbig.stringify(data); } else { responseText = data?.message; } - throw new AppwriteException(data?.message, response.status, data?.type, responseText); + throw new AppwriteException( + data?.message, + response.status, + data?.type, + responseText, + ); } if (data && typeof data === 'object') { @@ -757,7 +859,7 @@ class Client { let output: Payload = {}; for (const [key, value] of Object.entries(data)) { - let finalKey = prefix ? prefix + '[' + key +']' : key; + const finalKey = prefix ? prefix + '[' + key + ']' : key; if (Array.isArray(value)) { output = { ...output, ...Client.flatten(value, finalKey) }; } else { diff --git a/src/enums/adapter.ts b/src/enums/adapter.ts index a3b1ae0c..ff6b3f42 100644 --- a/src/enums/adapter.ts +++ b/src/enums/adapter.ts @@ -1,4 +1,4 @@ export enum Adapter { Static = 'static', Ssr = 'ssr', -} \ No newline at end of file +} diff --git a/src/enums/attribute-status.ts b/src/enums/attribute-status.ts index ade1d36a..43f788fa 100644 --- a/src/enums/attribute-status.ts +++ b/src/enums/attribute-status.ts @@ -4,4 +4,4 @@ export enum AttributeStatus { Deleting = 'deleting', Stuck = 'stuck', Failed = 'failed', -} \ No newline at end of file +} diff --git a/src/enums/authentication-factor.ts b/src/enums/authentication-factor.ts index e3260d71..d16c3fe5 100644 --- a/src/enums/authentication-factor.ts +++ b/src/enums/authentication-factor.ts @@ -4,4 +4,4 @@ export enum AuthenticationFactor { Totp = 'totp', Recoverycode = 'recoverycode', Custom = 'custom', -} \ No newline at end of file +} diff --git a/src/enums/authenticator-type.ts b/src/enums/authenticator-type.ts index 34db0cca..0c918278 100644 --- a/src/enums/authenticator-type.ts +++ b/src/enums/authenticator-type.ts @@ -1,3 +1,3 @@ export enum AuthenticatorType { Totp = 'totp', -} \ No newline at end of file +} diff --git a/src/enums/backup-services.ts b/src/enums/backup-services.ts index adef40d2..c95b851a 100644 --- a/src/enums/backup-services.ts +++ b/src/enums/backup-services.ts @@ -6,4 +6,4 @@ export enum BackupServices { DedicatedDatabases = 'dedicatedDatabases', Functions = 'functions', Storage = 'storage', -} \ No newline at end of file +} diff --git a/src/enums/billing-plan-group.ts b/src/enums/billing-plan-group.ts index 8aa025b3..e8cd15d8 100644 --- a/src/enums/billing-plan-group.ts +++ b/src/enums/billing-plan-group.ts @@ -2,4 +2,4 @@ export enum BillingPlanGroup { Starter = 'starter', Pro = 'pro', Scale = 'scale', -} \ No newline at end of file +} diff --git a/src/enums/browser-permission.ts b/src/enums/browser-permission.ts index 6e2c4cda..a670a6e0 100644 --- a/src/enums/browser-permission.ts +++ b/src/enums/browser-permission.ts @@ -19,4 +19,4 @@ export enum BrowserPermission { Screenwakelock = 'screen-wake-lock', Webshare = 'web-share', Xrspatialtracking = 'xr-spatial-tracking', -} \ No newline at end of file +} diff --git a/src/enums/browser-theme.ts b/src/enums/browser-theme.ts index 9f8c382a..acb8d578 100644 --- a/src/enums/browser-theme.ts +++ b/src/enums/browser-theme.ts @@ -1,4 +1,4 @@ export enum BrowserTheme { Light = 'light', Dark = 'dark', -} \ No newline at end of file +} diff --git a/src/enums/browser.ts b/src/enums/browser.ts index cec52fb6..78762163 100644 --- a/src/enums/browser.ts +++ b/src/enums/browser.ts @@ -13,4 +13,4 @@ export enum Browser { OperaMini = 'om', Opera = 'op', OperaNext = 'on', -} \ No newline at end of file +} diff --git a/src/enums/build-runtime.ts b/src/enums/build-runtime.ts index 50f152ac..cad34c11 100644 --- a/src/enums/build-runtime.ts +++ b/src/enums/build-runtime.ts @@ -77,6 +77,7 @@ export enum BuildRuntime { Bun11 = 'bun-1.1', Bun12 = 'bun-1.2', Bun13 = 'bun-1.3', + Bun14 = 'bun-1.4', Go123 = 'go-1.23', Go124 = 'go-1.24', Go125 = 'go-1.25', @@ -91,4 +92,4 @@ export enum BuildRuntime { Flutter338 = 'flutter-3.38', Flutter341 = 'flutter-3.41', Flutter344 = 'flutter-3.44', -} \ No newline at end of file +} diff --git a/src/enums/column-status.ts b/src/enums/column-status.ts index f53e8a66..934872ec 100644 --- a/src/enums/column-status.ts +++ b/src/enums/column-status.ts @@ -4,4 +4,4 @@ export enum ColumnStatus { Deleting = 'deleting', Stuck = 'stuck', Failed = 'failed', -} \ No newline at end of file +} diff --git a/src/enums/compression.ts b/src/enums/compression.ts index 1bec0e78..79d297c3 100644 --- a/src/enums/compression.ts +++ b/src/enums/compression.ts @@ -2,4 +2,4 @@ export enum Compression { None = 'none', Gzip = 'gzip', Zstd = 'zstd', -} \ No newline at end of file +} diff --git a/src/enums/credit-card.ts b/src/enums/credit-card.ts index e6ce2429..946e4931 100644 --- a/src/enums/credit-card.ts +++ b/src/enums/credit-card.ts @@ -16,4 +16,4 @@ export enum CreditCard { MIR = 'mir', Maestro = 'maestro', Rupay = 'rupay', -} \ No newline at end of file +} diff --git a/src/enums/database-status.ts b/src/enums/database-status.ts index 8a01e3b7..54e1ada0 100644 --- a/src/enums/database-status.ts +++ b/src/enums/database-status.ts @@ -13,4 +13,4 @@ export enum DatabaseStatus { Pausing = 'pausing', Resuming = 'resuming', Failingover = 'failing-over', -} \ No newline at end of file +} diff --git a/src/enums/database-type.ts b/src/enums/database-type.ts index b39f921e..725f3641 100644 --- a/src/enums/database-type.ts +++ b/src/enums/database-type.ts @@ -6,4 +6,4 @@ export enum DatabaseType { Mysql = 'mysql', Postgresql = 'postgresql', Mongodb = 'mongodb', -} \ No newline at end of file +} diff --git a/src/enums/databases-index-type.ts b/src/enums/databases-index-type.ts index 85ccf867..e849833d 100644 --- a/src/enums/databases-index-type.ts +++ b/src/enums/databases-index-type.ts @@ -3,4 +3,4 @@ export enum DatabasesIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', -} \ No newline at end of file +} diff --git a/src/enums/deployment-download-type.ts b/src/enums/deployment-download-type.ts index 538709bc..80cdec29 100644 --- a/src/enums/deployment-download-type.ts +++ b/src/enums/deployment-download-type.ts @@ -1,4 +1,4 @@ export enum DeploymentDownloadType { Source = 'source', Output = 'output', -} \ No newline at end of file +} diff --git a/src/enums/deployment-status.ts b/src/enums/deployment-status.ts index 7e8f4a1b..f89b3903 100644 --- a/src/enums/deployment-status.ts +++ b/src/enums/deployment-status.ts @@ -5,4 +5,4 @@ export enum DeploymentStatus { Ready = 'ready', Canceled = 'canceled', Failed = 'failed', -} \ No newline at end of file +} diff --git a/src/enums/documents-db-index-type.ts b/src/enums/documents-db-index-type.ts new file mode 100644 index 00000000..6c04a5f7 --- /dev/null +++ b/src/enums/documents-db-index-type.ts @@ -0,0 +1,5 @@ +export enum DocumentsDBIndexType { + Key = 'key', + Fulltext = 'fulltext', + Unique = 'unique', +} diff --git a/src/enums/embedding-model.ts b/src/enums/embedding-model.ts index d06bb77b..29bf262f 100644 --- a/src/enums/embedding-model.ts +++ b/src/enums/embedding-model.ts @@ -1,6 +1,4 @@ export enum EmbeddingModel { Nomicembedtext = 'nomic-embed-text', - Embeddinggemma = 'embedding-gemma', Allminilm = 'all-minilm', - Bgesmall = 'bge-small', -} \ No newline at end of file +} diff --git a/src/enums/execution-method.ts b/src/enums/execution-method.ts index 39d4c1e8..a01b6b1a 100644 --- a/src/enums/execution-method.ts +++ b/src/enums/execution-method.ts @@ -6,4 +6,4 @@ export enum ExecutionMethod { DELETE = 'DELETE', OPTIONS = 'OPTIONS', HEAD = 'HEAD', -} \ No newline at end of file +} diff --git a/src/enums/execution-resource-type.ts b/src/enums/execution-resource-type.ts new file mode 100644 index 00000000..f2773e86 --- /dev/null +++ b/src/enums/execution-resource-type.ts @@ -0,0 +1,4 @@ +export enum ExecutionResourceType { + Functions = 'functions', + Sites = 'sites', +} diff --git a/src/enums/execution-status.ts b/src/enums/execution-status.ts index 992d987d..81bd3955 100644 --- a/src/enums/execution-status.ts +++ b/src/enums/execution-status.ts @@ -4,4 +4,4 @@ export enum ExecutionStatus { Completed = 'completed', Failed = 'failed', Scheduled = 'scheduled', -} \ No newline at end of file +} diff --git a/src/enums/execution-trigger.ts b/src/enums/execution-trigger.ts index 1829d514..84fa8f60 100644 --- a/src/enums/execution-trigger.ts +++ b/src/enums/execution-trigger.ts @@ -2,4 +2,4 @@ export enum ExecutionTrigger { Http = 'http', Schedule = 'schedule', Event = 'event', -} \ No newline at end of file +} diff --git a/src/enums/flag.ts b/src/enums/flag.ts index 7e1d8781..ab49b648 100644 --- a/src/enums/flag.ts +++ b/src/enums/flag.ts @@ -194,4 +194,4 @@ export enum Flag { SouthAfrica = 'za', Zambia = 'zm', Zimbabwe = 'zw', -} \ No newline at end of file +} diff --git a/src/enums/framework.ts b/src/enums/framework.ts index 7093da33..6173a0ef 100644 --- a/src/enums/framework.ts +++ b/src/enums/framework.ts @@ -14,4 +14,4 @@ export enum Framework { Reactnative = 'react-native', Vite = 'vite', Other = 'other', -} \ No newline at end of file +} diff --git a/src/enums/image-format.ts b/src/enums/image-format.ts index 758fad74..4c210ffd 100644 --- a/src/enums/image-format.ts +++ b/src/enums/image-format.ts @@ -6,4 +6,4 @@ export enum ImageFormat { Heic = 'heic', Avif = 'avif', Gif = 'gif', -} \ No newline at end of file +} diff --git a/src/enums/image-gravity.ts b/src/enums/image-gravity.ts index 815095dd..a115f3a2 100644 --- a/src/enums/image-gravity.ts +++ b/src/enums/image-gravity.ts @@ -8,4 +8,4 @@ export enum ImageGravity { Bottomleft = 'bottom-left', Bottom = 'bottom', Bottomright = 'bottom-right', -} \ No newline at end of file +} diff --git a/src/enums/index-status.ts b/src/enums/index-status.ts index 6ce90ac8..241a017d 100644 --- a/src/enums/index-status.ts +++ b/src/enums/index-status.ts @@ -4,4 +4,4 @@ export enum IndexStatus { Deleting = 'deleting', Stuck = 'stuck', Failed = 'failed', -} \ No newline at end of file +} diff --git a/src/enums/invalidation-type.ts b/src/enums/invalidation-type.ts index 828f5402..e2b0443e 100644 --- a/src/enums/invalidation-type.ts +++ b/src/enums/invalidation-type.ts @@ -2,4 +2,4 @@ export enum InvalidationType { Tag = 'tag', Path = 'path', All = 'all', -} \ No newline at end of file +} diff --git a/src/enums/message-priority.ts b/src/enums/message-priority.ts index f3113a85..c4f491ef 100644 --- a/src/enums/message-priority.ts +++ b/src/enums/message-priority.ts @@ -1,4 +1,4 @@ export enum MessagePriority { Normal = 'normal', High = 'high', -} \ No newline at end of file +} diff --git a/src/enums/message-status.ts b/src/enums/message-status.ts index 08bd483b..05be0e81 100644 --- a/src/enums/message-status.ts +++ b/src/enums/message-status.ts @@ -4,4 +4,4 @@ export enum MessageStatus { Scheduled = 'scheduled', Sent = 'sent', Failed = 'failed', -} \ No newline at end of file +} diff --git a/src/enums/messaging-provider-type.ts b/src/enums/messaging-provider-type.ts index 18c9929b..f10f6309 100644 --- a/src/enums/messaging-provider-type.ts +++ b/src/enums/messaging-provider-type.ts @@ -2,4 +2,4 @@ export enum MessagingProviderType { Email = 'email', Sms = 'sms', Push = 'push', -} \ No newline at end of file +} diff --git a/src/enums/o-auth-2-google-prompt.ts b/src/enums/o-auth-2-google-prompt.ts index f8e98e12..23c5e9fc 100644 --- a/src/enums/o-auth-2-google-prompt.ts +++ b/src/enums/o-auth-2-google-prompt.ts @@ -2,4 +2,4 @@ export enum OAuth2GooglePrompt { None = 'none', Consent = 'consent', SelectAccount = 'select_account', -} \ No newline at end of file +} diff --git a/src/enums/o-auth-2-oidc-prompt.ts b/src/enums/o-auth-2-oidc-prompt.ts index daa1ef0e..1836202f 100644 --- a/src/enums/o-auth-2-oidc-prompt.ts +++ b/src/enums/o-auth-2-oidc-prompt.ts @@ -3,4 +3,4 @@ export enum OAuth2OidcPrompt { Login = 'login', Consent = 'consent', SelectAccount = 'select_account', -} \ No newline at end of file +} diff --git a/src/enums/o-auth-provider.ts b/src/enums/o-auth-provider.ts index e7136d69..6f0a4618 100644 --- a/src/enums/o-auth-provider.ts +++ b/src/enums/o-auth-provider.ts @@ -19,6 +19,7 @@ export enum OAuthProvider { Github = 'github', Gitlab = 'gitlab', Google = 'google', + Huggingface = 'huggingface', Keycloak = 'keycloak', Kick = 'kick', Linkedin = 'linkedin', @@ -43,4 +44,4 @@ export enum OAuthProvider { Yandex = 'yandex', Zoho = 'zoho', Zoom = 'zoom', -} \ No newline at end of file +} diff --git a/src/enums/order-by.ts b/src/enums/order-by.ts index 62dffb98..f954f10a 100644 --- a/src/enums/order-by.ts +++ b/src/enums/order-by.ts @@ -1,4 +1,4 @@ export enum OrderBy { Asc = 'asc', Desc = 'desc', -} \ No newline at end of file +} diff --git a/src/enums/organization-key-scopes.ts b/src/enums/organization-key-scopes.ts index eb18181d..2e878b48 100644 --- a/src/enums/organization-key-scopes.ts +++ b/src/enums/organization-key-scopes.ts @@ -15,4 +15,4 @@ export enum OrganizationKeyScopes { DomainsWrite = 'domains.write', KeysRead = 'keys.read', KeysWrite = 'keys.write', -} \ No newline at end of file +} diff --git a/src/enums/password-hash.ts b/src/enums/password-hash.ts index 76834af4..d615ce6f 100644 --- a/src/enums/password-hash.ts +++ b/src/enums/password-hash.ts @@ -10,4 +10,4 @@ export enum PasswordHash { Sha3256 = 'sha3-256', Sha3384 = 'sha3-384', Sha3512 = 'sha3-512', -} \ No newline at end of file +} diff --git a/src/enums/platform-type.ts b/src/enums/platform-type.ts index bde1d30f..5585e88c 100644 --- a/src/enums/platform-type.ts +++ b/src/enums/platform-type.ts @@ -4,4 +4,4 @@ export enum PlatformType { Android = 'android', Linux = 'linux', Web = 'web', -} \ No newline at end of file +} diff --git a/src/enums/project-auth-method-id.ts b/src/enums/project-auth-method-id.ts index a05c217e..367ed141 100644 --- a/src/enums/project-auth-method-id.ts +++ b/src/enums/project-auth-method-id.ts @@ -6,4 +6,4 @@ export enum ProjectAuthMethodId { Invites = 'invites', Jwt = 'jwt', Phone = 'phone', -} \ No newline at end of file +} diff --git a/src/enums/project-email-template-id.ts b/src/enums/project-email-template-id.ts index b5aba1a6..c8ecbec4 100644 --- a/src/enums/project-email-template-id.ts +++ b/src/enums/project-email-template-id.ts @@ -6,4 +6,4 @@ export enum ProjectEmailTemplateId { MfaChallenge = 'mfaChallenge', SessionAlert = 'sessionAlert', OtpSession = 'otpSession', -} \ No newline at end of file +} diff --git a/src/enums/project-email-template-locale.ts b/src/enums/project-email-template-locale.ts index b5bb7cf8..c9e85ac2 100644 --- a/src/enums/project-email-template-locale.ts +++ b/src/enums/project-email-template-locale.ts @@ -130,4 +130,4 @@ export enum ProjectEmailTemplateLocale { Zhsg = 'zh-sg', Zhtw = 'zh-tw', Zu = 'zu', -} \ No newline at end of file +} diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts index d4b5c7c9..e9606007 100644 --- a/src/enums/project-key-scopes.ts +++ b/src/enums/project-key-scopes.ts @@ -1,6 +1,7 @@ export enum ProjectKeyScopes { ProjectRead = 'project.read', ProjectWrite = 'project.write', + UsageRead = 'usage.read', KeysRead = 'keys.read', KeysWrite = 'keys.write', PlatformsRead = 'platforms.read', @@ -40,6 +41,18 @@ export enum ProjectKeyScopes { AttributesWrite = 'attributes.write', DocumentsRead = 'documents.read', DocumentsWrite = 'documents.write', + DocumentsdbRead = 'documentsdb.read', + DocumentsdbWrite = 'documentsdb.write', + DocumentsdbCollectionsRead = 'documentsdb.collections.read', + DocumentsdbCollectionsWrite = 'documentsdb.collections.write', + DocumentsdbDocumentsRead = 'documentsdb.documents.read', + DocumentsdbDocumentsWrite = 'documentsdb.documents.write', + VectorsdbRead = 'vectorsdb.read', + VectorsdbWrite = 'vectorsdb.write', + VectorsdbCollectionsRead = 'vectorsdb.collections.read', + VectorsdbCollectionsWrite = 'vectorsdb.collections.write', + VectorsdbDocumentsRead = 'vectorsdb.documents.read', + VectorsdbDocumentsWrite = 'vectorsdb.documents.write', BucketsRead = 'buckets.read', BucketsWrite = 'buckets.write', FilesRead = 'files.read', @@ -92,7 +105,6 @@ export enum ProjectKeyScopes { ArchivesWrite = 'archives.write', RestorationsRead = 'restorations.read', RestorationsWrite = 'restorations.write', - DedicatedDatabasesExecute = 'dedicatedDatabases.execute', DomainsRead = 'domains.read', DomainsWrite = 'domains.write', WafRulesRead = 'wafRules.read', @@ -104,5 +116,4 @@ export enum ProjectKeyScopes { Oauth2Read = 'oauth2.read', Oauth2Write = 'oauth2.write', Oauth2Introspect = 'oauth2.introspect', - UsageRead = 'usage.read', -} \ No newline at end of file +} diff --git a/src/enums/project-o-auth-2-google-prompt.ts b/src/enums/project-o-auth-2-google-prompt.ts index 75db98ec..43b77ed4 100644 --- a/src/enums/project-o-auth-2-google-prompt.ts +++ b/src/enums/project-o-auth-2-google-prompt.ts @@ -2,4 +2,4 @@ export enum ProjectOAuth2GooglePrompt { None = 'none', Consent = 'consent', SelectAccount = 'select_account', -} \ No newline at end of file +} diff --git a/src/enums/project-o-auth-2-oidc-prompt.ts b/src/enums/project-o-auth-2-oidc-prompt.ts index 6d346b16..12344220 100644 --- a/src/enums/project-o-auth-2-oidc-prompt.ts +++ b/src/enums/project-o-auth-2-oidc-prompt.ts @@ -3,4 +3,4 @@ export enum ProjectOAuth2OidcPrompt { Login = 'login', Consent = 'consent', SelectAccount = 'select_account', -} \ No newline at end of file +} diff --git a/src/enums/project-o-auth-provider-id.ts b/src/enums/project-o-auth-provider-id.ts index 125ee887..401f3d1e 100644 --- a/src/enums/project-o-auth-provider-id.ts +++ b/src/enums/project-o-auth-provider-id.ts @@ -19,6 +19,7 @@ export enum ProjectOAuthProviderId { Github = 'github', Gitlab = 'gitlab', Google = 'google', + Huggingface = 'huggingface', Keycloak = 'keycloak', Kick = 'kick', Linkedin = 'linkedin', @@ -43,4 +44,4 @@ export enum ProjectOAuthProviderId { Yandex = 'yandex', Zoho = 'zoho', Zoom = 'zoom', -} \ No newline at end of file +} diff --git a/src/enums/project-policy-id.ts b/src/enums/project-policy-id.ts index 4e287f49..c05f7f60 100644 --- a/src/enums/project-policy-id.ts +++ b/src/enums/project-policy-id.ts @@ -14,4 +14,4 @@ export enum ProjectPolicyId { Denydisposableemail = 'deny-disposable-email', Denyfreeemail = 'deny-free-email', Denycorporateemail = 'deny-corporate-email', -} \ No newline at end of file +} diff --git a/src/enums/project-protocol-id.ts b/src/enums/project-protocol-id.ts index 10a89c21..81546e67 100644 --- a/src/enums/project-protocol-id.ts +++ b/src/enums/project-protocol-id.ts @@ -2,4 +2,4 @@ export enum ProjectProtocolId { Rest = 'rest', Graphql = 'graphql', Websocket = 'websocket', -} \ No newline at end of file +} diff --git a/src/enums/project-service-id.ts b/src/enums/project-service-id.ts index 0da78c59..843da957 100644 --- a/src/enums/project-service-id.ts +++ b/src/enums/project-service-id.ts @@ -18,4 +18,4 @@ export enum ProjectServiceId { Messaging = 'messaging', Advisor = 'advisor', Oauth2 = 'oauth2', -} \ No newline at end of file +} diff --git a/src/enums/project-smtp-secure.ts b/src/enums/project-smtp-secure.ts index d3d37687..03d38af2 100644 --- a/src/enums/project-smtp-secure.ts +++ b/src/enums/project-smtp-secure.ts @@ -1,4 +1,4 @@ export enum ProjectSMTPSecure { Tls = 'tls', Ssl = 'ssl', -} \ No newline at end of file +} diff --git a/src/enums/proxy-resource-type.ts b/src/enums/proxy-resource-type.ts index e04c8046..0bb3f1eb 100644 --- a/src/enums/proxy-resource-type.ts +++ b/src/enums/proxy-resource-type.ts @@ -1,4 +1,4 @@ export enum ProxyResourceType { Site = 'site', Function = 'function', -} \ No newline at end of file +} diff --git a/src/enums/proxy-rule-deployment-resource-type.ts b/src/enums/proxy-rule-deployment-resource-type.ts index 89236c74..ef695072 100644 --- a/src/enums/proxy-rule-deployment-resource-type.ts +++ b/src/enums/proxy-rule-deployment-resource-type.ts @@ -1,4 +1,4 @@ export enum ProxyRuleDeploymentResourceType { Function = 'function', Site = 'site', -} \ No newline at end of file +} diff --git a/src/enums/proxy-rule-status.ts b/src/enums/proxy-rule-status.ts index 67b8e4cb..f717f93f 100644 --- a/src/enums/proxy-rule-status.ts +++ b/src/enums/proxy-rule-status.ts @@ -2,4 +2,4 @@ export enum ProxyRuleStatus { Unverified = 'unverified', Verifying = 'verifying', Verified = 'verified', -} \ No newline at end of file +} diff --git a/src/enums/region.ts b/src/enums/region.ts index 948dd0b8..30fc88c2 100644 --- a/src/enums/region.ts +++ b/src/enums/region.ts @@ -5,4 +5,4 @@ export enum Region { Sfo = 'sfo', Sgp = 'sgp', Tor = 'tor', -} \ No newline at end of file +} diff --git a/src/enums/relation-mutate.ts b/src/enums/relation-mutate.ts index 722a7572..87a43132 100644 --- a/src/enums/relation-mutate.ts +++ b/src/enums/relation-mutate.ts @@ -2,4 +2,4 @@ export enum RelationMutate { Cascade = 'cascade', Restrict = 'restrict', SetNull = 'setNull', -} \ No newline at end of file +} diff --git a/src/enums/relationship-type.ts b/src/enums/relationship-type.ts index 532015af..da136011 100644 --- a/src/enums/relationship-type.ts +++ b/src/enums/relationship-type.ts @@ -3,4 +3,4 @@ export enum RelationshipType { ManyToOne = 'manyToOne', ManyToMany = 'manyToMany', OneToMany = 'oneToMany', -} \ No newline at end of file +} diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts index 63e04b2a..ecc4e827 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -77,6 +77,7 @@ export enum Runtime { Bun11 = 'bun-1.1', Bun12 = 'bun-1.2', Bun13 = 'bun-1.3', + Bun14 = 'bun-1.4', Go123 = 'go-1.23', Go124 = 'go-1.24', Go125 = 'go-1.25', @@ -91,4 +92,4 @@ export enum Runtime { Flutter338 = 'flutter-3.38', Flutter341 = 'flutter-3.41', Flutter344 = 'flutter-3.44', -} \ No newline at end of file +} diff --git a/src/enums/smtp-encryption.ts b/src/enums/smtp-encryption.ts index 876177b6..5fe9c93a 100644 --- a/src/enums/smtp-encryption.ts +++ b/src/enums/smtp-encryption.ts @@ -2,4 +2,4 @@ export enum SmtpEncryption { None = 'none', Ssl = 'ssl', Tls = 'tls', -} \ No newline at end of file +} diff --git a/src/enums/status-code.ts b/src/enums/status-code.ts index 425d65c3..f5bfac49 100644 --- a/src/enums/status-code.ts +++ b/src/enums/status-code.ts @@ -3,4 +3,4 @@ export enum StatusCode { Found = '302', TemporaryRedirect = '307', PermanentRedirect = '308', -} \ No newline at end of file +} diff --git a/src/enums/tables-db-index-type.ts b/src/enums/tables-db-index-type.ts index a199cd9c..246bfc4a 100644 --- a/src/enums/tables-db-index-type.ts +++ b/src/enums/tables-db-index-type.ts @@ -3,4 +3,4 @@ export enum TablesDBIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', -} \ No newline at end of file +} diff --git a/src/enums/template-reference-type.ts b/src/enums/template-reference-type.ts index bd72cfb5..afcaea00 100644 --- a/src/enums/template-reference-type.ts +++ b/src/enums/template-reference-type.ts @@ -2,4 +2,4 @@ export enum TemplateReferenceType { Commit = 'commit', Branch = 'branch', Tag = 'tag', -} \ No newline at end of file +} diff --git a/src/enums/timezone.ts b/src/enums/timezone.ts index 207298a8..24c08db9 100644 --- a/src/enums/timezone.ts +++ b/src/enums/timezone.ts @@ -418,4 +418,4 @@ export enum Timezone { PacificWake = 'pacific/wake', PacificWallis = 'pacific/wallis', Utc = 'utc', -} \ No newline at end of file +} diff --git a/src/enums/vcs-reference-type.ts b/src/enums/vcs-reference-type.ts index cb5270f5..55f1d89d 100644 --- a/src/enums/vcs-reference-type.ts +++ b/src/enums/vcs-reference-type.ts @@ -2,4 +2,4 @@ export enum VCSReferenceType { Branch = 'branch', Commit = 'commit', Tag = 'tag', -} \ No newline at end of file +} diff --git a/src/enums/vectors-db-index-type.ts b/src/enums/vectors-db-index-type.ts new file mode 100644 index 00000000..d497359c --- /dev/null +++ b/src/enums/vectors-db-index-type.ts @@ -0,0 +1,8 @@ +export enum VectorsDBIndexType { + HnswEuclidean = 'hnsw_euclidean', + HnswDot = 'hnsw_dot', + HnswCosine = 'hnsw_cosine', + Object = 'object', + Key = 'key', + Unique = 'unique', +} diff --git a/src/id.ts b/src/id.ts index 33495cc8..d9ebe835 100644 --- a/src/id.ts +++ b/src/id.ts @@ -14,7 +14,8 @@ export class ID { const msec = now.getMilliseconds(); // Convert to hexadecimal - const hexTimestamp = sec.toString(16) + msec.toString(16).padStart(5, '0'); + const hexTimestamp = + sec.toString(16) + msec.toString(16).padStart(5, '0'); return hexTimestamp; } @@ -25,12 +26,12 @@ export class ID { * @returns {string} */ public static custom(id: string): string { - return id + return id; } /** * Have Appwrite generate a unique ID for you. - * + * * @param {number} padding. Default is 7. * @returns {string} */ diff --git a/src/index.ts b/src/index.ts index 58388a19..d63a2efc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,13 +5,17 @@ export { Apps } from './services/apps'; export { Avatars } from './services/avatars'; export { Backups } from './services/backups'; export { Databases } from './services/databases'; +export { DocumentsDB } from './services/documents-db'; export { Embeddings } from './services/embeddings'; export { Functions } from './services/functions'; export { Graphql } from './services/graphql'; export { Locale } from './services/locale'; export { Messaging } from './services/messaging'; +export { Mongo } from './services/mongo'; +export { Mysql } from './services/mysql'; export { Oauth2 } from './services/oauth-2'; export { Organization } from './services/organization'; +export { Postgresql } from './services/postgresql'; export { Presences } from './services/presences'; export { Project } from './services/project'; export { Proxy } from './services/proxy'; @@ -22,6 +26,7 @@ export { TablesDB } from './services/tables-db'; export { Teams } from './services/teams'; export { Tokens } from './services/tokens'; export { Users } from './services/users'; +export { VectorsDB } from './services/vectors-db'; export { Webhooks } from './services/webhooks'; export type { Models, Payload, UploadProgress } from './client'; export type { QueryTypes, QueryTypesList } from './query'; @@ -44,6 +49,7 @@ export { RelationshipType } from './enums/relationship-type'; 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 { EmbeddingModel } from './enums/embedding-model'; export { Runtime } from './enums/runtime'; export { ProjectKeyScopes } from './enums/project-key-scopes'; @@ -76,12 +82,14 @@ export { ImageGravity } from './enums/image-gravity'; export { TablesDBIndexType } from './enums/tables-db-index-type'; export { PasswordHash } from './enums/password-hash'; export { MessagingProviderType } from './enums/messaging-provider-type'; +export { VectorsDBIndexType } from './enums/vectors-db-index-type'; export { DatabaseType } from './enums/database-type'; export { DatabaseStatus } from './enums/database-status'; export { AttributeStatus } from './enums/attribute-status'; export { ColumnStatus } from './enums/column-status'; export { IndexStatus } from './enums/index-status'; 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 { OAuth2GooglePrompt } from './enums/o-auth-2-google-prompt'; diff --git a/src/inputFile.ts b/src/inputFile.ts index 05459284..f1648b8b 100644 --- a/src/inputFile.ts +++ b/src/inputFile.ts @@ -1,144 +1,190 @@ -import { File } from "undici"; +import { File } from 'undici'; type FsPromises = { - stat: (path: string) => Promise<{ size: number }>; - open: (path: string, flags: string) => Promise<{ - read: (buffer: Uint8Array, offset: number, length: number, position: number) => Promise<{ bytesRead: number }>; - close: () => Promise; - }>; - readFile: (path: string) => Promise; + stat: (path: string) => Promise<{ size: number }>; + open: ( + path: string, + flags: string, + ) => Promise<{ + read: ( + buffer: Uint8Array, + offset: number, + length: number, + position: number, + ) => Promise<{ bytesRead: number }>; + close: () => Promise; + }>; + readFile: (path: string) => Promise; }; function isEdgeRuntime(): boolean { - return typeof globalThis !== 'undefined' && typeof (globalThis as { EdgeRuntime?: unknown }).EdgeRuntime !== 'undefined'; + return ( + typeof globalThis !== 'undefined' && + typeof (globalThis as { EdgeRuntime?: unknown }).EdgeRuntime !== + 'undefined' + ); } function assertFileSystemAvailable(): void { - if (isEdgeRuntime()) { - throw new Error('File system operations are not supported in edge runtimes. Please use InputFile.fromBuffer instead.'); - } + if (isEdgeRuntime()) { + throw new Error( + 'File system operations are not supported in edge runtimes. Please use InputFile.fromBuffer instead.', + ); + } } async function getFs(): Promise { - assertFileSystemAvailable(); - - try { - const fs = await import('fs'); - return fs.promises; - } catch { - throw new Error('File system operations are not available in this runtime. Please use InputFile.fromBuffer instead.'); - } + assertFileSystemAvailable(); + + try { + const fs = await import('fs'); + return fs.promises; + } catch { + throw new Error( + 'File system operations are not available in this runtime. Please use InputFile.fromBuffer instead.', + ); + } } function getFilename(path: string): string { - const segments = path.replace(/\\/g, '/').split('/').filter(Boolean); - return segments.pop() ?? 'file'; + const segments = path.replace(/\\/g, '/').split('/').filter(Boolean); + return segments.pop() ?? 'file'; } type BlobLike = { - size: number; - slice: (start: number, end: number) => BlobLike; - arrayBuffer: () => Promise; + size: number; + slice: (start: number, end: number) => BlobLike; + arrayBuffer: () => Promise; }; type InputFileSource = - | { type: 'path'; path: string } - | { type: 'buffer'; data: Uint8Array } - | { type: 'blob'; data: BlobLike }; + | { type: 'path'; path: string } + | { type: 'buffer'; data: Uint8Array } + | { type: 'blob'; data: BlobLike }; export class InputFile { - private source: InputFileSource; - filename: string; + private source: InputFileSource; + filename: string; + + private constructor(source: InputFileSource, filename: string) { + this.source = source; + this.filename = filename; + } - private constructor(source: InputFileSource, filename: string) { - this.source = source; - this.filename = filename; - } + static fromBuffer( + parts: BlobLike | Uint8Array | ArrayBuffer | string, + name: string, + ): InputFile { + if ( + parts && + !ArrayBuffer.isView(parts) && + typeof (parts as BlobLike).arrayBuffer === 'function' + ) { + return new InputFile( + { type: 'blob', data: parts as BlobLike }, + name, + ); + } - static fromBuffer(parts: BlobLike | Uint8Array | ArrayBuffer | string, name: string): InputFile { - if (parts && !ArrayBuffer.isView(parts) && typeof (parts as BlobLike).arrayBuffer === 'function') { - return new InputFile({ type: 'blob', data: parts as BlobLike }, name); + if (typeof parts === 'string') { + return new InputFile( + { type: 'buffer', data: new TextEncoder().encode(parts) }, + name, + ); + } + + if (parts instanceof ArrayBuffer) { + return new InputFile( + { type: 'buffer', data: new Uint8Array(parts) }, + name, + ); + } + + if (ArrayBuffer.isView(parts)) { + return new InputFile( + { + type: 'buffer', + data: new Uint8Array( + parts.buffer, + parts.byteOffset, + parts.byteLength, + ), + }, + name, + ); + } + + throw new Error('Unsupported input type for InputFile.fromBuffer'); } - if (typeof parts === 'string') { - return new InputFile({ type: 'buffer', data: new TextEncoder().encode(parts) }, name); + static fromPath(path: string, name?: string): InputFile { + assertFileSystemAvailable(); + return new InputFile({ type: 'path', path }, name ?? getFilename(path)); } - if (parts instanceof ArrayBuffer) { - return new InputFile({ type: 'buffer', data: new Uint8Array(parts) }, name); + static fromPlainText(content: string, name: string): InputFile { + return new InputFile( + { type: 'buffer', data: new TextEncoder().encode(content) }, + name, + ); } - if (ArrayBuffer.isView(parts)) { - return new InputFile({ - type: 'buffer', - data: new Uint8Array(parts.buffer, parts.byteOffset, parts.byteLength), - }, name); + async size(): Promise { + switch (this.source.type) { + case 'path': { + const fs = await getFs(); + return (await fs.stat(this.source.path)).size; + } + case 'buffer': + return this.source.data.length; + case 'blob': + return this.source.data.size; + } } - throw new Error('Unsupported input type for InputFile.fromBuffer'); - } + async slice(start: number, end: number): Promise { + const length = end - start; + + switch (this.source.type) { + case 'path': { + const fs = await getFs(); + const handle = await fs.open(this.source.path, 'r'); + try { + const buffer = new Uint8Array(length); + const result = await handle.read(buffer, 0, length, start); + return result.bytesRead === buffer.length + ? buffer + : buffer.subarray(0, result.bytesRead); + } finally { + await handle.close(); + } + } + case 'buffer': + return this.source.data.subarray(start, end); + case 'blob': { + const arrayBuffer = await this.source.data + .slice(start, end) + .arrayBuffer(); + return new Uint8Array(arrayBuffer); + } + } + } - static fromPath(path: string, name?: string): InputFile { - assertFileSystemAvailable(); - return new InputFile({ type: 'path', path }, name ?? getFilename(path)); - } - - static fromPlainText(content: string, name: string): InputFile { - return new InputFile({ type: 'buffer', data: new TextEncoder().encode(content) }, name); - } - - async size(): Promise { - switch (this.source.type) { - case 'path': { - const fs = await getFs(); - return (await fs.stat(this.source.path)).size; - } - case 'buffer': - return this.source.data.length; - case 'blob': - return this.source.data.size; + async toFile(): Promise { + const data = await this.toUint8Array(); + return new File([data], this.filename); } - } - - async slice(start: number, end: number): Promise { - const length = end - start; - - switch (this.source.type) { - case 'path': { - const fs = await getFs(); - const handle = await fs.open(this.source.path, 'r'); - try { - const buffer = new Uint8Array(length); - const result = await handle.read(buffer, 0, length, start); - return result.bytesRead === buffer.length ? buffer : buffer.subarray(0, result.bytesRead); - } finally { - await handle.close(); + + private async toUint8Array(): Promise { + switch (this.source.type) { + case 'path': { + const fs = await getFs(); + return await fs.readFile(this.source.path); + } + case 'buffer': + return this.source.data; + case 'blob': + return new Uint8Array(await this.source.data.arrayBuffer()); } - } - case 'buffer': - return this.source.data.subarray(start, end); - case 'blob': { - const arrayBuffer = await this.source.data.slice(start, end).arrayBuffer(); - return new Uint8Array(arrayBuffer); - } - } - } - - async toFile(): Promise { - const data = await this.toUint8Array(); - return new File([data], this.filename); - } - - private async toUint8Array(): Promise { - switch (this.source.type) { - case 'path': { - const fs = await getFs(); - return await fs.readFile(this.source.path); - } - case 'buffer': - return this.source.data; - case 'blob': - return new Uint8Array(await this.source.data.arrayBuffer()); } - } } diff --git a/src/models.ts b/src/models.ts index 14faf011..5ad29b76 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1,27 +1,26 @@ -import { DatabaseType } from "./enums/database-type" -import { DatabaseStatus } from "./enums/database-status" -import { AttributeStatus } from "./enums/attribute-status" -import { ColumnStatus } from "./enums/column-status" -import { IndexStatus } from "./enums/index-status" -import { DeploymentStatus } from "./enums/deployment-status" -import { ExecutionTrigger } from "./enums/execution-trigger" -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 { OAuth2GooglePrompt } from "./enums/o-auth-2-google-prompt" -import { OAuth2OidcPrompt } from "./enums/o-auth-2-oidc-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 { DatabaseType } from './enums/database-type'; +import { AttributeStatus } from './enums/attribute-status'; +import { ColumnStatus } from './enums/column-status'; +import { IndexStatus } from './enums/index-status'; +import { DeploymentStatus } from './enums/deployment-status'; +import { ExecutionResourceType } from './enums/execution-resource-type'; +import { ExecutionTrigger } from './enums/execution-trigger'; +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 { OAuth2GooglePrompt } from './enums/o-auth-2-google-prompt'; +import { OAuth2OidcPrompt } from './enums/o-auth-2-oidc-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'; /** * Appwrite Models */ export namespace Models { - declare const __default: unique symbol; /** @@ -36,12 +35,14 @@ export namespace Models { * List of rows. */ rows: Row[]; - } + }; /** * Documents List */ - export type DocumentList = { + export type DocumentList< + Document extends Models.Document = Models.DefaultDocument, + > = { /** * Total number of documents that matched your query. */ @@ -50,7 +51,7 @@ export namespace Models { * List of documents. */ documents: Document[]; - } + }; /** * Presences List @@ -64,7 +65,7 @@ export namespace Models { * List of presences. */ presences: Presence[]; - } + }; /** * Tables List @@ -78,7 +79,7 @@ export namespace Models { * List of tables. */ tables: Table[]; - } + }; /** * Collections List @@ -92,7 +93,7 @@ export namespace Models { * List of collections. */ collections: Collection[]; - } + }; /** * Databases List @@ -106,7 +107,7 @@ export namespace Models { * List of databases. */ databases: Database[]; - } + }; /** * Indexes List @@ -120,7 +121,7 @@ export namespace Models { * List of indexes. */ indexes: Index[]; - } + }; /** * Column Indexes List @@ -134,12 +135,14 @@ export namespace Models { * List of indexes. */ indexes: ColumnIndex[]; - } + }; /** * Users List */ - export type UserList = { + export type UserList< + Preferences extends Models.Preferences = Models.DefaultPreferences, + > = { /** * Total number of users that matched your query. */ @@ -148,7 +151,7 @@ export namespace Models { * List of users. */ users: User[]; - } + }; /** * Sessions List @@ -162,7 +165,7 @@ export namespace Models { * List of sessions. */ sessions: Session[]; - } + }; /** * Identities List @@ -176,7 +179,7 @@ export namespace Models { * List of identities. */ identities: Identity[]; - } + }; /** * Logs List @@ -190,7 +193,7 @@ export namespace Models { * List of logs. */ logs: Log[]; - } + }; /** * Files List @@ -204,7 +207,7 @@ export namespace Models { * List of files. */ files: File[]; - } + }; /** * Buckets List @@ -218,7 +221,7 @@ export namespace Models { * List of buckets. */ buckets: Bucket[]; - } + }; /** * Resource Tokens List @@ -232,12 +235,14 @@ export namespace Models { * List of tokens. */ tokens: ResourceToken[]; - } + }; /** * Teams List */ - export type TeamList = { + export type TeamList< + Preferences extends Models.Preferences = Models.DefaultPreferences, + > = { /** * Total number of teams that matched your query. */ @@ -246,7 +251,7 @@ export namespace Models { * List of teams. */ teams: Team[]; - } + }; /** * Memberships List @@ -260,7 +265,7 @@ export namespace Models { * List of memberships. */ memberships: Membership[]; - } + }; /** * Sites List @@ -274,7 +279,7 @@ export namespace Models { * List of sites. */ sites: Site[]; - } + }; /** * Functions List @@ -288,7 +293,7 @@ export namespace Models { * List of functions. */ functions: Function[]; - } + }; /** * Frameworks List @@ -302,7 +307,7 @@ export namespace Models { * List of frameworks. */ frameworks: Framework[]; - } + }; /** * Runtimes List @@ -316,7 +321,7 @@ export namespace Models { * List of runtimes. */ runtimes: Runtime[]; - } + }; /** * Deployments List @@ -330,7 +335,7 @@ export namespace Models { * List of deployments. */ deployments: Deployment[]; - } + }; /** * Executions List @@ -344,7 +349,7 @@ export namespace Models { * List of executions. */ executions: Execution[]; - } + }; /** * Projects List @@ -358,7 +363,7 @@ export namespace Models { * List of projects. */ projects: Project[]; - } + }; /** * Webhooks List @@ -372,7 +377,7 @@ export namespace Models { * List of webhooks. */ webhooks: Webhook[]; - } + }; /** * API Keys List @@ -386,7 +391,7 @@ export namespace Models { * List of keys. */ keys: Key[]; - } + }; /** * Countries List @@ -400,7 +405,7 @@ export namespace Models { * List of countries. */ countries: Country[]; - } + }; /** * Continents List @@ -414,7 +419,7 @@ export namespace Models { * List of continents. */ continents: Continent[]; - } + }; /** * Languages List @@ -428,7 +433,7 @@ export namespace Models { * List of languages. */ languages: Language[]; - } + }; /** * Currencies List @@ -442,7 +447,7 @@ export namespace Models { * List of currencies. */ currencies: Currency[]; - } + }; /** * Phones List @@ -456,7 +461,7 @@ export namespace Models { * List of phones. */ phones: Phone[]; - } + }; /** * Variables List @@ -470,7 +475,7 @@ export namespace Models { * List of variables. */ variables: Variable[]; - } + }; /** * Mock Numbers List @@ -484,7 +489,7 @@ export namespace Models { * List of mockNumbers. */ mockNumbers: MockNumber[]; - } + }; /** * Policies List @@ -497,8 +502,24 @@ export namespace Models { /** * List of policies. */ - policies: (Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail)[]; - } + policies: ( + | Models.PolicyPasswordDictionary + | Models.PolicyPasswordHistory + | Models.PolicyPasswordStrength + | Models.PolicyPasswordPersonalData + | Models.PolicySessionAlert + | Models.PolicySessionDuration + | Models.PolicySessionInvalidation + | Models.PolicySessionLimit + | Models.PolicyUserLimit + | Models.PolicyMembershipPrivacy + | Models.PolicyMfaFactors + | Models.PolicyDenyAliasedEmail + | Models.PolicyDenyDisposableEmail + | Models.PolicyDenyFreeEmail + | Models.PolicyDenyCorporateEmail + )[]; + }; /** * Email Templates List @@ -512,7 +533,7 @@ export namespace Models { * List of templates. */ templates: EmailTemplate[]; - } + }; /** * Rule List @@ -526,7 +547,7 @@ export namespace Models { * List of rules. */ rules: ProxyRule[]; - } + }; /** * Locale codes list @@ -540,7 +561,7 @@ export namespace Models { * List of localeCodes. */ localeCodes: LocaleCode[]; - } + }; /** * Provider list @@ -554,7 +575,7 @@ export namespace Models { * List of providers. */ providers: Provider[]; - } + }; /** * Message list @@ -568,7 +589,7 @@ export namespace Models { * List of messages. */ messages: Message[]; - } + }; /** * Topic list @@ -582,7 +603,7 @@ export namespace Models { * List of topics. */ topics: Topic[]; - } + }; /** * Subscriber list @@ -596,7 +617,7 @@ export namespace Models { * List of subscribers. */ subscribers: Subscriber[]; - } + }; /** * Target list @@ -610,7 +631,7 @@ export namespace Models { * List of targets. */ targets: Target[]; - } + }; /** * Transaction List @@ -624,7 +645,7 @@ export namespace Models { * List of transactions. */ transactions: Transaction[]; - } + }; /** * Specifications List @@ -638,7 +659,21 @@ export namespace Models { * List of specifications. */ specifications: Specification[]; - } + }; + + /** + * VectorsDB Collections List + */ + export type VectorsdbCollectionList = { + /** + * Total number of collections that matched your query. + */ + total: number; + /** + * List of collections. + */ + collections: VectorsdbCollection[]; + }; /** * Embedding list @@ -652,7 +687,7 @@ export namespace Models { * List of embeddings. */ embeddings: Embedding[]; - } + }; /** * Insights List @@ -666,7 +701,7 @@ export namespace Models { * List of insights. */ insights: Insight[]; - } + }; /** * Reports List @@ -680,7 +715,7 @@ export namespace Models { * List of reports. */ reports: Report[]; - } + }; /** * Database @@ -726,6 +761,18 @@ export namespace Models { * Number of secondary high availability replicas, excluding the primary. Null when backing configuration is unavailable. */ replicas?: number; + /** + * Error message when the dedicated backing failed. Null when the database has no dedicated backing or has not failed. + */ + error?: string; + /** + * Container status of the dedicated backing: active or inactive. Null when the database has no dedicated backing or the runtime has not reported one. + */ + containerStatus?: string; + /** + * Idle-lifecycle state of the dedicated backing: active, warm, cold, or hibernated. Null when the database has no dedicated backing or the runtime has not reported one. + */ + lifecycleState?: string; /** * Database backup policies. */ @@ -734,7 +781,7 @@ export namespace Models { * Database backup archives. */ archives?: BackupArchive[]; - } + }; /** * Embedding @@ -756,7 +803,7 @@ export namespace Models { * Error message if embedding generation fails. Empty string if no error. */ error: string; - } + }; /** * Collection @@ -797,7 +844,26 @@ export namespace Models { /** * Collection attributes. */ - attributes: (Models.AttributeBoolean | Models.AttributeBigint | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; + attributes: ( + | Models.AttributeBoolean + | Models.AttributeBigint + | Models.AttributeInteger + | Models.AttributeFloat + | Models.AttributeEmail + | Models.AttributeEnum + | Models.AttributeUrl + | Models.AttributeIp + | Models.AttributeDatetime + | Models.AttributeRelationship + | Models.AttributePoint + | Models.AttributeLine + | Models.AttributePolygon + | Models.AttributeVarchar + | Models.AttributeText + | Models.AttributeMediumtext + | Models.AttributeLongtext + | Models.AttributeString + )[]; /** * Collection indexes. */ @@ -810,7 +876,7 @@ export namespace Models { * Currently used document size in bytes based on defined attributes. */ bytesUsed: number; - } + }; /** * Attributes List @@ -823,8 +889,27 @@ export namespace Models { /** * List of attributes. */ - attributes: (Models.AttributeBoolean | Models.AttributeBigint | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; - } + attributes: ( + | Models.AttributeBoolean + | Models.AttributeBigint + | Models.AttributeInteger + | Models.AttributeFloat + | Models.AttributeEmail + | Models.AttributeEnum + | Models.AttributeUrl + | Models.AttributeIp + | Models.AttributeDatetime + | Models.AttributeRelationship + | Models.AttributePoint + | Models.AttributeLine + | Models.AttributePolygon + | Models.AttributeVarchar + | Models.AttributeText + | Models.AttributeMediumtext + | Models.AttributeLongtext + | Models.AttributeString + )[]; + }; /** * AttributeString @@ -874,7 +959,7 @@ export namespace Models { * Defines whether this attribute is encrypted or not. */ encrypt?: boolean; - } + }; /** * AttributeInteger @@ -924,7 +1009,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: number; - } + }; /** * AttributeBigInt @@ -974,7 +1059,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: number | bigint; - } + }; /** * AttributeFloat @@ -1024,7 +1109,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: number; - } + }; /** * AttributeBoolean @@ -1066,7 +1151,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: boolean; - } + }; /** * AttributeEmail @@ -1112,7 +1197,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: string; - } + }; /** * AttributeEnum @@ -1162,7 +1247,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: string; - } + }; /** * AttributeIP @@ -1208,7 +1293,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: string; - } + }; /** * AttributeURL @@ -1254,7 +1339,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: string; - } + }; /** * AttributeDatetime @@ -1300,7 +1385,7 @@ export namespace Models { * Default value for attribute when not provided. Only null is optional */ default?: string; - } + }; /** * AttributeRelationship @@ -1362,7 +1447,7 @@ export namespace Models { * Whether this is the parent or child side of the relationship */ side: string; - } + }; /** * AttributePoint @@ -1404,7 +1489,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: number[]; - } + }; /** * AttributeLine @@ -1446,7 +1531,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: number[][]; - } + }; /** * AttributePolygon @@ -1488,7 +1573,7 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: number[][][]; - } + }; /** * AttributeVarchar @@ -1538,7 +1623,7 @@ export namespace Models { * Defines whether this attribute is encrypted or not. */ encrypt?: boolean; - } + }; /** * AttributeText @@ -1584,7 +1669,7 @@ export namespace Models { * Defines whether this attribute is encrypted or not. */ encrypt?: boolean; - } + }; /** * AttributeMediumtext @@ -1630,7 +1715,7 @@ export namespace Models { * Defines whether this attribute is encrypted or not. */ encrypt?: boolean; - } + }; /** * AttributeLongtext @@ -1676,7 +1761,145 @@ export namespace Models { * Defines whether this attribute is encrypted or not. */ encrypt?: boolean; - } + }; + + /** + * VectorsDB Collection + */ + export type VectorsdbCollection = { + /** + * Collection ID. + */ + $id: string; + /** + * Collection creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Collection update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Collection permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; + /** + * Database ID. + */ + databaseId: string; + /** + * Collection name. + */ + name: string; + /** + * Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the collection is inaccessible to users, but remains accessible to Server SDKs using API keys. + */ + enabled: boolean; + /** + * Whether document-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + documentSecurity: boolean; + /** + * Collection attributes. + */ + attributes: (Models.AttributeObject | Models.AttributeVector)[]; + /** + * Collection indexes. + */ + indexes: Index[]; + /** + * Maximum document size in bytes. Returns 0 when no limit applies. + */ + bytesMax: number; + /** + * Currently used document size in bytes based on defined attributes. + */ + bytesUsed: number; + /** + * Embedding dimension. + */ + dimension: number; + }; + + /** + * AttributeObject + */ + export type AttributeObject = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + }; + + /** + * AttributeVector + */ + export type AttributeVector = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Vector dimensions. + */ + size: number; + }; /** * Table @@ -1717,7 +1940,26 @@ export namespace Models { /** * Table columns. */ - columns: (Models.ColumnBoolean | Models.ColumnBigint | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; + columns: ( + | Models.ColumnBoolean + | Models.ColumnBigint + | Models.ColumnInteger + | Models.ColumnFloat + | Models.ColumnEmail + | Models.ColumnEnum + | Models.ColumnUrl + | Models.ColumnIp + | Models.ColumnDatetime + | Models.ColumnRelationship + | Models.ColumnPoint + | Models.ColumnLine + | Models.ColumnPolygon + | Models.ColumnVarchar + | Models.ColumnText + | Models.ColumnMediumtext + | Models.ColumnLongtext + | Models.ColumnString + )[]; /** * Table indexes. */ @@ -1730,7 +1972,7 @@ export namespace Models { * Currently used row size in bytes based on defined columns. */ bytesUsed: number; - } + }; /** * Columns List @@ -1743,8 +1985,27 @@ export namespace Models { /** * List of columns. */ - columns: (Models.ColumnBoolean | Models.ColumnBigint | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; - } + columns: ( + | Models.ColumnBoolean + | Models.ColumnBigint + | Models.ColumnInteger + | Models.ColumnFloat + | Models.ColumnEmail + | Models.ColumnEnum + | Models.ColumnUrl + | Models.ColumnIp + | Models.ColumnDatetime + | Models.ColumnRelationship + | Models.ColumnPoint + | Models.ColumnLine + | Models.ColumnPolygon + | Models.ColumnVarchar + | Models.ColumnText + | Models.ColumnMediumtext + | Models.ColumnLongtext + | Models.ColumnString + )[]; + }; /** * ColumnString @@ -1794,7 +2055,7 @@ export namespace Models { * Defines whether this column is encrypted or not. */ encrypt?: boolean; - } + }; /** * ColumnInteger @@ -1844,7 +2105,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: number; - } + }; /** * ColumnBigInt @@ -1894,7 +2155,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: number | bigint; - } + }; /** * ColumnFloat @@ -1944,7 +2205,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: number; - } + }; /** * ColumnBoolean @@ -1986,7 +2247,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: boolean; - } + }; /** * ColumnEmail @@ -2032,7 +2293,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: string; - } + }; /** * ColumnEnum @@ -2082,7 +2343,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: string; - } + }; /** * ColumnIP @@ -2128,7 +2389,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: string; - } + }; /** * ColumnURL @@ -2174,7 +2435,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: string; - } + }; /** * ColumnDatetime @@ -2220,7 +2481,7 @@ export namespace Models { * Default value for column when not provided. Only null is optional */ default?: string; - } + }; /** * ColumnRelationship @@ -2282,7 +2543,7 @@ export namespace Models { * Whether this is the parent or child side of the relationship */ side: string; - } + }; /** * ColumnPoint @@ -2324,7 +2585,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: number[]; - } + }; /** * ColumnLine @@ -2366,7 +2627,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: number[][]; - } + }; /** * ColumnPolygon @@ -2408,7 +2669,7 @@ export namespace Models { * Default value for column when not provided. Cannot be set when column is required. */ default?: number[][][]; - } + }; /** * ColumnVarchar @@ -2458,7 +2719,7 @@ export namespace Models { * Defines whether this column is encrypted or not. */ encrypt?: boolean; - } + }; /** * ColumnText @@ -2504,7 +2765,7 @@ export namespace Models { * Defines whether this column is encrypted or not. */ encrypt?: boolean; - } + }; /** * ColumnMediumtext @@ -2550,7 +2811,7 @@ export namespace Models { * Defines whether this column is encrypted or not. */ encrypt?: boolean; - } + }; /** * ColumnLongtext @@ -2596,7 +2857,7 @@ export namespace Models { * Defines whether this column is encrypted or not. */ encrypt?: boolean; - } + }; /** * Index @@ -2642,7 +2903,7 @@ export namespace Models { * Index orders. */ orders?: string[]; - } + }; /** * Index @@ -2688,7 +2949,7 @@ export namespace Models { * Index orders. */ orders?: string[]; - } + }; /** * Row @@ -2722,7 +2983,7 @@ export namespace Models { * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ $permissions: string[]; - } + }; export type DefaultRow = Row & { [key: string]: any; @@ -2761,7 +3022,7 @@ export namespace Models { * Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ $permissions: string[]; - } + }; export type DefaultDocument = Document & { [key: string]: any; @@ -2808,7 +3069,7 @@ export namespace Models { * Presence metadata. */ metadata?: object; - } + }; /** * Log @@ -2902,12 +3163,14 @@ export namespace Models { * Country name. */ countryName: string; - } + }; /** * User */ - export type User = { + export type User< + Preferences extends Models.Preferences = Models.DefaultPreferences, + > = { /** * User ID. */ @@ -3012,7 +3275,7 @@ export namespace Models { * 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; - } + }; /** * AlgoMD5 @@ -3022,7 +3285,7 @@ export namespace Models { * Algo type. */ type: string; - } + }; /** * AlgoSHA @@ -3032,7 +3295,7 @@ export namespace Models { * Algo type. */ type: string; - } + }; /** * AlgoPHPass @@ -3042,7 +3305,7 @@ export namespace Models { * Algo type. */ type: string; - } + }; /** * AlgoBcrypt @@ -3052,7 +3315,7 @@ export namespace Models { * Algo type. */ type: string; - } + }; /** * AlgoScrypt @@ -3078,7 +3341,7 @@ export namespace Models { * Length used to compute hash. */ length: number; - } + }; /** * AlgoScryptModified @@ -3100,7 +3363,7 @@ export namespace Models { * Key used to compute hash. */ signerKey: string; - } + }; /** * AlgoArgon2 @@ -3122,13 +3385,12 @@ export namespace Models { * Number of threads used to compute hash. */ threads: number; - } + }; /** * Preferences */ - export type Preferences = { - } + export type Preferences = {}; export type DefaultPreferences = Preferences & { [key: string]: any; @@ -3255,7 +3517,7 @@ export namespace Models { * Most recent date in ISO 8601 format when the session successfully passed MFA challenge. */ mfaUpdatedAt: string; - } + }; /** * Identity @@ -3301,7 +3563,7 @@ export namespace Models { * Identity Provider Refresh Token. */ providerRefreshToken: string; - } + }; /** * Token @@ -3331,7 +3593,7 @@ export namespace Models { * Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. */ phrase: string; - } + }; /** * JWT @@ -3341,7 +3603,7 @@ export namespace Models { * JWT encoded string. */ jwt: string; - } + }; /** * Locale @@ -3419,7 +3681,7 @@ export namespace Models { * Registered organization of the IP */ connectionOrganization?: string; - } + }; /** * LocaleCode @@ -3433,7 +3695,7 @@ export namespace Models { * Locale name */ name: string; - } + }; /** * File @@ -3503,7 +3765,7 @@ export namespace Models { * Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). */ compression: string; - } + }; /** * Bucket @@ -3565,7 +3827,7 @@ export namespace Models { * Total size of this bucket in bytes. */ totalSize: number; - } + }; /** * ResourceToken @@ -3599,12 +3861,14 @@ export namespace Models { * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. */ accessedAt: string; - } + }; /** * Team */ - export type Team = { + export type Team< + Preferences extends Models.Preferences = Models.DefaultPreferences, + > = { /** * Team ID. */ @@ -3629,7 +3893,7 @@ export namespace Models { * Team preferences as a key-value object */ prefs: Preferences; - } + }; /** * Membership @@ -3695,7 +3959,7 @@ export namespace Models { * User list of roles */ roles: string[]; - } + }; /** * Site @@ -3765,6 +4029,10 @@ export namespace Models { * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". */ latestDeploymentStatus: string; + /** + * Allowed permission scopes. + */ + scopes: string[]; /** * Site variables. */ @@ -3837,7 +4105,7 @@ export namespace Models { * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. */ fallbackFile: string; - } + }; /** * Function @@ -3971,7 +4239,7 @@ export namespace Models { * Machine specification for executions. */ runtimeSpecification: string; - } + }; /** * Runtime @@ -4009,7 +4277,7 @@ export namespace Models { * List of supported architectures. */ supports: string[]; - } + }; /** * Framework @@ -4035,7 +4303,7 @@ export namespace Models { * List of supported adapters. */ adapters: FrameworkAdapter[]; - } + }; /** * Framework Adapter @@ -4061,7 +4329,7 @@ export namespace Models { * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. */ fallbackFile: string; - } + }; /** * Deployment @@ -4175,7 +4443,7 @@ export namespace Models { * The branch of the vcs repository */ providerBranchUrl: string; - } + }; /** * Execution @@ -4198,19 +4466,23 @@ export namespace Models { */ $permissions: string[]; /** - * Function ID. + * Function or site ID. + */ + resourceId: string; + /** + * Execution resource type. */ - functionId: string; + resourceType: ExecutionResourceType; /** - * Function's deployment ID used to create the execution. + * Deployment ID used to create the execution. */ deploymentId: string; /** - * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + * The trigger that caused the resource to execute. Possible values can be: `http`, `schedule`, or `event`. */ trigger: ExecutionTrigger; /** - * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + * The status of the resource execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. */ status: ExecutionStatus; /** @@ -4238,11 +4510,11 @@ export namespace Models { */ responseHeaders: Headers[]; /** - * Function logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + * Resource logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. */ logs: string; /** - * Function errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + * Resource errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. */ errors: string; /** @@ -4253,7 +4525,7 @@ export namespace Models { * The scheduled time for execution. If left empty, execution will be queued immediately. */ scheduledAt?: string; - } + }; /** * Project @@ -4370,7 +4642,7 @@ export namespace Models { /** * Whether WAF enforcement is enabled for the project. */ - wafEnabled: boolean; + wafEnabled?: boolean; /** * Billing limits reached */ @@ -4443,7 +4715,7 @@ export namespace Models { * OAuth2 server discovery URL */ oAuth2ServerDiscoveryUrl?: string; - } + }; /** * ProjectAuthMethod @@ -4457,7 +4729,7 @@ export namespace Models { * Auth method status. */ enabled: boolean; - } + }; /** * ProjectService @@ -4471,7 +4743,7 @@ export namespace Models { * Service status. */ enabled: boolean; - } + }; /** * ProjectProtocol @@ -4485,7 +4757,7 @@ export namespace Models { * Protocol status. */ enabled: boolean; - } + }; /** * Webhook @@ -4543,7 +4815,7 @@ export namespace Models { * Number of consecutive failed webhook attempts. */ attempts: number; - } + }; /** * Key @@ -4585,7 +4857,7 @@ export namespace Models { * List of SDK user agents that used this key. */ sdks: string[]; - } + }; /** * Ephemeral Key @@ -4627,7 +4899,7 @@ export namespace Models { * List of SDK user agents that used this key. */ sdks: string[]; - } + }; /** * DevKey @@ -4665,7 +4937,7 @@ export namespace Models { * List of SDK user agents that used this key. */ sdks: string[]; - } + }; /** * Mock Number @@ -4676,7 +4948,7 @@ export namespace Models { */ number: string; /** - * Mock OTP for the number. + * Mock OTP for the number. */ otp: string; /** @@ -4687,7 +4959,7 @@ export namespace Models { * Attribute update date in ISO 8601 format. */ $updatedAt: string; - } + }; /** * OAuth2GitHub @@ -4709,7 +4981,7 @@ export namespace Models { * GitHub OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Discord @@ -4731,7 +5003,7 @@ export namespace Models { * Discord OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Figma @@ -4753,7 +5025,7 @@ export namespace Models { * Figma OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Dropbox @@ -4775,7 +5047,7 @@ export namespace Models { * Dropbox OAuth2 app secret. */ appSecret: string; - } + }; /** * OAuth2Dailymotion @@ -4797,7 +5069,7 @@ export namespace Models { * Dailymotion OAuth2 API secret. */ apiSecret: string; - } + }; /** * OAuth2Bitbucket @@ -4819,7 +5091,7 @@ export namespace Models { * Bitbucket OAuth2 secret. */ secret: string; - } + }; /** * OAuth2Bitly @@ -4841,7 +5113,7 @@ export namespace Models { * Bitly OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Box @@ -4863,7 +5135,7 @@ export namespace Models { * Box OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Autodesk @@ -4885,7 +5157,7 @@ export namespace Models { * Autodesk OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Google @@ -4911,7 +5183,7 @@ export namespace Models { * Google OAuth2 prompt values. */ prompt: OAuth2GooglePrompt[]; - } + }; /** * OAuth2Zoom @@ -4933,7 +5205,7 @@ export namespace Models { * Zoom OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Zoho @@ -4955,7 +5227,7 @@ export namespace Models { * Zoho OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Yandex @@ -4977,7 +5249,7 @@ export namespace Models { * Yandex OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2X @@ -4999,7 +5271,7 @@ export namespace Models { * X OAuth2 secret key. */ secretKey: string; - } + }; /** * OAuth2WordPress @@ -5021,7 +5293,7 @@ export namespace Models { * WordPress OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Twitch @@ -5043,7 +5315,7 @@ export namespace Models { * Twitch OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Stripe @@ -5065,7 +5337,7 @@ export namespace Models { * Stripe OAuth2 API secret key. */ apiSecretKey: string; - } + }; /** * OAuth2Spotify @@ -5087,7 +5359,7 @@ export namespace Models { * Spotify OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Slack @@ -5109,7 +5381,7 @@ export namespace Models { * Slack OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Podio @@ -5131,7 +5403,7 @@ export namespace Models { * Podio OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Notion @@ -5153,7 +5425,7 @@ export namespace Models { * Notion OAuth2 client secret. */ oauthClientSecret: string; - } + }; /** * OAuth2Salesforce @@ -5175,7 +5447,7 @@ export namespace Models { * Salesforce OAuth2 consumer secret. */ customerSecret: string; - } + }; /** * OAuth2Yahoo @@ -5197,7 +5469,29 @@ export namespace Models { * Yahoo OAuth2 client secret. */ clientSecret: string; - } + }; + + /** + * OAuth2HuggingFace + */ + export type OAuth2HuggingFace = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Hugging Face OAuth2 client ID. + */ + clientId: string; + /** + * Hugging Face OAuth2 client secret. + */ + clientSecret: string; + }; /** * OAuth2Linkedin @@ -5219,7 +5513,7 @@ export namespace Models { * LinkedIn OAuth2 primary client secret. */ primaryClientSecret: string; - } + }; /** * OAuth2Disqus @@ -5241,7 +5535,7 @@ export namespace Models { * Disqus OAuth2 secret key. */ secretKey: string; - } + }; /** * OAuth2Amazon @@ -5263,7 +5557,7 @@ export namespace Models { * Amazon OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Etsy @@ -5285,7 +5579,7 @@ export namespace Models { * Etsy OAuth2 shared secret. */ sharedSecret: string; - } + }; /** * OAuth2Facebook @@ -5307,7 +5601,7 @@ export namespace Models { * Facebook OAuth2 app secret. */ appSecret: string; - } + }; /** * OAuth2Tradeshift @@ -5329,7 +5623,7 @@ export namespace Models { * Tradeshift OAuth2 client secret. */ oauth2ClientSecret: string; - } + }; /** * OAuth2Paypal @@ -5351,7 +5645,7 @@ export namespace Models { * PayPal OAuth2 secret key. */ secretKey: string; - } + }; /** * OAuth2Gitlab @@ -5377,7 +5671,7 @@ export namespace Models { * GitLab OAuth2 endpoint URL. Defaults to https://gitlab.com for self-hosted instances. */ endpoint: string; - } + }; /** * OAuth2Appwrite @@ -5399,7 +5693,7 @@ export namespace Models { * Appwrite OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Authentik @@ -5425,7 +5719,7 @@ export namespace Models { * Authentik OAuth2 endpoint domain. */ endpoint: string; - } + }; /** * OAuth2Auth0 @@ -5451,7 +5745,7 @@ export namespace Models { * Auth0 OAuth2 endpoint domain. */ endpoint: string; - } + }; /** * OAuth2FusionAuth @@ -5477,7 +5771,7 @@ export namespace Models { * FusionAuth OAuth2 endpoint domain. */ endpoint: string; - } + }; /** * OAuth2Keycloak @@ -5507,7 +5801,7 @@ export namespace Models { * Keycloak OAuth2 realm name. */ realmName: string; - } + }; /** * OAuth2Oidc @@ -5553,7 +5847,7 @@ export namespace Models { * Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds. */ maxAge?: number; - } + }; /** * OAuth2Okta @@ -5583,7 +5877,7 @@ export namespace Models { * Okta OAuth2 authorization server ID. */ authorizationServerId: string; - } + }; /** * OAuth2Kick @@ -5605,7 +5899,7 @@ export namespace Models { * Kick OAuth2 client secret. */ clientSecret: string; - } + }; /** * OAuth2Apple @@ -5635,7 +5929,7 @@ export namespace Models { * Apple OAuth2 .p8 private key file contents. The secret key wrapped by the PEM markers is 200 characters long. */ p8File: string; - } + }; /** * OAuth2Microsoft @@ -5661,7 +5955,7 @@ export namespace Models { * Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. */ tenant: string; - } + }; /** * OAuth2 Providers List @@ -5674,8 +5968,51 @@ export namespace Models { /** * List of OAuth2 providers. */ - providers: (Models.OAuth2Github | Models.OAuth2Discord | Models.OAuth2Figma | Models.OAuth2Dropbox | Models.OAuth2Dailymotion | Models.OAuth2Bitbucket | Models.OAuth2Bitly | Models.OAuth2Box | Models.OAuth2Autodesk | Models.OAuth2Google | Models.OAuth2Zoom | Models.OAuth2Zoho | Models.OAuth2Yandex | Models.OAuth2X | Models.OAuth2WordPress | Models.OAuth2Twitch | Models.OAuth2Stripe | Models.OAuth2Spotify | Models.OAuth2Slack | Models.OAuth2Podio | Models.OAuth2Notion | Models.OAuth2Salesforce | Models.OAuth2Yahoo | Models.OAuth2Linkedin | Models.OAuth2Disqus | Models.OAuth2Amazon | Models.OAuth2Etsy | Models.OAuth2Facebook | Models.OAuth2Tradeshift | Models.OAuth2Paypal | Models.OAuth2Gitlab | Models.OAuth2Appwrite | Models.OAuth2Authentik | Models.OAuth2Auth0 | Models.OAuth2FusionAuth | Models.OAuth2Keycloak | Models.OAuth2Oidc | Models.OAuth2Apple | Models.OAuth2Okta | Models.OAuth2Kick | Models.OAuth2Microsoft)[]; - } + providers: ( + | Models.OAuth2Github + | Models.OAuth2Discord + | Models.OAuth2Figma + | Models.OAuth2Dropbox + | Models.OAuth2Dailymotion + | Models.OAuth2Bitbucket + | Models.OAuth2Bitly + | Models.OAuth2Box + | Models.OAuth2Autodesk + | Models.OAuth2Google + | Models.OAuth2Zoom + | Models.OAuth2Zoho + | Models.OAuth2Yandex + | Models.OAuth2X + | Models.OAuth2WordPress + | Models.OAuth2Twitch + | Models.OAuth2Stripe + | Models.OAuth2Spotify + | Models.OAuth2Slack + | Models.OAuth2Podio + | Models.OAuth2Notion + | Models.OAuth2Salesforce + | Models.OAuth2Yahoo + | Models.OAuth2Linkedin + | Models.OAuth2Disqus + | Models.OAuth2Amazon + | Models.OAuth2Etsy + | Models.OAuth2Facebook + | Models.OAuth2Tradeshift + | Models.OAuth2Paypal + | Models.OAuth2Gitlab + | Models.OAuth2Appwrite + | Models.OAuth2Authentik + | Models.OAuth2Auth0 + | Models.OAuth2FusionAuth + | Models.OAuth2Keycloak + | Models.OAuth2Oidc + | Models.OAuth2Apple + | Models.OAuth2Okta + | Models.OAuth2Kick + | Models.OAuth2Microsoft + | Models.OAuth2HuggingFace + )[]; + }; /** * Policy Password Dictionary @@ -5689,7 +6026,7 @@ export namespace Models { * Whether password dictionary policy is enabled. */ enabled: boolean; - } + }; /** * Policy Password History @@ -5703,7 +6040,7 @@ export namespace Models { * Password history length. A value of 0 means the policy is disabled. */ total: number; - } + }; /** * Policy Password Strength @@ -5733,7 +6070,7 @@ export namespace Models { * Whether passwords must include at least one symbol. */ symbols: boolean; - } + }; /** * Policy Password Personal Data @@ -5747,7 +6084,7 @@ export namespace Models { * Whether password personal data policy is enabled. */ enabled: boolean; - } + }; /** * Policy Session Alert @@ -5761,7 +6098,7 @@ export namespace Models { * Whether session alert policy is enabled. */ enabled: boolean; - } + }; /** * Policy Session Duration @@ -5775,7 +6112,7 @@ export namespace Models { * Session duration in seconds. */ duration: number; - } + }; /** * Policy Session Invalidation @@ -5789,7 +6126,7 @@ export namespace Models { * Whether session invalidation policy is enabled. */ enabled: boolean; - } + }; /** * Policy Session Limit @@ -5803,7 +6140,7 @@ export namespace Models { * Maximum number of sessions allowed per user. A value of 0 means the policy is disabled. */ total: number; - } + }; /** * Policy User Limit @@ -5817,7 +6154,7 @@ export namespace Models { * Maximum number of users allowed in the project. A value of 0 means the policy is disabled. */ total: number; - } + }; /** * Policy Membership Privacy @@ -5851,7 +6188,7 @@ export namespace Models { * Whether user last access time is visible in memberships. */ userAccessedAt: boolean; - } + }; /** * Policy MFA Factors @@ -5877,7 +6214,7 @@ export namespace Models { * Whether the custom factor can be used to complete an MFA challenge. */ custom: boolean; - } + }; /** * Platform Web @@ -5907,7 +6244,7 @@ export namespace Models { * Web app hostname. Empty string for other platforms. */ hostname: string; - } + }; /** * Platform Apple @@ -5937,7 +6274,7 @@ export namespace Models { * Apple bundle identifier. */ bundleIdentifier: string; - } + }; /** * Platform Android @@ -5967,7 +6304,7 @@ export namespace Models { * Android application ID. */ applicationId: string; - } + }; /** * Platform Windows @@ -5997,7 +6334,7 @@ export namespace Models { * Windows package identifier name. */ packageIdentifierName: string; - } + }; /** * Platform Linux @@ -6027,7 +6364,7 @@ export namespace Models { * Linux package name. */ packageName: string; - } + }; /** * Platforms List @@ -6040,8 +6377,14 @@ export namespace Models { /** * List of platforms. */ - platforms: (Models.PlatformWeb | Models.PlatformApple | Models.PlatformAndroid | Models.PlatformWindows | Models.PlatformLinux)[]; - } + platforms: ( + | Models.PlatformWeb + | Models.PlatformApple + | Models.PlatformAndroid + | Models.PlatformWindows + | Models.PlatformLinux + )[]; + }; /** * Variable @@ -6079,7 +6422,7 @@ export namespace Models { * ID of resource to which the variable belongs. If resourceType is "project", it is empty. If resourceType is "function", it is ID of the function. */ resourceId: string; - } + }; /** * Country @@ -6093,7 +6436,7 @@ export namespace Models { * Country two-character ISO 3166-1 alpha code. */ code: string; - } + }; /** * Continent @@ -6107,7 +6450,7 @@ export namespace Models { * Continent two letter code. */ code: string; - } + }; /** * Language @@ -6125,7 +6468,7 @@ export namespace Models { * Language native name. */ nativeName: string; - } + }; /** * Currency @@ -6159,7 +6502,7 @@ export namespace Models { * Currency plural name */ namePlural: string; - } + }; /** * Phone @@ -6177,7 +6520,7 @@ export namespace Models { * Country name. */ countryName: string; - } + }; /** * Headers @@ -6191,7 +6534,7 @@ export namespace Models { * Header value. */ value: string; - } + }; /** * Specification @@ -6213,7 +6556,7 @@ export namespace Models { * Size slug. */ slug: string; - } + }; /** * Rule @@ -6279,7 +6622,7 @@ export namespace Models { * Certificate auto-renewal date in ISO 8601 format. */ renewAt: string; - } + }; /** * EmailTemplate @@ -6317,7 +6660,7 @@ export namespace Models { * Email subject */ subject: string; - } + }; /** * MFA Challenge @@ -6339,7 +6682,7 @@ export namespace Models { * Token expiration date in ISO 8601 format. */ expire: string; - } + }; /** * MFA Challenge Secret @@ -6365,7 +6708,7 @@ export namespace Models { * Challenge code to be delivered to the end user through a custom channel. */ code: string; - } + }; /** * MFA Recovery Codes @@ -6375,7 +6718,7 @@ export namespace Models { * Recovery codes. */ recoveryCodes: string[]; - } + }; /** * MFAType @@ -6389,7 +6732,7 @@ export namespace Models { * URI for authenticator apps. */ uri: string; - } + }; /** * MFAFactors @@ -6415,7 +6758,7 @@ export namespace Models { * Can custom factor be used for MFA challenge for this account. */ custom: boolean; - } + }; /** * Provider @@ -6457,7 +6800,7 @@ export namespace Models { * Provider options. */ options?: object; - } + }; /** * Message @@ -6515,7 +6858,7 @@ export namespace Models { * Status of delivery. */ status: MessageStatus; - } + }; /** * Topic @@ -6553,7 +6896,7 @@ export namespace Models { * Subscribe permissions. */ subscribe: string[]; - } + }; /** * Transaction @@ -6583,7 +6926,7 @@ export namespace Models { * Expiration time in ISO 8601 format. */ expiresAt: string; - } + }; /** * Subscriber @@ -6625,7 +6968,7 @@ export namespace Models { * The target provider type. Can be one of the following: `email`, `sms` or `push`. */ providerType: string; - } + }; /** * Target @@ -6667,7 +7010,7 @@ export namespace Models { * Is the target expired. */ expired: boolean; - } + }; /** * Insight @@ -6741,7 +7084,7 @@ export namespace Models { * User ID that dismissed the insight. Empty when not dismissed. */ dismissedBy?: string; - } + }; /** * InsightCTA @@ -6763,7 +7106,7 @@ export namespace Models { * Parameter map the client should pass to the service method when this CTA is triggered. Keys match the target API's parameter names (e.g. databaseId/tableId/columns for tablesDB, databaseId/collectionId/attributes for the legacy Databases API). */ params: object; - } + }; /** * Report @@ -6817,7 +7160,7 @@ export namespace Models { * Time the report was analyzed in ISO 8601 format. */ analyzedAt?: string; - } + }; /** * ActivityEvent @@ -6939,7 +7282,7 @@ export namespace Models { * Version of the SDK that triggered the event. */ sdkVersion: string; - } + }; /** * AdditionalResource @@ -6969,7 +7312,7 @@ export namespace Models { * Description on invoice */ invoiceDesc: string; - } + }; /** * Archive @@ -7023,7 +7366,121 @@ export namespace Models { * The resource type to backup. Set only if this archive should backup a single resource. */ resourceType?: string; - } + }; + + /** + * Backup + */ + export type DedicatedDatabaseBackup = { + /** + * Backup ID. + */ + $id: string; + /** + * Backup creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Database ID this backup belongs to. + */ + databaseId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Backup policy ID when the backup was created by a schedule. + */ + policyId: string; + /** + * Backup trigger. Possible values: manual, schedule. + */ + trigger: string; + /** + * Backup type. Possible values: full (complete database snapshot), incremental (changes since last backup), wal (write-ahead log continuous archival). + */ + type: string; + /** + * Backup type that was requested. Differs from `type` when the backend could not run the requested type and took a different one instead, in which case `fallbackReason` explains why. Empty for backups taken before the requested type was recorded. + */ + requestedType: string; + /** + * Why the backend ran a different backup type than the one requested. Empty when the backup ran as requested. + */ + fallbackReason: string; + /** + * Backup status. Possible values: pending (queued for processing), running (currently in progress), completed (successfully finished), failed (encountered an error), verified (integrity check passed). + */ + status: string; + /** + * Backup size in bytes. + */ + sizeBytes: number; + /** + * Backup start time in ISO 8601 format. + */ + startedAt?: string; + /** + * Backup completion time in ISO 8601 format. + */ + completedAt?: string; + /** + * Backup verification time in ISO 8601 format. + */ + verifiedAt?: string; + /** + * Backup expiration time in ISO 8601 format. + */ + expiresAt?: string; + /** + * Transaction-log position the backup anchors at, in the engine's own notation: PostgreSQL `{walSegment}|{lsn}`, MySQL and MariaDB `{binlogFile}|{offset}`, MongoDB `{seconds}|{increment}`. Empty when the backup recorded no position, which is the case for backup types that carry none. + */ + logPosition?: string; + /** + * Error message if backup failed. + */ + error: string; + }; + + /** + * BackupList + */ + export type DedicatedDatabaseBackupList = { + /** + * Total number of backups. + */ + total: number; + /** + * List of backups. + */ + backups: DedicatedDatabaseBackup[]; + }; + + /** + * BackupStorageConfig + */ + export type DedicatedDatabaseBackupStorage = { + /** + * Storage provider. Possible values: s3 (Amazon S3 or S3-compatible), gcs (Google Cloud Storage), azure (Azure Blob Storage). + */ + provider: string; + /** + * Storage bucket or container name. + */ + bucket: string; + /** + * Storage region. + */ + region: string; + /** + * Object key prefix for backups. + */ + prefix: string; + /** + * Custom endpoint for S3-compatible storage. + */ + endpoint: string; + }; /** * Limits @@ -7061,7 +7518,7 @@ export namespace Models { * Budget limit percentage */ budgetLimit?: number; - } + }; /** * billingPlan @@ -7279,6 +7736,10 @@ export namespace Models { * Does plan support credit */ supportsCredits: boolean; + /** + * Does plan support dedicated databases. + */ + supportsDedicatedDatabases: boolean; /** * Does plan support blocking disposable email addresses. */ @@ -7339,11 +7800,15 @@ export namespace Models { * Details of the program this plan is a part of. */ program?: Program; + /** + * Included monthly dedicated-database compute credit in USD. Resets each billing cycle with no roll-over. + */ + databaseComputeCredit: number; /** * Dedicated database limits available to this plan. */ dedicatedDatabases?: BillingPlanDedicatedDatabaseLimits; - } + }; /** * Addon @@ -7357,7 +7822,7 @@ export namespace Models { * Addon projects */ projects?: BillingPlanAddonDetails; - } + }; /** * Details @@ -7395,7 +7860,7 @@ export namespace Models { * Description on invoice */ invoiceDesc: string; - } + }; /** * PlanLimits @@ -7409,7 +7874,7 @@ export namespace Models { * Daily credits limit (if applicable) */ dailyCredits?: number; - } + }; /** * dedicatedDatabaseLimits @@ -7491,7 +7956,7 @@ export namespace Models { * Replica synchronization modes available for dedicated databases. */ allowedSyncModes?: string[]; - } + }; /** * BillingPlanSupportedAddons @@ -7509,7 +7974,7 @@ export namespace Models { * Whether the plan supports Premium Geo DB addon (organization-level) */ premiumGeoDBOrg: boolean; - } + }; /** * Block @@ -7559,7 +8024,75 @@ export namespace Models { * Billing plan of the organization that owns the project. */ billingPlan: string; - } + }; + + /** + * Branch + */ + export type DedicatedDatabaseBranch = { + /** + * Branch identifier. + */ + branchId: string; + /** + * Branch name. + */ + branchName: string; + /** + * Kubernetes namespace where the branch is deployed. + */ + namespace: string; + /** + * Unix timestamp when the branch expires. + */ + expiresAt: number; + /** + * Branch hostname for direct connections. + */ + host: string; + /** + * Branch port. Null until the backing reports one. + */ + port: number; + /** + * Advertised catalog the client connects to. MySQL/MariaDB use default; Postgres uses the routing label. + */ + database: string; + /** + * Database username. Shared with the parent database. + */ + username: string; + /** + * Database password. Shared with the parent database. + */ + password: string; + /** + * Whether SSL is required. + */ + ssl: boolean; + /** + * Database engine. Possible values: postgresql, mysql, mongodb. + */ + engine: string; + /** + * Full connection string for the branch. + */ + connectionString: string; + }; + + /** + * BranchList + */ + export type DedicatedDatabaseBranchList = { + /** + * Total number of branches. + */ + total: number; + /** + * List of branches. + */ + branches: DedicatedDatabaseBranch[]; + }; /** * Database Migration @@ -7605,6 +8138,10 @@ export namespace Models { * Number of documents still pending replication to the target. */ lagDocuments: number; + /** + * Highest source changelog sequence applied to the target so far. + */ + changelogWatermark: number; /** * Time the migrated data was verified against the source in ISO 8601 format. */ @@ -7629,7 +8166,7 @@ export namespace Models { * Whether the migration is paused. */ paused: boolean; - } + }; /** * DedicatedDatabase @@ -7827,7 +8364,105 @@ export namespace Models { * Error message if status is failed. */ error: string; - } + }; + + /** + * Execution + */ + export type DedicatedDatabaseExecution = { + /** + * Result rows as a list of column-name => value maps. Empty for non-returning statements. + */ + rows: Record[]; + /** + * Number of rows returned (for SELECT) or affected (for INSERT/UPDATE/DELETE). + */ + rowCount: number; + /** + * Column metadata in result-set order. + */ + columns: DedicatedDatabaseExecutionColumn[]; + /** + * Server-side execution time in milliseconds. + */ + durationMs: number; + /** + * True when the configured row or byte cap was hit and the result was truncated. + */ + truncated: boolean; + /** + * Serialised payload size in bytes. + */ + bytes: number; + }; + + /** + * ExecutionColumn + */ + export type DedicatedDatabaseExecutionColumn = { + /** + * Column name as returned by the database. + */ + name: string; + /** + * Engine-specific column type (e.g. int4, text, timestamptz). + */ + type: string; + }; + + /** + * Restoration + */ + export type DedicatedDatabaseRestoration = { + /** + * Restoration ID. + */ + $id: string; + /** + * Restoration creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Database ID being restored into. + */ + databaseId: string; + /** + * Source database ID when restoring a backup into another database. + */ + sourceDatabaseId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Backup ID used for restoration (null for PITR). + */ + backupId: string; + /** + * Restoration type. Possible values: backup (restore from a specific backup snapshot), pitr (point-in-time recovery to a specific timestamp). + */ + type: string; + /** + * Restoration status. Possible values: pending (queued for processing), running (currently in progress), completed (successfully finished), failed (encountered an error). + */ + status: string; + /** + * Target time for PITR restoration in ISO 8601 format. + */ + targetTime: string; + /** + * Restoration start time in ISO 8601 format. + */ + startedAt: string; + /** + * Restoration completion time in ISO 8601 format. + */ + completedAt: string; + /** + * Error message if restoration failed. + */ + error: string; + }; /** * Status @@ -7889,7 +8524,25 @@ export namespace Models { * Storage volume information. */ volumes: DatabaseStatusVolume[]; - } + }; + + /** + * 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 @@ -7908,10 +8561,14 @@ export namespace Models { */ status: string; /** - * 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. + * 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 @@ -7934,7 +8591,7 @@ export namespace Models { */ type: string; /** - * Operation status. Possible values: running (in progress), completed (finished successfully), failed (ended in an error). + * Operation status. Possible values: queued (accepted and waiting to resume), running (in progress), completed (finished successfully), failed (ended in an error). */ status: string; /** @@ -7961,7 +8618,7 @@ export namespace Models { * Failure message if the operation failed. */ errorMessage: string; - } + }; /** * OperationList @@ -7975,7 +8632,7 @@ export namespace Models { * List of operations. */ operations: DedicatedDatabaseOperation[]; - } + }; /** * Replicas @@ -8013,7 +8670,7 @@ export namespace Models { * Per-pod statuses for the primary and every replica. */ members: DedicatedDatabaseMember[]; - } + }; /** * Invalidation @@ -8035,12 +8692,14 @@ export namespace Models { * Invalidation status. */ status: string; - } + }; /** * Organization */ - export type Organization = { + export type Organization< + Preferences extends Models.Preferences = Models.DefaultPreferences, + > = { /** * Team ID. */ @@ -8181,7 +8840,21 @@ export namespace Models { * Selected projects */ projects: string[]; - } + }; + + /** + * PITRWindows + */ + export type DedicatedDatabasePITRWindows = { + /** + * Earliest available recovery point. + */ + earliest: string; + /** + * Latest available recovery point. + */ + latest: string; + }; /** * backup @@ -8235,7 +8908,7 @@ export namespace Models { * Is this policy enabled. */ enabled: boolean; - } + }; /** * Policy Deny Aliased Email @@ -8249,7 +8922,7 @@ export namespace Models { * Whether the deny aliased email policy is enabled. */ enabled: boolean; - } + }; /** * Policy Deny Disposable Email @@ -8263,7 +8936,7 @@ export namespace Models { * Whether the deny disposable email policy is enabled. */ enabled: boolean; - } + }; /** * Policy Deny Free Email @@ -8277,7 +8950,7 @@ export namespace Models { * Whether the deny free email policy is enabled. */ enabled: boolean; - } + }; /** * Policy Deny Corporate Email @@ -8291,7 +8964,75 @@ export namespace Models { * Whether the deny non-corporate email policy is enabled. */ enabled: boolean; - } + }; + + /** + * PoolerConfig + */ + export type DedicatedDatabasePooler = { + /** + * Whether connection pooling is enabled. + */ + enabled: boolean; + /** + * Connection pool mode. Possible values: transaction (releases connections back to pool after each transaction), session (holds connections for the entire client session). + */ + mode: string; + /** + * Client-connection ceiling the pooler accepts. Enforced on MySQL and MariaDB; on PostgreSQL the pooler has no client cap, so this reports the database's advertised networkMaxConnections and cannot be set here. + */ + maxConnections: number; + /** + * Default pool size per user. + */ + defaultPoolSize: number; + /** + * Pooler listening port. + */ + port: number; + /** + * Whether SELECTs are routed to HA replicas while writes and locked reads stay on the primary. Active only when HA is enabled. + */ + readWriteSplitting: boolean; + /** + * Effective CPU request applied to the pooler sidecar container (Kubernetes quantity). Returns the proportional default (5% of DB CPU, floor 100m) unless overridden. + */ + poolerCpuRequest: string; + /** + * Effective CPU limit applied to the pooler sidecar container (Kubernetes quantity). Returns the proportional default (10% of DB CPU, floor 200m) unless overridden. + */ + poolerCpuLimit: string; + /** + * Effective memory request applied to the pooler sidecar container (Kubernetes quantity). Returns the proportional default (7.5% of DB memory, floor 64Mi) unless overridden. + */ + poolerMemoryRequest: string; + /** + * Effective memory limit applied to the pooler sidecar container (Kubernetes quantity). Returns the proportional default (15% of DB memory, floor 128Mi) unless overridden. + */ + poolerMemoryLimit: string; + }; + + /** + * Postgres extension + */ + export type PostgresExtension = { + /** + * Extension key used with CREATE EXTENSION. + */ + key: string; + /** + * Human-readable extension name. + */ + name: string; + /** + * Short description of what the extension provides. + */ + description: string; + /** + * Category the extension belongs to. + */ + category: string; + }; /** * Program @@ -8333,7 +9074,7 @@ export namespace Models { * Billing plan ID that this is program is associated with. */ billingPlanId: string; - } + }; /** * Restoration @@ -8380,10 +9121,24 @@ export namespace Models { */ resources: string[]; /** - * Optional data in key-value object. + * Optional data in key-value object. */ options: string; - } + }; + + /** + * Dedicated database restorations list + */ + export type DedicatedDatabaseRestorationList = { + /** + * Total number of restorations that matched your query. + */ + total: number; + /** + * List of restorations. + */ + restorations: DedicatedDatabaseRestoration[]; + }; /** * Specification @@ -8425,7 +9180,7 @@ export namespace Models { * Whether the specification is available on the current plan. */ enabled: boolean; - } + }; /** * SpecificationList @@ -8443,7 +9198,7 @@ export namespace Models { * Overage and add-on pricing shared across all specifications. */ pricing: DedicatedDatabaseSpecificationPricing; - } + }; /** * SpecificationPricing @@ -8465,7 +9220,7 @@ export namespace Models { * Point-in-time recovery price as a fraction of the specification cost. */ pitrRate: number; - } + }; /** * Connections @@ -8479,7 +9234,7 @@ export namespace Models { * The engine's own max_connections. On a pooled database this is the backend limit the pooler multiplexes onto, not the ceiling a client pool may reach — that is networkMaxConnections on the database resource. */ max: number; - } + }; /** * Replica @@ -8498,10 +9253,14 @@ export namespace Models { */ healthy: boolean; /** - * Replication lag in seconds (null for primary). + * 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 healthy, or whose probe did not answer, has none yet. `healthy` is a reachability probe of the member itself and says nothing about replication, so a healthy member may still not be replicating. + */ + replicating?: boolean; + /** + * Replication lag in seconds (null for primary). Also null against `replicating: true`, for a member that is streaming but whose engine printed no numeric lag. */ lagSeconds?: number; - } + }; /** * Volume @@ -8523,7 +9282,7 @@ export namespace Models { * Whether the volume is mounted. */ mounted: boolean; - } + }; /** * usageBillingPlan @@ -8573,7 +9332,7 @@ export namespace Models { * Credits additional resources */ credits?: AdditionalResource; - } + }; /** * App @@ -8683,7 +9442,7 @@ export namespace Models { * List of application secrets. */ secrets: AppSecret[]; - } + }; /** * AppSecret @@ -8725,7 +9484,7 @@ export namespace Models { * Time the secret was last used for authentication in ISO 8601 format. Null if never used. */ lastAccessedAt?: string; - } + }; /** * AppSecretPlaintext @@ -8767,7 +9526,7 @@ export namespace Models { * Time the secret was last used for authentication in ISO 8601 format. Null if never used. */ lastAccessedAt?: string; - } + }; /** * AppScope @@ -8793,7 +9552,7 @@ export namespace Models { * Whether the scope is deprecated. Deprecated scopes can still be requested but should not be offered for new grants. */ deprecated: boolean; - } + }; /** * AppInstallation @@ -8826,7 +9585,7 @@ export namespace Models { /** * Authorization details granted to the application. Rich authorization request (RFC 9396) style entries; the Appwrite Console stores authorized project IDs here. */ - authorizationDetails: object; + authorizationDetails: Record[]; /** * ID of the user who created the installation. */ @@ -8839,7 +9598,7 @@ export namespace Models { * Time an access token was last issued for the installation in ISO 8601 format. Null if never used. */ lastAccessedAt?: string; - } + }; /** * AppKey @@ -8881,7 +9640,7 @@ export namespace Models { * Time the app key was last used for authentication in ISO 8601 format. Null if never used. */ lastAccessedAt?: string; - } + }; /** * OAuth2 Authorize @@ -8895,7 +9654,7 @@ export namespace Models { * URL the end user should be redirected to when the flow can complete without consent. Empty when consent is still required. */ redirectUrl: string; - } + }; /** * OAuth2 Approve @@ -8905,7 +9664,7 @@ export namespace Models { * URL the end user should be redirected to after the grant is approved, carrying the authorization `code` and/or `id_token` along with the original `state`. */ redirectUrl: string; - } + }; /** * OAuth2 Reject @@ -8915,7 +9674,7 @@ export namespace Models { * URL the end user should be redirected to after the grant is rejected, carrying an `access_denied` error. */ redirectUrl: string; - } + }; /** * OAuth2 Grant @@ -8969,7 +9728,7 @@ export namespace Models { * Grant expiration time in ISO 8601 format. */ expire: string; - } + }; /** * OAuth2 Device Authorization @@ -8999,7 +9758,7 @@ export namespace Models { * Minimum polling interval for the token endpoint in seconds. */ interval: number; - } + }; /** * OAuth2 PAR @@ -9013,7 +9772,7 @@ export namespace Models { * Lifetime of the authorization request handle in seconds. */ expires_in: number; - } + }; /** * OAuth2 Token @@ -9047,7 +9806,7 @@ export namespace Models { * OpenID Connect ID token. Returned when the `openid` scope is granted. */ id_token?: string; - } + }; /** * OAuth2 Consent @@ -9093,7 +9852,7 @@ export namespace Models { * Consent expiration time in ISO 8601 format. Empty when the consent has no token-bound expiry yet. */ expire: string; - } + }; /** * OAuth2 Consent Token @@ -9143,7 +9902,7 @@ export namespace Models { * Expiration time of the current access token of this family in ISO 8601 format. */ expire: string; - } + }; /** * OAuth2 Project @@ -9161,7 +9920,7 @@ export namespace Models { * API endpoint of the region the project is deployed in. Empty when the region has no public hostname configured. */ endpoint: string; - } + }; /** * OAuth2 Organization @@ -9171,7 +9930,7 @@ export namespace Models { * Organization ID. */ $id: string; - } + }; /** * OAuth2 accessible projects list @@ -9185,7 +9944,7 @@ export namespace Models { * List of projects. */ projects: Oauth2Project[]; - } + }; /** * OAuth2 accessible organizations list @@ -9199,7 +9958,7 @@ export namespace Models { * List of organizations. */ organizations: Oauth2Organization[]; - } + }; /** * OAuth2 consents list @@ -9213,7 +9972,7 @@ export namespace Models { * List of consents. */ consents: Oauth2Consent[]; - } + }; /** * OAuth2 consent tokens list @@ -9227,7 +9986,7 @@ export namespace Models { * List of tokens. */ tokens: Oauth2ConsentToken[]; - } + }; /** * Activity event list @@ -9241,7 +10000,7 @@ export namespace Models { * List of events. */ events: ActivityEvent[]; - } + }; /** * Backup archive list @@ -9255,7 +10014,7 @@ export namespace Models { * List of archives. */ archives: BackupArchive[]; - } + }; /** * Backup policy list @@ -9269,7 +10028,7 @@ export namespace Models { * List of policies. */ policies: BackupPolicy[]; - } + }; /** * Backup restoration list @@ -9283,7 +10042,7 @@ export namespace Models { * List of restorations. */ restorations: BackupRestoration[]; - } + }; /** * Database Migrations List @@ -9297,7 +10056,21 @@ export namespace Models { * List of migrations. */ migrations: DatabaseMigration[]; - } + }; + + /** + * Dedicated databases list + */ + export type DedicatedDatabaseList = { + /** + * Total number of databases that matched your query. + */ + total: number; + /** + * List of databases. + */ + databases: DedicatedDatabase[]; + }; /** * Apps list @@ -9311,7 +10084,7 @@ export namespace Models { * List of apps. */ apps: App[]; - } + }; /** * App secrets list @@ -9325,7 +10098,7 @@ export namespace Models { * List of secrets. */ secrets: AppSecret[]; - } + }; /** * App scopes list @@ -9339,7 +10112,7 @@ export namespace Models { * List of scopes. */ scopes: AppScope[]; - } + }; /** * App installations list @@ -9353,7 +10126,7 @@ export namespace Models { * List of installations. */ installations: AppInstallation[]; - } + }; /** * App keys list @@ -9367,5 +10140,5 @@ export namespace Models { * List of keys. */ keys: AppKey[]; - } + }; } diff --git a/src/operator.ts b/src/operator.ts index 2386a6c4..86b59205 100644 --- a/src/operator.ts +++ b/src/operator.ts @@ -3,306 +3,304 @@ export type OperatorValuesList = string[] | number[] | boolean[] | any[]; export type OperatorValues = OperatorValuesSingle | OperatorValuesList; export enum Condition { - Equal = "equal", - NotEqual = "notEqual", - GreaterThan = "greaterThan", - GreaterThanEqual = "greaterThanEqual", - LessThan = "lessThan", - LessThanEqual = "lessThanEqual", - Contains = "contains", - IsNull = "isNull", - IsNotNull = "isNotNull", + Equal = 'equal', + NotEqual = 'notEqual', + GreaterThan = 'greaterThan', + GreaterThanEqual = 'greaterThanEqual', + LessThan = 'lessThan', + LessThanEqual = 'lessThanEqual', + Contains = 'contains', + IsNull = 'isNull', + IsNotNull = 'isNotNull', } /** * Helper class to generate operator strings for atomic operations. */ export class Operator { - method: string; - values: OperatorValuesList | undefined; + method: string; + values: OperatorValuesList | undefined; - /** - * Constructor for Operator class. - * - * @param {string} method - * @param {OperatorValues} values - */ - constructor( - method: string, - values?: OperatorValues - ) { - this.method = method; + /** + * Constructor for Operator class. + * + * @param {string} method + * @param {OperatorValues} values + */ + constructor(method: string, values?: OperatorValues) { + this.method = method; - if (values !== undefined) { - if (Array.isArray(values)) { - this.values = values; - } else { - this.values = [values] as OperatorValuesList; - } + if (values !== undefined) { + if (Array.isArray(values)) { + this.values = values; + } else { + this.values = [values] as OperatorValuesList; + } + } } - } - /** - * Convert the operator object to a JSON string. - * - * @returns {string} - */ - toString(): string { - return JSON.stringify({ - method: this.method, - values: this.values, - }); - } - - /** - * Increment a numeric attribute by a specified value. - * - * @param {number} value - * @param {number} max - * @returns {string} - */ - static increment = (value: number = 1, max?: number): string => { - if (isNaN(value) || !isFinite(value)) { - throw new Error("Value cannot be NaN or Infinity"); - } - if (max !== undefined && (isNaN(max) || !isFinite(max))) { - throw new Error("Max cannot be NaN or Infinity"); - } - const values: any[] = [value]; - if (max !== undefined) { - values.push(max); + /** + * Convert the operator object to a JSON string. + * + * @returns {string} + */ + toString(): string { + return JSON.stringify({ + method: this.method, + values: this.values, + }); } - return new Operator("increment", values).toString(); - }; - /** - * Decrement a numeric attribute by a specified value. - * - * @param {number} value - * @param {number} min - * @returns {string} - */ - static decrement = (value: number = 1, min?: number): string => { - if (isNaN(value) || !isFinite(value)) { - throw new Error("Value cannot be NaN or Infinity"); - } - if (min !== undefined && (isNaN(min) || !isFinite(min))) { - throw new Error("Min cannot be NaN or Infinity"); - } - const values: any[] = [value]; - if (min !== undefined) { - values.push(min); - } - return new Operator("decrement", values).toString(); - }; + /** + * Increment a numeric attribute by a specified value. + * + * @param {number} value + * @param {number} max + * @returns {string} + */ + static increment = (value: number = 1, max?: number): string => { + if (isNaN(value) || !isFinite(value)) { + throw new Error('Value cannot be NaN or Infinity'); + } + if (max !== undefined && (isNaN(max) || !isFinite(max))) { + throw new Error('Max cannot be NaN or Infinity'); + } + const values: any[] = [value]; + if (max !== undefined) { + values.push(max); + } + return new Operator('increment', values).toString(); + }; - /** - * Multiply a numeric attribute by a specified factor. - * - * @param {number} factor - * @param {number} max - * @returns {string} - */ - static multiply = (factor: number, max?: number): string => { - if (isNaN(factor) || !isFinite(factor)) { - throw new Error("Factor cannot be NaN or Infinity"); - } - if (max !== undefined && (isNaN(max) || !isFinite(max))) { - throw new Error("Max cannot be NaN or Infinity"); - } - const values: any[] = [factor]; - if (max !== undefined) { - values.push(max); - } - return new Operator("multiply", values).toString(); - }; + /** + * Decrement a numeric attribute by a specified value. + * + * @param {number} value + * @param {number} min + * @returns {string} + */ + static decrement = (value: number = 1, min?: number): string => { + if (isNaN(value) || !isFinite(value)) { + throw new Error('Value cannot be NaN or Infinity'); + } + if (min !== undefined && (isNaN(min) || !isFinite(min))) { + throw new Error('Min cannot be NaN or Infinity'); + } + const values: any[] = [value]; + if (min !== undefined) { + values.push(min); + } + return new Operator('decrement', values).toString(); + }; - /** - * Divide a numeric attribute by a specified divisor. - * - * @param {number} divisor - * @param {number} min - * @returns {string} - */ - static divide = (divisor: number, min?: number): string => { - if (isNaN(divisor) || !isFinite(divisor)) { - throw new Error("Divisor cannot be NaN or Infinity"); - } - if (min !== undefined && (isNaN(min) || !isFinite(min))) { - throw new Error("Min cannot be NaN or Infinity"); - } - if (divisor === 0) { - throw new Error("Divisor cannot be zero"); - } - const values: any[] = [divisor]; - if (min !== undefined) { - values.push(min); - } - return new Operator("divide", values).toString(); - }; + /** + * Multiply a numeric attribute by a specified factor. + * + * @param {number} factor + * @param {number} max + * @returns {string} + */ + static multiply = (factor: number, max?: number): string => { + if (isNaN(factor) || !isFinite(factor)) { + throw new Error('Factor cannot be NaN or Infinity'); + } + if (max !== undefined && (isNaN(max) || !isFinite(max))) { + throw new Error('Max cannot be NaN or Infinity'); + } + const values: any[] = [factor]; + if (max !== undefined) { + values.push(max); + } + return new Operator('multiply', values).toString(); + }; - /** - * Apply modulo operation on a numeric attribute. - * - * @param {number} divisor - * @returns {string} - */ - static modulo = (divisor: number): string => { - if (isNaN(divisor) || !isFinite(divisor)) { - throw new Error("Divisor cannot be NaN or Infinity"); - } - if (divisor === 0) { - throw new Error("Divisor cannot be zero"); - } - return new Operator("modulo", [divisor]).toString(); - }; + /** + * Divide a numeric attribute by a specified divisor. + * + * @param {number} divisor + * @param {number} min + * @returns {string} + */ + static divide = (divisor: number, min?: number): string => { + if (isNaN(divisor) || !isFinite(divisor)) { + throw new Error('Divisor cannot be NaN or Infinity'); + } + if (min !== undefined && (isNaN(min) || !isFinite(min))) { + throw new Error('Min cannot be NaN or Infinity'); + } + if (divisor === 0) { + throw new Error('Divisor cannot be zero'); + } + const values: any[] = [divisor]; + if (min !== undefined) { + values.push(min); + } + return new Operator('divide', values).toString(); + }; - /** - * Raise a numeric attribute to a specified power. - * - * @param {number} exponent - * @param {number} max - * @returns {string} - */ - static power = (exponent: number, max?: number): string => { - if (isNaN(exponent) || !isFinite(exponent)) { - throw new Error("Exponent cannot be NaN or Infinity"); - } - if (max !== undefined && (isNaN(max) || !isFinite(max))) { - throw new Error("Max cannot be NaN or Infinity"); - } - const values: any[] = [exponent]; - if (max !== undefined) { - values.push(max); - } - return new Operator("power", values).toString(); - }; + /** + * Apply modulo operation on a numeric attribute. + * + * @param {number} divisor + * @returns {string} + */ + static modulo = (divisor: number): string => { + if (isNaN(divisor) || !isFinite(divisor)) { + throw new Error('Divisor cannot be NaN or Infinity'); + } + if (divisor === 0) { + throw new Error('Divisor cannot be zero'); + } + return new Operator('modulo', [divisor]).toString(); + }; + + /** + * Raise a numeric attribute to a specified power. + * + * @param {number} exponent + * @param {number} max + * @returns {string} + */ + static power = (exponent: number, max?: number): string => { + if (isNaN(exponent) || !isFinite(exponent)) { + throw new Error('Exponent cannot be NaN or Infinity'); + } + if (max !== undefined && (isNaN(max) || !isFinite(max))) { + throw new Error('Max cannot be NaN or Infinity'); + } + const values: any[] = [exponent]; + if (max !== undefined) { + values.push(max); + } + return new Operator('power', values).toString(); + }; - /** - * Append values to an array attribute. - * - * @param {any[]} values - * @returns {string} - */ - static arrayAppend = (values: any[]): string => - new Operator("arrayAppend", values).toString(); + /** + * Append values to an array attribute. + * + * @param {any[]} values + * @returns {string} + */ + static arrayAppend = (values: any[]): string => + new Operator('arrayAppend', values).toString(); - /** - * Prepend values to an array attribute. - * - * @param {any[]} values - * @returns {string} - */ - static arrayPrepend = (values: any[]): string => - new Operator("arrayPrepend", values).toString(); + /** + * Prepend values to an array attribute. + * + * @param {any[]} values + * @returns {string} + */ + static arrayPrepend = (values: any[]): string => + new Operator('arrayPrepend', values).toString(); - /** - * Insert a value at a specific index in an array attribute. - * - * @param {number} index - * @param {any} value - * @returns {string} - */ - static arrayInsert = (index: number, value: any): string => - new Operator("arrayInsert", [index, value]).toString(); + /** + * Insert a value at a specific index in an array attribute. + * + * @param {number} index + * @param {any} value + * @returns {string} + */ + static arrayInsert = (index: number, value: any): string => + new Operator('arrayInsert', [index, value]).toString(); - /** - * Remove a value from an array attribute. - * - * @param {any} value - * @returns {string} - */ - static arrayRemove = (value: any): string => - new Operator("arrayRemove", [value]).toString(); + /** + * Remove a value from an array attribute. + * + * @param {any} value + * @returns {string} + */ + static arrayRemove = (value: any): string => + new Operator('arrayRemove', [value]).toString(); - /** - * Remove duplicate values from an array attribute. - * - * @returns {string} - */ - static arrayUnique = (): string => - new Operator("arrayUnique", []).toString(); + /** + * Remove duplicate values from an array attribute. + * + * @returns {string} + */ + static arrayUnique = (): string => + new Operator('arrayUnique', []).toString(); - /** - * Keep only values that exist in both the current array and the provided array. - * - * @param {any[]} values - * @returns {string} - */ - static arrayIntersect = (values: any[]): string => - new Operator("arrayIntersect", values).toString(); + /** + * Keep only values that exist in both the current array and the provided array. + * + * @param {any[]} values + * @returns {string} + */ + static arrayIntersect = (values: any[]): string => + new Operator('arrayIntersect', values).toString(); - /** - * Remove values from the array that exist in the provided array. - * - * @param {any[]} values - * @returns {string} - */ - static arrayDiff = (values: any[]): string => - new Operator("arrayDiff", values).toString(); + /** + * Remove values from the array that exist in the provided array. + * + * @param {any[]} values + * @returns {string} + */ + static arrayDiff = (values: any[]): string => + new Operator('arrayDiff', values).toString(); - /** - * Filter array values based on a condition. - * - * @param {Condition} condition - * @param {any} value - * @returns {string} - */ - static arrayFilter = (condition: Condition, value?: any): string => { - const values: any[] = [condition as string, value === undefined ? null : value]; - return new Operator("arrayFilter", values).toString(); - }; + /** + * Filter array values based on a condition. + * + * @param {Condition} condition + * @param {any} value + * @returns {string} + */ + static arrayFilter = (condition: Condition, value?: any): string => { + const values: any[] = [ + condition as string, + value === undefined ? null : value, + ]; + return new Operator('arrayFilter', values).toString(); + }; - /** - * Concatenate a value to a string or array attribute. - * - * @param {any} value - * @returns {string} - */ - static stringConcat = (value: any): string => - new Operator("stringConcat", [value]).toString(); + /** + * Concatenate a value to a string or array attribute. + * + * @param {any} value + * @returns {string} + */ + static stringConcat = (value: any): string => + new Operator('stringConcat', [value]).toString(); - /** - * Replace occurrences of a search string with a replacement string. - * - * @param {string} search - * @param {string} replace - * @returns {string} - */ - static stringReplace = (search: string, replace: string): string => - new Operator("stringReplace", [search, replace]).toString(); + /** + * Replace occurrences of a search string with a replacement string. + * + * @param {string} search + * @param {string} replace + * @returns {string} + */ + static stringReplace = (search: string, replace: string): string => + new Operator('stringReplace', [search, replace]).toString(); - /** - * Toggle a boolean attribute. - * - * @returns {string} - */ - static toggle = (): string => - new Operator("toggle", []).toString(); + /** + * Toggle a boolean attribute. + * + * @returns {string} + */ + static toggle = (): string => new Operator('toggle', []).toString(); - /** - * Add days to a date attribute. - * - * @param {number} days - * @returns {string} - */ - static dateAddDays = (days: number): string => - new Operator("dateAddDays", [days]).toString(); + /** + * Add days to a date attribute. + * + * @param {number} days + * @returns {string} + */ + static dateAddDays = (days: number): string => + new Operator('dateAddDays', [days]).toString(); - /** - * Subtract days from a date attribute. - * - * @param {number} days - * @returns {string} - */ - static dateSubDays = (days: number): string => - new Operator("dateSubDays", [days]).toString(); + /** + * Subtract days from a date attribute. + * + * @param {number} days + * @returns {string} + */ + static dateSubDays = (days: number): string => + new Operator('dateSubDays', [days]).toString(); - /** - * Set a date attribute to the current date and time. - * - * @returns {string} - */ - static dateSetNow = (): string => - new Operator("dateSetNow", []).toString(); + /** + * Set a date attribute to the current date and time. + * + * @returns {string} + */ + static dateSetNow = (): string => new Operator('dateSetNow', []).toString(); } diff --git a/src/permission.ts b/src/permission.ts index 94d9cedd..758211bf 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -10,7 +10,7 @@ export class Permission { */ static read = (role: string): string => { return `read("${role}")`; - } + }; /** * Generate write permission string for the provided role. @@ -23,7 +23,7 @@ export class Permission { */ static write = (role: string): string => { return `write("${role}")`; - } + }; /** * Generate create permission string for the provided role. @@ -33,7 +33,7 @@ export class Permission { */ static create = (role: string): string => { return `create("${role}")`; - } + }; /** * Generate update permission string for the provided role. @@ -43,7 +43,7 @@ export class Permission { */ static update = (role: string): string => { return `update("${role}")`; - } + }; /** * Generate delete permission string for the provided role. @@ -53,5 +53,5 @@ export class Permission { */ static delete = (role: string): string => { return `delete("${role}")`; - } + }; } diff --git a/src/query.ts b/src/query.ts index e0e97257..7a7da885 100644 --- a/src/query.ts +++ b/src/query.ts @@ -2,7 +2,8 @@ import JSONbigModule from 'json-bigint'; const JSONbig = JSONbigModule({ useNativeBigInt: true }); type QueryTypesSingle = string | number | bigint | boolean; -export type QueryTypesList = string[] | number[] | bigint[] | boolean[] | Query[] | any[]; +export type QueryTypesList = + string[] | number[] | bigint[] | boolean[] | Query[] | any[]; export type QueryTypes = QueryTypesSingle | QueryTypesList; type AttributesTypes = string | string[]; @@ -10,597 +11,652 @@ type AttributesTypes = string | string[]; * Helper class to generate query strings. */ export class Query { - method: string; - attribute: AttributesTypes | undefined; - values: QueryTypesList | undefined; - - /** - * Constructor for Query class. - * - * @param {string} method - * @param {AttributesTypes} attribute - * @param {QueryTypes} values - */ - constructor( - method: string, - attribute?: AttributesTypes, - values?: QueryTypes - ) { - this.method = method; - this.attribute = attribute; - - if (values !== undefined) { - if (Array.isArray(values)) { - this.values = values; - } else { - this.values = [values] as QueryTypesList; - } + method: string; + attribute: AttributesTypes | undefined; + values: QueryTypesList | undefined; + + /** + * Constructor for Query class. + * + * @param {string} method + * @param {AttributesTypes} attribute + * @param {QueryTypes} values + */ + constructor( + method: string, + attribute?: AttributesTypes, + values?: QueryTypes, + ) { + this.method = method; + this.attribute = attribute; + + if (values !== undefined) { + if (Array.isArray(values)) { + this.values = values; + } else { + this.values = [values] as QueryTypesList; + } + } } - } - - /** - * Convert the query object to a JSON string. - * - * @returns {string} - */ - toString(): string { - return JSONbig.stringify({ - method: this.method, - attribute: this.attribute, - values: this.values, - }); - } - - /** - * Filter resources where attribute is equal to value. - * - * @param {string} attribute - * @param {QueryTypes} value - * @returns {string} - */ - static equal = (attribute: string, value: QueryTypes): string => - new Query("equal", attribute, value).toString(); - - /** - * Filter resources where attribute is not equal to value. - * - * @param {string} attribute - * @param {QueryTypes} value - * @returns {string} - */ - static notEqual = (attribute: string, value: QueryTypes): string => - new Query("notEqual", attribute, value).toString(); - - /** - * Filter resources where attribute matches a regular expression pattern. - * - * @param {string} attribute The attribute to filter on. - * @param {string} pattern The regular expression pattern to match. - * @returns {string} - */ - static regex = (attribute: string, pattern: string): string => - new Query("regex", attribute, pattern).toString(); - - /** - * Filter resources where attribute is less than value. - * - * @param {string} attribute - * @param {QueryTypes} value - * @returns {string} - */ - static lessThan = (attribute: string, value: QueryTypes): string => - new Query("lessThan", attribute, value).toString(); - - /** - * Filter resources where attribute is less than or equal to value. - * - * @param {string} attribute - * @param {QueryTypes} value - * @returns {string} - */ - static lessThanEqual = (attribute: string, value: QueryTypes): string => - new Query("lessThanEqual", attribute, value).toString(); - - /** - * Filter resources where attribute is greater than value. - * - * @param {string} attribute - * @param {QueryTypes} value - * @returns {string} - */ - static greaterThan = (attribute: string, value: QueryTypes): string => - new Query("greaterThan", attribute, value).toString(); - - /** - * Filter resources where attribute is greater than or equal to value. - * - * @param {string} attribute - * @param {QueryTypes} value - * @returns {string} - */ - static greaterThanEqual = (attribute: string, value: QueryTypes): string => - new Query("greaterThanEqual", attribute, value).toString(); - - /** - * Filter resources where attribute is null. - * - * @param {string} attribute - * @returns {string} - */ - static isNull = (attribute: string): string => - new Query("isNull", attribute).toString(); - - /** - * Filter resources where attribute is not null. - * - * @param {string} attribute - * @returns {string} - */ - static isNotNull = (attribute: string): string => - new Query("isNotNull", attribute).toString(); - - /** - * Filter resources where the specified attributes exist. - * - * @param {string[]} attributes The list of attributes that must exist. - * @returns {string} - */ - static exists = (attributes: string[]): string => - new Query("exists", undefined, attributes).toString(); - - /** - * Filter resources where the specified attributes do not exist. - * - * @param {string[]} attributes The list of attributes that must not exist. - * @returns {string} - */ - static notExists = (attributes: string[]): string => - new Query("notExists", undefined, attributes).toString(); - - /** - * Filter resources where attribute is between start and end (inclusive). - * - * @param {string} attribute - * @param {string | number | bigint} start - * @param {string | number | bigint} end - * @returns {string} - */ - static between = (attribute: string, start: string | number | bigint, end: string | number | bigint): string => - new Query("between", attribute, [start, end] as QueryTypesList).toString(); - - /** - * Filter resources where attribute starts with value. - * - * @param {string} attribute - * @param {string} value - * @returns {string} - */ - static startsWith = (attribute: string, value: string): string => - new Query("startsWith", attribute, value).toString(); - - /** - * Filter resources where attribute ends with value. - * - * @param {string} attribute - * @param {string} value - * @returns {string} - */ - static endsWith = (attribute: string, value: string): string => - new Query("endsWith", attribute, value).toString(); - - /** - * Specify which attributes should be returned by the API call. - * - * @param {string[]} attributes - * @returns {string} - */ - static select = (attributes: string[]): string => - new Query("select", undefined, attributes).toString(); - - /** - * Filter resources by searching attribute for value. - * A fulltext index on attribute is required for this query to work. - * - * @param {string} attribute - * @param {string} value - * @returns {string} - */ - static search = (attribute: string, value: string): string => - new Query("search", attribute, value).toString(); - - /** - * Sort results by attribute descending. - * - * @param {string} attribute - * @returns {string} - */ - static orderDesc = (attribute: string): string => - new Query("orderDesc", attribute).toString(); - - /** - * Sort results by attribute ascending. - * - * @param {string} attribute - * @returns {string} - */ - static orderAsc = (attribute: string): string => - new Query("orderAsc", attribute).toString(); - - /** - * Sort results randomly. - * - * @returns {string} - */ - static orderRandom = (): string => - new Query("orderRandom").toString(); - - /** - * Return results after documentId. - * - * @param {string} documentId - * @returns {string} - */ - static cursorAfter = (documentId: string): string => - new Query("cursorAfter", undefined, documentId).toString(); - - /** - * Return results before documentId. - * - * @param {string} documentId - * @returns {string} - */ - static cursorBefore = (documentId: string): string => - new Query("cursorBefore", undefined, documentId).toString(); - - /** - * Return only limit results. - * - * @param {number} limit - * @returns {string} - */ - static limit = (limit: number): string => - new Query("limit", undefined, limit).toString(); - - /** - * Filter resources by skipping the first offset results. - * - * @param {number} offset - * @returns {string} - */ - static offset = (offset: number): string => - new Query("offset", undefined, offset).toString(); - - /** - * Filter resources where attribute contains the specified value. - * For string attributes, checks if the string contains the substring. - * - * Note: For array attributes, use {@link containsAny} or {@link containsAll} instead. - * @param {string} attribute - * @param {string | string[]} value - * @returns {string} - */ - static contains = (attribute: string, value: string | any[]): string => - new Query("contains", attribute, value).toString(); - - /** - * Filter resources where attribute contains ANY of the specified values. - * For array and relationship attributes, matches documents where the attribute - * contains at least one of the given values. - * - * @param {string} attribute - * @param {any[]} value - * @returns {string} - */ - static containsAny = (attribute: string, value: any[]): string => - new Query("containsAny", attribute, value).toString(); - - /** - * Filter resources where attribute contains ALL of the specified values. - * For array and relationship attributes, matches documents where the attribute - * contains every one of the given values. - * - * @param {string} attribute - * @param {any[]} value - * @returns {string} - */ - static containsAll = (attribute: string, value: any[]): string => - new Query("containsAll", attribute, value).toString(); - - /** - * Filter resources where attribute does not contain the specified value. - * - * @param {string} attribute - * @param {string | any[]} value - * @returns {string} - */ - static notContains = (attribute: string, value: string | any[]): string => - new Query("notContains", attribute, value).toString(); - - /** - * Filter resources by searching attribute for value (inverse of search). - * A fulltext index on attribute is required for this query to work. - * - * @param {string} attribute - * @param {string} value - * @returns {string} - */ - static notSearch = (attribute: string, value: string): string => - new Query("notSearch", attribute, value).toString(); - - /** - * Filter resources where attribute is not between start and end (exclusive). - * - * @param {string} attribute - * @param {string | number | bigint} start - * @param {string | number | bigint} end - * @returns {string} - */ - static notBetween = (attribute: string, start: string | number | bigint, end: string | number | bigint): string => - new Query("notBetween", attribute, [start, end] as QueryTypesList).toString(); - - /** - * Filter resources where attribute does not start with value. - * - * @param {string} attribute - * @param {string} value - * @returns {string} - */ - static notStartsWith = (attribute: string, value: string): string => - new Query("notStartsWith", attribute, value).toString(); - - /** - * Filter resources where attribute does not end with value. - * - * @param {string} attribute - * @param {string} value - * @returns {string} - */ - static notEndsWith = (attribute: string, value: string): string => - new Query("notEndsWith", attribute, value).toString(); - - /** - * Filter resources where document was created before date. - * - * @param {string} value - * @returns {string} - */ - static createdBefore = (value: string): string => - Query.lessThan("$createdAt", value); - - /** - * Filter resources where document was created after date. - * - * @param {string} value - * @returns {string} - */ - static createdAfter = (value: string): string => - Query.greaterThan("$createdAt", value); - - /** - * Filter resources where document was created between dates. - * - * @param {string} start - * @param {string} end - * @returns {string} - */ - static createdBetween = (start: string, end: string): string => - Query.between("$createdAt", start, end); - - /** - * Filter resources where document was updated before date. - * - * @param {string} value - * @returns {string} - */ - static updatedBefore = (value: string): string => - Query.lessThan("$updatedAt", value); - - /** - * Filter resources where document was updated after date. - * - * @param {string} value - * @returns {string} - */ - static updatedAfter = (value: string): string => - Query.greaterThan("$updatedAt", value); - - /** - * Filter resources where document was updated between dates. - * - * @param {string} start - * @param {string} end - * @returns {string} - */ - static updatedBetween = (start: string, end: string): string => - Query.between("$updatedAt", start, end); - - /** - * Combine multiple queries using logical OR operator. - * - * @param {string[]} queries - * @returns {string} - */ - static or = (queries: string[]) => - new Query("or", undefined, queries.map((query) => JSONbig.parse(query))).toString(); - - /** - * Combine multiple queries using logical AND operator. - * - * @param {string[]} queries - * @returns {string} - */ - static and = (queries: string[]) => - new Query("and", undefined, queries.map((query) => JSONbig.parse(query))).toString(); - - /** - * Filter array elements where at least one element matches all the specified queries. - * - * @param {string} attribute The attribute containing the array to filter on. - * @param {string[]} queries The list of query strings to match against array elements. - * @returns {string} - */ - static elemMatch = (attribute: string, queries: string[]): string => - new Query( - "elemMatch", - attribute, - queries.map((query) => JSONbig.parse(query)) - ).toString(); - - /** - * Filter resources where attribute is at a specific distance from the given coordinates. - * - * @param {string} attribute - * @param {any[]} values - * @param {number} distance - * @param {boolean} meters - * @returns {string} - */ - static distanceEqual = (attribute: string, values: any[], distance: number, meters: boolean = true): string => - new Query("distanceEqual", attribute, [[values, distance, meters]] as QueryTypesList).toString(); - - /** - * Filter resources where attribute is not at a specific distance from the given coordinates. - * - * @param {string} attribute - * @param {any[]} values - * @param {number} distance - * @param {boolean} meters - * @returns {string} - */ - static distanceNotEqual = (attribute: string, values: any[], distance: number, meters: boolean = true): string => - new Query("distanceNotEqual", attribute, [[values, distance, meters]] as QueryTypesList).toString(); - - /** - * Filter resources where attribute is at a distance greater than the specified value from the given coordinates. - * - * @param {string} attribute - * @param {any[]} values - * @param {number} distance - * @param {boolean} meters - * @returns {string} - */ - static distanceGreaterThan = (attribute: string, values: any[], distance: number, meters: boolean = true): string => - new Query("distanceGreaterThan", attribute, [[values, distance, meters]] as QueryTypesList).toString(); - - /** - * Filter resources where attribute is at a distance less than the specified value from the given coordinates. - * - * @param {string} attribute - * @param {any[]} values - * @param {number} distance - * @param {boolean} meters - * @returns {string} - */ - static distanceLessThan = (attribute: string, values: any[], distance: number, meters: boolean = true): string => - new Query("distanceLessThan", attribute, [[values, distance, meters]] as QueryTypesList).toString(); - - /** - * Filter resources using vector dot product similarity. - * - * @param {string} attribute - * @param {number[]} vector - * @returns {string} - */ - static vectorDot = (attribute: string, vector: number[]): string => - new Query("vectorDot", attribute, [vector] as QueryTypesList).toString(); - - /** - * Filter resources using vector cosine similarity. - * - * @param {string} attribute - * @param {number[]} vector - * @returns {string} - */ - static vectorCosine = (attribute: string, vector: number[]): string => - new Query("vectorCosine", attribute, [vector] as QueryTypesList).toString(); - - /** - * Filter resources using vector Euclidean distance. - * - * @param {string} attribute - * @param {number[]} vector - * @returns {string} - */ - static vectorEuclidean = (attribute: string, vector: number[]): string => - new Query("vectorEuclidean", attribute, [vector] as QueryTypesList).toString(); - - /** - * Filter resources where attribute intersects with the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static intersects = (attribute: string, values: any[]): string => - new Query("intersects", attribute, [values]).toString(); - - /** - * Filter resources where attribute does not intersect with the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static notIntersects = (attribute: string, values: any[]): string => - new Query("notIntersects", attribute, [values]).toString(); - - /** - * Filter resources where attribute crosses the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static crosses = (attribute: string, values: any[]): string => - new Query("crosses", attribute, [values]).toString(); - - /** - * Filter resources where attribute does not cross the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static notCrosses = (attribute: string, values: any[]): string => - new Query("notCrosses", attribute, [values]).toString(); - - /** - * Filter resources where attribute overlaps with the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static overlaps = (attribute: string, values: any[]): string => - new Query("overlaps", attribute, [values]).toString(); - - /** - * Filter resources where attribute does not overlap with the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static notOverlaps = (attribute: string, values: any[]): string => - new Query("notOverlaps", attribute, [values]).toString(); - - /** - * Filter resources where attribute touches the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static touches = (attribute: string, values: any[]): string => - new Query("touches", attribute, [values]).toString(); - - /** - * Filter resources where attribute does not touch the given geometry. - * - * @param {string} attribute - * @param {any[]} values - * @returns {string} - */ - static notTouches = (attribute: string, values: any[]): string => - new Query("notTouches", attribute, [values]).toString(); + + /** + * Convert the query object to a JSON string. + * + * @returns {string} + */ + toString(): string { + return JSONbig.stringify({ + method: this.method, + attribute: this.attribute, + values: this.values, + }); + } + + /** + * Filter resources where attribute is equal to value. + * + * @param {string} attribute + * @param {QueryTypes} value + * @returns {string} + */ + static equal = (attribute: string, value: QueryTypes): string => + new Query('equal', attribute, value).toString(); + + /** + * Filter resources where attribute is not equal to value. + * + * @param {string} attribute + * @param {QueryTypes} value + * @returns {string} + */ + static notEqual = (attribute: string, value: QueryTypes): string => + new Query('notEqual', attribute, value).toString(); + + /** + * Filter resources where attribute matches a regular expression pattern. + * + * @param {string} attribute The attribute to filter on. + * @param {string} pattern The regular expression pattern to match. + * @returns {string} + */ + static regex = (attribute: string, pattern: string): string => + new Query('regex', attribute, pattern).toString(); + + /** + * Filter resources where attribute is less than value. + * + * @param {string} attribute + * @param {QueryTypes} value + * @returns {string} + */ + static lessThan = (attribute: string, value: QueryTypes): string => + new Query('lessThan', attribute, value).toString(); + + /** + * Filter resources where attribute is less than or equal to value. + * + * @param {string} attribute + * @param {QueryTypes} value + * @returns {string} + */ + static lessThanEqual = (attribute: string, value: QueryTypes): string => + new Query('lessThanEqual', attribute, value).toString(); + + /** + * Filter resources where attribute is greater than value. + * + * @param {string} attribute + * @param {QueryTypes} value + * @returns {string} + */ + static greaterThan = (attribute: string, value: QueryTypes): string => + new Query('greaterThan', attribute, value).toString(); + + /** + * Filter resources where attribute is greater than or equal to value. + * + * @param {string} attribute + * @param {QueryTypes} value + * @returns {string} + */ + static greaterThanEqual = (attribute: string, value: QueryTypes): string => + new Query('greaterThanEqual', attribute, value).toString(); + + /** + * Filter resources where attribute is null. + * + * @param {string} attribute + * @returns {string} + */ + static isNull = (attribute: string): string => + new Query('isNull', attribute).toString(); + + /** + * Filter resources where attribute is not null. + * + * @param {string} attribute + * @returns {string} + */ + static isNotNull = (attribute: string): string => + new Query('isNotNull', attribute).toString(); + + /** + * Filter resources where the specified attributes exist. + * + * @param {string[]} attributes The list of attributes that must exist. + * @returns {string} + */ + static exists = (attributes: string[]): string => + new Query('exists', undefined, attributes).toString(); + + /** + * Filter resources where the specified attributes do not exist. + * + * @param {string[]} attributes The list of attributes that must not exist. + * @returns {string} + */ + static notExists = (attributes: string[]): string => + new Query('notExists', undefined, attributes).toString(); + + /** + * Filter resources where attribute is between start and end (inclusive). + * + * @param {string} attribute + * @param {string | number | bigint} start + * @param {string | number | bigint} end + * @returns {string} + */ + static between = ( + attribute: string, + start: string | number | bigint, + end: string | number | bigint, + ): string => + new Query('between', attribute, [ + start, + end, + ] as QueryTypesList).toString(); + + /** + * Filter resources where attribute starts with value. + * + * @param {string} attribute + * @param {string} value + * @returns {string} + */ + static startsWith = (attribute: string, value: string): string => + new Query('startsWith', attribute, value).toString(); + + /** + * Filter resources where attribute ends with value. + * + * @param {string} attribute + * @param {string} value + * @returns {string} + */ + static endsWith = (attribute: string, value: string): string => + new Query('endsWith', attribute, value).toString(); + + /** + * Specify which attributes should be returned by the API call. + * + * @param {string[]} attributes + * @returns {string} + */ + static select = (attributes: string[]): string => + new Query('select', undefined, attributes).toString(); + + /** + * Filter resources by searching attribute for value. + * A fulltext index on attribute is required for this query to work. + * + * @param {string} attribute + * @param {string} value + * @returns {string} + */ + static search = (attribute: string, value: string): string => + new Query('search', attribute, value).toString(); + + /** + * Sort results by attribute descending. + * + * @param {string} attribute + * @returns {string} + */ + static orderDesc = (attribute: string): string => + new Query('orderDesc', attribute).toString(); + + /** + * Sort results by attribute ascending. + * + * @param {string} attribute + * @returns {string} + */ + static orderAsc = (attribute: string): string => + new Query('orderAsc', attribute).toString(); + + /** + * Sort results randomly. + * + * @returns {string} + */ + static orderRandom = (): string => new Query('orderRandom').toString(); + + /** + * Return results after documentId. + * + * @param {string} documentId + * @returns {string} + */ + static cursorAfter = (documentId: string): string => + new Query('cursorAfter', undefined, documentId).toString(); + + /** + * Return results before documentId. + * + * @param {string} documentId + * @returns {string} + */ + static cursorBefore = (documentId: string): string => + new Query('cursorBefore', undefined, documentId).toString(); + + /** + * Return only limit results. + * + * @param {number} limit + * @returns {string} + */ + static limit = (limit: number): string => + new Query('limit', undefined, limit).toString(); + + /** + * Filter resources by skipping the first offset results. + * + * @param {number} offset + * @returns {string} + */ + static offset = (offset: number): string => + new Query('offset', undefined, offset).toString(); + + /** + * Filter resources where attribute contains the specified value. + * For string attributes, checks if the string contains the substring. + * + * Note: For array attributes, use {@link containsAny} or {@link containsAll} instead. + * @param {string} attribute + * @param {string | string[]} value + * @returns {string} + */ + static contains = (attribute: string, value: string | any[]): string => + new Query('contains', attribute, value).toString(); + + /** + * Filter resources where attribute contains ANY of the specified values. + * For array and relationship attributes, matches documents where the attribute + * contains at least one of the given values. + * + * @param {string} attribute + * @param {any[]} value + * @returns {string} + */ + static containsAny = (attribute: string, value: any[]): string => + new Query('containsAny', attribute, value).toString(); + + /** + * Filter resources where attribute contains ALL of the specified values. + * For array and relationship attributes, matches documents where the attribute + * contains every one of the given values. + * + * @param {string} attribute + * @param {any[]} value + * @returns {string} + */ + static containsAll = (attribute: string, value: any[]): string => + new Query('containsAll', attribute, value).toString(); + + /** + * Filter resources where attribute does not contain the specified value. + * + * @param {string} attribute + * @param {string | any[]} value + * @returns {string} + */ + static notContains = (attribute: string, value: string | any[]): string => + new Query('notContains', attribute, value).toString(); + + /** + * Filter resources by searching attribute for value (inverse of search). + * A fulltext index on attribute is required for this query to work. + * + * @param {string} attribute + * @param {string} value + * @returns {string} + */ + static notSearch = (attribute: string, value: string): string => + new Query('notSearch', attribute, value).toString(); + + /** + * Filter resources where attribute is not between start and end (exclusive). + * + * @param {string} attribute + * @param {string | number | bigint} start + * @param {string | number | bigint} end + * @returns {string} + */ + static notBetween = ( + attribute: string, + start: string | number | bigint, + end: string | number | bigint, + ): string => + new Query('notBetween', attribute, [ + start, + end, + ] as QueryTypesList).toString(); + + /** + * Filter resources where attribute does not start with value. + * + * @param {string} attribute + * @param {string} value + * @returns {string} + */ + static notStartsWith = (attribute: string, value: string): string => + new Query('notStartsWith', attribute, value).toString(); + + /** + * Filter resources where attribute does not end with value. + * + * @param {string} attribute + * @param {string} value + * @returns {string} + */ + static notEndsWith = (attribute: string, value: string): string => + new Query('notEndsWith', attribute, value).toString(); + + /** + * Filter resources where document was created before date. + * + * @param {string} value + * @returns {string} + */ + static createdBefore = (value: string): string => + Query.lessThan('$createdAt', value); + + /** + * Filter resources where document was created after date. + * + * @param {string} value + * @returns {string} + */ + static createdAfter = (value: string): string => + Query.greaterThan('$createdAt', value); + + /** + * Filter resources where document was created between dates. + * + * @param {string} start + * @param {string} end + * @returns {string} + */ + static createdBetween = (start: string, end: string): string => + Query.between('$createdAt', start, end); + + /** + * Filter resources where document was updated before date. + * + * @param {string} value + * @returns {string} + */ + static updatedBefore = (value: string): string => + Query.lessThan('$updatedAt', value); + + /** + * Filter resources where document was updated after date. + * + * @param {string} value + * @returns {string} + */ + static updatedAfter = (value: string): string => + Query.greaterThan('$updatedAt', value); + + /** + * Filter resources where document was updated between dates. + * + * @param {string} start + * @param {string} end + * @returns {string} + */ + static updatedBetween = (start: string, end: string): string => + Query.between('$updatedAt', start, end); + + /** + * Combine multiple queries using logical OR operator. + * + * @param {string[]} queries + * @returns {string} + */ + static or = (queries: string[]) => + new Query( + 'or', + undefined, + queries.map((query) => JSONbig.parse(query)), + ).toString(); + + /** + * Combine multiple queries using logical AND operator. + * + * @param {string[]} queries + * @returns {string} + */ + static and = (queries: string[]) => + new Query( + 'and', + undefined, + queries.map((query) => JSONbig.parse(query)), + ).toString(); + + /** + * Filter array elements where at least one element matches all the specified queries. + * + * @param {string} attribute The attribute containing the array to filter on. + * @param {string[]} queries The list of query strings to match against array elements. + * @returns {string} + */ + static elemMatch = (attribute: string, queries: string[]): string => + new Query( + 'elemMatch', + attribute, + queries.map((query) => JSONbig.parse(query)), + ).toString(); + + /** + * Filter resources where attribute is at a specific distance from the given coordinates. + * + * @param {string} attribute + * @param {any[]} values + * @param {number} distance + * @param {boolean} meters + * @returns {string} + */ + static distanceEqual = ( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): string => + new Query('distanceEqual', attribute, [ + [values, distance, meters], + ] as QueryTypesList).toString(); + + /** + * Filter resources where attribute is not at a specific distance from the given coordinates. + * + * @param {string} attribute + * @param {any[]} values + * @param {number} distance + * @param {boolean} meters + * @returns {string} + */ + static distanceNotEqual = ( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): string => + new Query('distanceNotEqual', attribute, [ + [values, distance, meters], + ] as QueryTypesList).toString(); + + /** + * Filter resources where attribute is at a distance greater than the specified value from the given coordinates. + * + * @param {string} attribute + * @param {any[]} values + * @param {number} distance + * @param {boolean} meters + * @returns {string} + */ + static distanceGreaterThan = ( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): string => + new Query('distanceGreaterThan', attribute, [ + [values, distance, meters], + ] as QueryTypesList).toString(); + + /** + * Filter resources where attribute is at a distance less than the specified value from the given coordinates. + * + * @param {string} attribute + * @param {any[]} values + * @param {number} distance + * @param {boolean} meters + * @returns {string} + */ + static distanceLessThan = ( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): string => + new Query('distanceLessThan', attribute, [ + [values, distance, meters], + ] as QueryTypesList).toString(); + + /** + * Filter resources using vector dot product similarity. + * + * @param {string} attribute + * @param {number[]} vector + * @returns {string} + */ + static vectorDot = (attribute: string, vector: number[]): string => + new Query('vectorDot', attribute, [ + vector, + ] as QueryTypesList).toString(); + + /** + * Filter resources using vector cosine similarity. + * + * @param {string} attribute + * @param {number[]} vector + * @returns {string} + */ + static vectorCosine = (attribute: string, vector: number[]): string => + new Query('vectorCosine', attribute, [ + vector, + ] as QueryTypesList).toString(); + + /** + * Filter resources using vector Euclidean distance. + * + * @param {string} attribute + * @param {number[]} vector + * @returns {string} + */ + static vectorEuclidean = (attribute: string, vector: number[]): string => + new Query('vectorEuclidean', attribute, [ + vector, + ] as QueryTypesList).toString(); + + /** + * Filter resources where attribute intersects with the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static intersects = (attribute: string, values: any[]): string => + new Query('intersects', attribute, [values]).toString(); + + /** + * Filter resources where attribute does not intersect with the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static notIntersects = (attribute: string, values: any[]): string => + new Query('notIntersects', attribute, [values]).toString(); + + /** + * Filter resources where attribute crosses the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static crosses = (attribute: string, values: any[]): string => + new Query('crosses', attribute, [values]).toString(); + + /** + * Filter resources where attribute does not cross the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static notCrosses = (attribute: string, values: any[]): string => + new Query('notCrosses', attribute, [values]).toString(); + + /** + * Filter resources where attribute overlaps with the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static overlaps = (attribute: string, values: any[]): string => + new Query('overlaps', attribute, [values]).toString(); + + /** + * Filter resources where attribute does not overlap with the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static notOverlaps = (attribute: string, values: any[]): string => + new Query('notOverlaps', attribute, [values]).toString(); + + /** + * Filter resources where attribute touches the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static touches = (attribute: string, values: any[]): string => + new Query('touches', attribute, [values]).toString(); + + /** + * Filter resources where attribute does not touch the given geometry. + * + * @param {string} attribute + * @param {any[]} values + * @returns {string} + */ + static notTouches = (attribute: string, values: any[]): string => + new Query('notTouches', attribute, [values]).toString(); } diff --git a/src/role.ts b/src/role.ts index 79f8c6b6..51a05aaf 100644 --- a/src/role.ts +++ b/src/role.ts @@ -2,99 +2,98 @@ * Helper class to generate role strings for `Permission`. */ export class Role { - /** * Grants access to anyone. - * + * * This includes authenticated and unauthenticated users. - * + * * @returns {string} */ public static any(): string { - return 'any' + return 'any'; } /** * Grants access to a specific user by user ID. - * + * * You can optionally pass verified or unverified for * `status` to target specific types of users. * - * @param {string} id - * @param {string} status + * @param {string} id + * @param {string} status * @returns {string} */ public static user(id: string, status: string = ''): string { if (status === '') { - return `user:${id}` + return `user:${id}`; } - return `user:${id}/${status}` + return `user:${id}/${status}`; } /** * Grants access to any authenticated or anonymous user. - * + * * You can optionally pass verified or unverified for * `status` to target specific types of users. - * - * @param {string} status + * + * @param {string} status * @returns {string} */ public static users(status: string = ''): string { if (status === '') { - return 'users' + return 'users'; } - return `users/${status}` + return `users/${status}`; } /** * Grants access to any guest user without a session. - * + * * Authenticated users don't have access to this role. - * + * * @returns {string} */ public static guests(): string { - return 'guests' + return 'guests'; } /** * Grants access to a team by team ID. - * + * * You can optionally pass a role for `role` to target * team members with the specified role. - * - * @param {string} id - * @param {string} role + * + * @param {string} id + * @param {string} role * @returns {string} */ public static team(id: string, role: string = ''): string { if (role === '') { - return `team:${id}` + return `team:${id}`; } - return `team:${id}/${role}` + return `team:${id}/${role}`; } /** * Grants access to a specific member of a team. - * + * * When the member is removed from the team, they will * no longer have access. - * - * @param {string} id + * + * @param {string} id * @returns {string} */ public static member(id: string): string { - return `member:${id}` + return `member:${id}`; } /** * Grants access to a user with the specified label. - * - * @param {string} name + * + * @param {string} name * @returns {string} */ public static label(name: string): string { - return `label:${name}` + return `label:${name}`; } -} \ No newline at end of file +} diff --git a/src/services/account.ts b/src/services/account.ts index 849902c5..b871ac75 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,11 +1,9 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - import { AuthenticatorType } from '../enums/authenticator-type'; import { AuthenticationFactor } from '../enums/authentication-factor'; import { OAuthProvider } from '../enums/o-auth-provider'; - export class Account { client: Client; @@ -19,23 +17,19 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - get(): Promise> { - + get< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(): Promise> { const apiPath = '/account'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -48,7 +42,14 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - create(params: { userId: string, email: string, password: string, name?: string }): Promise>; + create< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + name?: string; + }): Promise>; /** * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). * @@ -60,29 +61,49 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - create(userId: string, email: string, password: string, name?: string): Promise>; create( - paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + userId: string, + email: string, + password: string, + name?: string, + ): Promise>; + create( + paramsOrFirst: + | { userId: string; email: string; password: string; name?: string } + | string, + ...rest: [string?, string?, string?] ): Promise> { - let params: { userId: string, email: string, password: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + let params: { + userId: string; + email: string; + password: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, password: rest[1] as string, - name: rest[2] as string + name: rest[2] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; const name = params.name; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -90,37 +111,33 @@ export class Account { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/account'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof password !== 'undefined') { - payload['password'] = password; + apiPayload['password'] = password; } if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -131,7 +148,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - listConsents(params?: { queries?: string[], total?: boolean }): Promise; + listConsents(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of the OAuth2 consents the current user has given to third-party apps. * @@ -141,47 +161,51 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listConsents(queries?: string[], total?: boolean): Promise; listConsents( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listConsents( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/account/consents'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -202,39 +226,41 @@ export class Account { */ getConsent(consentId: string): Promise; getConsent( - paramsOrFirst: { consentId: string } | string + paramsOrFirst: { consentId: string } | string, ): Promise { let params: { consentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { consentId: string }; } else { params = { - consentId: paramsOrFirst as string + consentId: paramsOrFirst as string, }; } - - const consentId = params.consentId; + const consentId = params.consentId; if (typeof consentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "consentId"'); + throw new AppwriteException( + 'Missing required parameter: "consentId"', + ); } - - const apiPath = '/account/consents/{consentId}'.replace('{consentId}', encodeURIComponent(String(consentId))); - const payload: Payload = {}; + const apiPath = '/account/consents/{consentId}'.replace( + '{consentId}', + encodeURIComponent(String(consentId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -254,41 +280,41 @@ export class Account { * @deprecated Use the object parameter style method for a better developer experience. */ deleteConsent(consentId: string): Promise<{}>; - deleteConsent( - paramsOrFirst: { consentId: string } | string - ): Promise<{}> { + deleteConsent(paramsOrFirst: { consentId: string } | string): Promise<{}> { let params: { consentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { consentId: string }; } else { params = { - consentId: paramsOrFirst as string + consentId: paramsOrFirst as string, }; } - - const consentId = params.consentId; + const consentId = params.consentId; if (typeof consentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "consentId"'); + throw new AppwriteException( + 'Missing required parameter: "consentId"', + ); } - - const apiPath = '/account/consents/{consentId}'.replace('{consentId}', encodeURIComponent(String(consentId))); - const payload: Payload = {}; + const apiPath = '/account/consents/{consentId}'.replace( + '{consentId}', + encodeURIComponent(String(consentId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -300,7 +326,11 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - listConsentTokens(params: { consentId: string, queries?: string[], total?: boolean }): Promise; + listConsentTokens(params: { + consentId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of the token families issued under an OAuth2 consent. Each entry represents one authorized device or session; the token secrets themselves are never returned. * @@ -311,52 +341,63 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listConsentTokens(consentId: string, queries?: string[], total?: boolean): Promise; listConsentTokens( - paramsOrFirst: { consentId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + consentId: string, + queries?: string[], + total?: boolean, + ): Promise; + listConsentTokens( + paramsOrFirst: + { consentId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { consentId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { consentId: string, queries?: string[], total?: boolean }; + let params: { consentId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + consentId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { consentId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const consentId = params.consentId; const queries = params.queries; const total = params.total; - if (typeof consentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "consentId"'); + throw new AppwriteException( + 'Missing required parameter: "consentId"', + ); } - - const apiPath = '/account/consents/{consentId}/tokens'.replace('{consentId}', encodeURIComponent(String(consentId))); - const payload: Payload = {}; + const apiPath = '/account/consents/{consentId}/tokens'.replace( + '{consentId}', + encodeURIComponent(String(consentId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -367,7 +408,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - getConsentToken(params: { consentId: string, tokenId: string }): Promise; + getConsentToken(params: { + consentId: string; + tokenId: string; + }): Promise; /** * Get a token family issued under an OAuth2 consent by its unique ID. The token secrets themselves are never returned. * @@ -377,47 +421,56 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getConsentToken(consentId: string, tokenId: string): Promise; getConsentToken( - paramsOrFirst: { consentId: string, tokenId: string } | string, - ...rest: [(string)?] + consentId: string, + tokenId: string, + ): Promise; + getConsentToken( + paramsOrFirst: { consentId: string; tokenId: string } | string, + ...rest: [string?] ): Promise { - let params: { consentId: string, tokenId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { consentId: string, tokenId: string }; + let params: { consentId: string; tokenId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + consentId: string; + tokenId: string; + }; } else { params = { consentId: paramsOrFirst as string, - tokenId: rest[0] as string + tokenId: rest[0] as string, }; } - + const consentId = params.consentId; const tokenId = params.tokenId; - if (typeof consentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "consentId"'); + throw new AppwriteException( + 'Missing required parameter: "consentId"', + ); } if (typeof tokenId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tokenId"'); - } - - const apiPath = '/account/consents/{consentId}/tokens/{tokenId}'.replace('{consentId}', encodeURIComponent(String(consentId))).replace('{tokenId}', encodeURIComponent(String(tokenId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "tokenId"', + ); + } + const apiPath = '/account/consents/{consentId}/tokens/{tokenId}' + .replace('{consentId}', encodeURIComponent(String(consentId))) + .replace('{tokenId}', encodeURIComponent(String(tokenId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -428,7 +481,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteConsentToken(params: { consentId: string, tokenId: string }): Promise<{}>; + deleteConsentToken(params: { + consentId: string; + tokenId: string; + }): Promise<{}>; /** * Delete a token family issued under an OAuth2 consent by its unique ID. The access and refresh tokens of the family stop working immediately; other token families and the consent itself are unaffected. * @@ -440,63 +496,74 @@ export class Account { */ deleteConsentToken(consentId: string, tokenId: string): Promise<{}>; deleteConsentToken( - paramsOrFirst: { consentId: string, tokenId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { consentId: string; tokenId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { consentId: string, tokenId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { consentId: string, tokenId: string }; + let params: { consentId: string; tokenId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + consentId: string; + tokenId: string; + }; } else { params = { consentId: paramsOrFirst as string, - tokenId: rest[0] as string + tokenId: rest[0] as string, }; } - + const consentId = params.consentId; const tokenId = params.tokenId; - if (typeof consentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "consentId"'); + throw new AppwriteException( + 'Missing required parameter: "consentId"', + ); } if (typeof tokenId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tokenId"'); - } - - const apiPath = '/account/consents/{consentId}/tokens/{tokenId}'.replace('{consentId}', encodeURIComponent(String(consentId))).replace('{tokenId}', encodeURIComponent(String(tokenId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "tokenId"', + ); + } + const apiPath = '/account/consents/{consentId}/tokens/{tokenId}' + .replace('{consentId}', encodeURIComponent(String(consentId))) + .replace('{tokenId}', encodeURIComponent(String(tokenId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** * Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. * This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. - * + * * * @param {string} params.email - User email. * @param {string} params.password - User password. Must be at least 8 chars. * @throws {AppwriteException} * @returns {Promise>} */ - updateEmail(params: { email: string, password: string }): Promise>; + updateEmail< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + email: string; + password: string; + }): Promise>; /** * Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. * This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. - * + * * * @param {string} email - User email. * @param {string} password - User password. Must be at least 8 chars. @@ -504,54 +571,60 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmail(email: string, password: string): Promise>; - updateEmail( - paramsOrFirst: { email: string, password: string } | string, - ...rest: [(string)?] + updateEmail< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(email: string, password: string): Promise>; + updateEmail< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { email: string; password: string } | string, + ...rest: [string?] ): Promise> { - let params: { email: string, password: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { email: string, password: string }; + let params: { email: string; password: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + email: string; + password: string; + }; } else { params = { email: paramsOrFirst as string, - password: rest[0] as string + password: rest[0] as string, }; } - + const email = params.email; const password = params.password; - if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/account/email'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof password !== 'undefined') { - payload['password'] = password; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -562,7 +635,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - listIdentities(params?: { queries?: string[], total?: boolean }): Promise; + listIdentities(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get the list of identities for the currently logged in user. * @@ -572,47 +648,51 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listIdentities(queries?: string[], total?: boolean): Promise; listIdentities( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listIdentities( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/account/identities'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -633,39 +713,41 @@ export class Account { */ deleteIdentity(identityId: string): Promise<{}>; deleteIdentity( - paramsOrFirst: { identityId: string } | string + paramsOrFirst: { identityId: string } | string, ): Promise<{}> { let params: { identityId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { identityId: string }; } else { params = { - identityId: paramsOrFirst as string + identityId: paramsOrFirst as string, }; } - - const identityId = params.identityId; + const identityId = params.identityId; if (typeof identityId === 'undefined') { - throw new AppwriteException('Missing required parameter: "identityId"'); + throw new AppwriteException( + 'Missing required parameter: "identityId"', + ); } - - const apiPath = '/account/identities/{identityId}'.replace('{identityId}', encodeURIComponent(String(identityId))); - const payload: Payload = {}; + const apiPath = '/account/identities/{identityId}'.replace( + '{identityId}', + encodeURIComponent(String(identityId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -676,7 +758,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - listLogs(params?: { queries?: string[], total?: boolean }): Promise; + listLogs(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. * @@ -688,45 +773,46 @@ export class Account { */ listLogs(queries?: string[], total?: boolean): Promise; listLogs( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/account/logs'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -736,7 +822,9 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - updateMFA(params: { mfa: boolean }): Promise>; + updateMFA< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { mfa: boolean }): Promise>; /** * Enable or disable MFA on an account. * @@ -745,45 +833,46 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMFA(mfa: boolean): Promise>; - updateMFA( - paramsOrFirst: { mfa: boolean } | boolean + updateMFA< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(mfa: boolean): Promise>; + updateMFA< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { mfa: boolean } | boolean, ): Promise> { let params: { mfa: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { mfa: boolean }; } else { params = { - mfa: paramsOrFirst as boolean + mfa: paramsOrFirst as boolean, }; } - - const mfa = params.mfa; + const mfa = params.mfa; if (typeof mfa === 'undefined') { throw new AppwriteException('Missing required parameter: "mfa"'); } - const apiPath = '/account/mfa'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof mfa !== 'undefined') { - payload['mfa'] = mfa; + apiPayload['mfa'] = mfa; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -794,7 +883,9 @@ export class Account { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead. */ - createMfaAuthenticator(params: { type: AuthenticatorType }): Promise; + createMfaAuthenticator(params: { + type: AuthenticatorType; + }): Promise; /** * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. * @@ -805,40 +896,41 @@ export class Account { */ createMfaAuthenticator(type: AuthenticatorType): Promise; createMfaAuthenticator( - paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType + paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType, ): Promise { let params: { type: AuthenticatorType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'type' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { type: AuthenticatorType }; } else { params = { - type: paramsOrFirst as AuthenticatorType + type: paramsOrFirst as AuthenticatorType, }; } - - const type = params.type; + const type = params.type; if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type))); - const payload: Payload = {}; + const apiPath = '/account/mfa/authenticators/{type}'.replace( + '{type}', + encodeURIComponent(String(type)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -848,7 +940,9 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createMFAAuthenticator(params: { type: AuthenticatorType }): Promise; + createMFAAuthenticator(params: { + type: AuthenticatorType; + }): Promise; /** * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. * @@ -859,40 +953,41 @@ export class Account { */ createMFAAuthenticator(type: AuthenticatorType): Promise; createMFAAuthenticator( - paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType + paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType, ): Promise { let params: { type: AuthenticatorType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'type' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { type: AuthenticatorType }; } else { params = { - type: paramsOrFirst as AuthenticatorType + type: paramsOrFirst as AuthenticatorType, }; } - - const type = params.type; + const type = params.type; if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type))); - const payload: Payload = {}; + const apiPath = '/account/mfa/authenticators/{type}'.replace( + '{type}', + encodeURIComponent(String(type)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -904,7 +999,12 @@ export class Account { * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead. */ - updateMfaAuthenticator(params: { type: AuthenticatorType, otp: string }): Promise>; + updateMfaAuthenticator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + type: AuthenticatorType; + otp: string; + }): Promise>; /** * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * @@ -914,51 +1014,60 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMfaAuthenticator(type: AuthenticatorType, otp: string): Promise>; - updateMfaAuthenticator( - paramsOrFirst: { type: AuthenticatorType, otp: string } | AuthenticatorType, - ...rest: [(string)?] + updateMfaAuthenticator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(type: AuthenticatorType, otp: string): Promise>; + updateMfaAuthenticator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + { type: AuthenticatorType; otp: string } | AuthenticatorType, + ...rest: [string?] ): Promise> { - let params: { type: AuthenticatorType, otp: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst || 'otp' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { type: AuthenticatorType, otp: string }; + let params: { type: AuthenticatorType; otp: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('type' in paramsOrFirst || 'otp' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + type: AuthenticatorType; + otp: string; + }; } else { params = { type: paramsOrFirst as AuthenticatorType, - otp: rest[0] as string + otp: rest[0] as string, }; } - + const type = params.type; const otp = params.otp; - if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof otp === 'undefined') { throw new AppwriteException('Missing required parameter: "otp"'); } - - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type))); - const payload: Payload = {}; + const apiPath = '/account/mfa/authenticators/{type}'.replace( + '{type}', + encodeURIComponent(String(type)), + ); + const apiPayload: Payload = {}; if (typeof otp !== 'undefined') { - payload['otp'] = otp; + apiPayload['otp'] = otp; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -969,7 +1078,12 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - updateMFAAuthenticator(params: { type: AuthenticatorType, otp: string }): Promise>; + updateMFAAuthenticator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + type: AuthenticatorType; + otp: string; + }): Promise>; /** * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * @@ -979,51 +1093,60 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMFAAuthenticator(type: AuthenticatorType, otp: string): Promise>; - updateMFAAuthenticator( - paramsOrFirst: { type: AuthenticatorType, otp: string } | AuthenticatorType, - ...rest: [(string)?] + updateMFAAuthenticator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(type: AuthenticatorType, otp: string): Promise>; + updateMFAAuthenticator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + { type: AuthenticatorType; otp: string } | AuthenticatorType, + ...rest: [string?] ): Promise> { - let params: { type: AuthenticatorType, otp: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst || 'otp' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { type: AuthenticatorType, otp: string }; + let params: { type: AuthenticatorType; otp: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('type' in paramsOrFirst || 'otp' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + type: AuthenticatorType; + otp: string; + }; } else { params = { type: paramsOrFirst as AuthenticatorType, - otp: rest[0] as string + otp: rest[0] as string, }; } - + const type = params.type; const otp = params.otp; - if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof otp === 'undefined') { throw new AppwriteException('Missing required parameter: "otp"'); } - - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type))); - const payload: Payload = {}; + const apiPath = '/account/mfa/authenticators/{type}'.replace( + '{type}', + encodeURIComponent(String(type)), + ); + const apiPayload: Payload = {}; if (typeof otp !== 'undefined') { - payload['otp'] = otp; + apiPayload['otp'] = otp; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1045,39 +1168,40 @@ export class Account { */ deleteMfaAuthenticator(type: AuthenticatorType): Promise<{}>; deleteMfaAuthenticator( - paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType + paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType, ): Promise<{}> { let params: { type: AuthenticatorType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'type' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { type: AuthenticatorType }; } else { params = { - type: paramsOrFirst as AuthenticatorType + type: paramsOrFirst as AuthenticatorType, }; } - - const type = params.type; + const type = params.type; if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type))); - const payload: Payload = {}; + const apiPath = '/account/mfa/authenticators/{type}'.replace( + '{type}', + encodeURIComponent(String(type)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1098,39 +1222,40 @@ export class Account { */ deleteMFAAuthenticator(type: AuthenticatorType): Promise<{}>; deleteMFAAuthenticator( - paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType + paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType, ): Promise<{}> { let params: { type: AuthenticatorType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'type' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { type: AuthenticatorType }; } else { params = { - type: paramsOrFirst as AuthenticatorType + type: paramsOrFirst as AuthenticatorType, }; } - - const type = params.type; + const type = params.type; if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type))); - const payload: Payload = {}; + const apiPath = '/account/mfa/authenticators/{type}'.replace( + '{type}', + encodeURIComponent(String(type)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1141,7 +1266,9 @@ export class Account { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead. */ - createMfaChallenge(params: { factor: AuthenticationFactor }): Promise; + createMfaChallenge(params: { + factor: AuthenticationFactor; + }): Promise; /** * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * @@ -1150,45 +1277,45 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMfaChallenge(factor: AuthenticationFactor): Promise; createMfaChallenge( - paramsOrFirst: { factor: AuthenticationFactor } | AuthenticationFactor + factor: AuthenticationFactor, + ): Promise; + createMfaChallenge( + paramsOrFirst: { factor: AuthenticationFactor } | AuthenticationFactor, ): Promise { let params: { factor: AuthenticationFactor }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('factor' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'factor' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { factor: AuthenticationFactor }; } else { params = { - factor: paramsOrFirst as AuthenticationFactor + factor: paramsOrFirst as AuthenticationFactor, }; } - - const factor = params.factor; + const factor = params.factor; if (typeof factor === 'undefined') { throw new AppwriteException('Missing required parameter: "factor"'); } - const apiPath = '/account/mfa/challenges'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof factor !== 'undefined') { - payload['factor'] = factor; + apiPayload['factor'] = factor; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1198,7 +1325,9 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createMFAChallenge(params: { factor: AuthenticationFactor }): Promise; + createMFAChallenge(params: { + factor: AuthenticationFactor; + }): Promise; /** * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * @@ -1207,45 +1336,45 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMFAChallenge(factor: AuthenticationFactor): Promise; createMFAChallenge( - paramsOrFirst: { factor: AuthenticationFactor } | AuthenticationFactor + factor: AuthenticationFactor, + ): Promise; + createMFAChallenge( + paramsOrFirst: { factor: AuthenticationFactor } | AuthenticationFactor, ): Promise { let params: { factor: AuthenticationFactor }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('factor' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'factor' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { factor: AuthenticationFactor }; } else { params = { - factor: paramsOrFirst as AuthenticationFactor + factor: paramsOrFirst as AuthenticationFactor, }; } - - const factor = params.factor; + const factor = params.factor; if (typeof factor === 'undefined') { throw new AppwriteException('Missing required parameter: "factor"'); } - const apiPath = '/account/mfa/challenges'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof factor !== 'undefined') { - payload['factor'] = factor; + apiPayload['factor'] = factor; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1257,7 +1386,10 @@ export class Account { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead. */ - updateMfaChallenge(params: { challengeId: string, otp: string }): Promise; + updateMfaChallenge(params: { + challengeId: string; + otp: string; + }): Promise; /** * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * @@ -1267,54 +1399,59 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMfaChallenge(challengeId: string, otp: string): Promise; updateMfaChallenge( - paramsOrFirst: { challengeId: string, otp: string } | string, - ...rest: [(string)?] + challengeId: string, + otp: string, + ): Promise; + updateMfaChallenge( + paramsOrFirst: { challengeId: string; otp: string } | string, + ...rest: [string?] ): Promise { - let params: { challengeId: string, otp: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { challengeId: string, otp: string }; + let params: { challengeId: string; otp: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + challengeId: string; + otp: string; + }; } else { params = { challengeId: paramsOrFirst as string, - otp: rest[0] as string + otp: rest[0] as string, }; } - + const challengeId = params.challengeId; const otp = params.otp; - if (typeof challengeId === 'undefined') { - throw new AppwriteException('Missing required parameter: "challengeId"'); + throw new AppwriteException( + 'Missing required parameter: "challengeId"', + ); } if (typeof otp === 'undefined') { throw new AppwriteException('Missing required parameter: "otp"'); } - const apiPath = '/account/mfa/challenges'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof challengeId !== 'undefined') { - payload['challengeId'] = challengeId; + apiPayload['challengeId'] = challengeId; } if (typeof otp !== 'undefined') { - payload['otp'] = otp; + apiPayload['otp'] = otp; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1325,7 +1462,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - updateMFAChallenge(params: { challengeId: string, otp: string }): Promise; + updateMFAChallenge(params: { + challengeId: string; + otp: string; + }): Promise; /** * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * @@ -1335,54 +1475,59 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMFAChallenge(challengeId: string, otp: string): Promise; updateMFAChallenge( - paramsOrFirst: { challengeId: string, otp: string } | string, - ...rest: [(string)?] + challengeId: string, + otp: string, + ): Promise; + updateMFAChallenge( + paramsOrFirst: { challengeId: string; otp: string } | string, + ...rest: [string?] ): Promise { - let params: { challengeId: string, otp: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { challengeId: string, otp: string }; + let params: { challengeId: string; otp: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + challengeId: string; + otp: string; + }; } else { params = { challengeId: paramsOrFirst as string, - otp: rest[0] as string + otp: rest[0] as string, }; } - + const challengeId = params.challengeId; const otp = params.otp; - if (typeof challengeId === 'undefined') { - throw new AppwriteException('Missing required parameter: "challengeId"'); + throw new AppwriteException( + 'Missing required parameter: "challengeId"', + ); } if (typeof otp === 'undefined') { throw new AppwriteException('Missing required parameter: "otp"'); } - const apiPath = '/account/mfa/challenges'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof challengeId !== 'undefined') { - payload['challengeId'] = challengeId; + apiPayload['challengeId'] = challengeId; } if (typeof otp !== 'undefined') { - payload['otp'] = otp; + apiPayload['otp'] = otp; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1393,22 +1538,16 @@ export class Account { * @deprecated This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead. */ listMfaFactors(): Promise { - const apiPath = '/account/mfa/factors'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1418,22 +1557,16 @@ export class Account { * @returns {Promise} */ listMFAFactors(): Promise { - const apiPath = '/account/mfa/factors'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1444,22 +1577,16 @@ export class Account { * @deprecated This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead. */ getMfaRecoveryCodes(): Promise { - const apiPath = '/account/mfa/recovery-codes'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1469,22 +1596,16 @@ export class Account { * @returns {Promise} */ getMFARecoveryCodes(): Promise { - const apiPath = '/account/mfa/recovery-codes'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1495,23 +1616,17 @@ export class Account { * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead. */ createMfaRecoveryCodes(): Promise { - const apiPath = '/account/mfa/recovery-codes'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1521,23 +1636,17 @@ export class Account { * @returns {Promise} */ createMFARecoveryCodes(): Promise { - const apiPath = '/account/mfa/recovery-codes'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1548,23 +1657,17 @@ export class Account { * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead. */ updateMfaRecoveryCodes(): Promise { - const apiPath = '/account/mfa/recovery-codes'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1574,23 +1677,17 @@ export class Account { * @returns {Promise} */ updateMFARecoveryCodes(): Promise { - const apiPath = '/account/mfa/recovery-codes'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1600,7 +1697,9 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - updateName(params: { name: string }): Promise>; + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { name: string }): Promise>; /** * Update currently logged in user account name. * @@ -1609,45 +1708,46 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateName(name: string): Promise>; - updateName( - paramsOrFirst: { name: string } | string + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(name: string): Promise>; + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { name: string } | string, ): Promise> { let params: { name: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { name: string }; } else { params = { - name: paramsOrFirst as string + name: paramsOrFirst as string, }; } - - const name = params.name; + const name = params.name; if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/account/name'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1658,7 +1758,12 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - updatePassword(params: { password: string, oldPassword?: string }): Promise>; + updatePassword< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + password: string; + oldPassword?: string; + }): Promise>; /** * Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. * @@ -1668,51 +1773,60 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePassword(password: string, oldPassword?: string): Promise>; - updatePassword( - paramsOrFirst: { password: string, oldPassword?: string } | string, - ...rest: [(string)?] + updatePassword< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + password: string, + oldPassword?: string, + ): Promise>; + updatePassword< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { password: string; oldPassword?: string } | string, + ...rest: [string?] ): Promise> { - let params: { password: string, oldPassword?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { password: string, oldPassword?: string }; + let params: { password: string; oldPassword?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + password: string; + oldPassword?: string; + }; } else { params = { password: paramsOrFirst as string, - oldPassword: rest[0] as string + oldPassword: rest[0] as string, }; } - + const password = params.password; const oldPassword = params.oldPassword; - if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/account/password'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof password !== 'undefined') { - payload['password'] = password; + apiPayload['password'] = password; } if (typeof oldPassword !== 'undefined') { - payload['oldPassword'] = oldPassword; + apiPayload['oldPassword'] = oldPassword; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1723,7 +1837,12 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - updatePhone(params: { phone: string, password: string }): Promise>; + updatePhone< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + phone: string; + password: string; + }): Promise>; /** * Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. * @@ -1733,54 +1852,60 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePhone(phone: string, password: string): Promise>; - updatePhone( - paramsOrFirst: { phone: string, password: string } | string, - ...rest: [(string)?] + updatePhone< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(phone: string, password: string): Promise>; + updatePhone< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { phone: string; password: string } | string, + ...rest: [string?] ): Promise> { - let params: { phone: string, password: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { phone: string, password: string }; + let params: { phone: string; password: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + phone: string; + password: string; + }; } else { params = { phone: paramsOrFirst as string, - password: rest[0] as string + password: rest[0] as string, }; } - + const phone = params.phone; const password = params.password; - if (typeof phone === 'undefined') { throw new AppwriteException('Missing required parameter: "phone"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/account/phone'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof phone !== 'undefined') { - payload['phone'] = phone; + apiPayload['phone'] = phone; } if (typeof password !== 'undefined') { - payload['password'] = password; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1789,23 +1914,19 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - getPrefs(): Promise { - + getPrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(): Promise { const apiPath = '/account/prefs'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1815,7 +1936,11 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - updatePrefs(params: { prefs: Partial }): Promise>; + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + prefs: Partial; + }): Promise>; /** * Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. * @@ -1824,45 +1949,47 @@ export class Account { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePrefs(prefs: Partial): Promise>; - updatePrefs( - paramsOrFirst: { prefs: Partial } | Partial + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(prefs: Partial): Promise>; + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { prefs: Partial } | Partial, ): Promise> { let params: { prefs: Partial }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('prefs' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'prefs' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { prefs: Partial }; } else { params = { - prefs: paramsOrFirst as Partial + prefs: paramsOrFirst as Partial, }; } - - const prefs = params.prefs; + const prefs = params.prefs; if (typeof prefs === 'undefined') { throw new AppwriteException('Missing required parameter: "prefs"'); } - const apiPath = '/account/prefs'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof prefs !== 'undefined') { - payload['prefs'] = prefs; + apiPayload['prefs'] = prefs; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1873,7 +2000,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createRecovery(params: { email: string, url: string }): Promise; + createRecovery(params: { + email: string; + url: string; + }): Promise; /** * Sends the user an email with a temporary secret key for password reset. When the user clicks the confirmation link he is redirected back to your app password reset URL with the secret key and email address values attached to the URL query string. Use the query string params to submit a request to the [PUT /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) endpoint to complete the process. The verification link sent to the user's email address is valid for 1 hour. * @@ -1885,57 +2015,54 @@ export class Account { */ createRecovery(email: string, url: string): Promise; createRecovery( - paramsOrFirst: { email: string, url: string } | string, - ...rest: [(string)?] + paramsOrFirst: { email: string; url: string } | string, + ...rest: [string?] ): Promise { - let params: { email: string, url: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { email: string, url: string }; + let params: { email: string; url: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { email: string; url: string }; } else { params = { email: paramsOrFirst as string, - url: rest[0] as string + url: rest[0] as string, }; } - + const email = params.email; const url = params.url; - if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } - const apiPath = '/account/recovery'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof url !== 'undefined') { - payload['url'] = url; + apiPayload['url'] = url; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Use this endpoint to complete the user account password reset. Both the **userId** and **secret** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the [POST /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) endpoint. - * + * * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. * * @param {string} params.userId - User ID. @@ -1944,10 +2071,14 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - updateRecovery(params: { userId: string, secret: string, password: string }): Promise; + updateRecovery(params: { + userId: string; + secret: string; + password: string; + }): Promise; /** * Use this endpoint to complete the user account password reset. Both the **userId** and **secret** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the [POST /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) endpoint. - * + * * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. * * @param {string} userId - User ID. @@ -1957,27 +2088,39 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRecovery(userId: string, secret: string, password: string): Promise; updateRecovery( - paramsOrFirst: { userId: string, secret: string, password: string } | string, - ...rest: [(string)?, (string)?] + userId: string, + secret: string, + password: string, + ): Promise; + updateRecovery( + 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 }; + 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 + 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"'); } @@ -1985,34 +2128,30 @@ export class Account { throw new AppwriteException('Missing required parameter: "secret"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/account/recovery'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + apiPayload['secret'] = secret; } if (typeof password !== 'undefined') { - payload['password'] = password; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2022,22 +2161,16 @@ export class Account { * @returns {Promise} */ listSessions(): Promise { - const apiPath = '/account/sessions'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2047,22 +2180,16 @@ export class Account { * @returns {Promise<{}>} */ deleteSessions(): Promise<{}> { - const apiPath = '/account/sessions'; - const payload: Payload = {}; + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -2072,28 +2199,22 @@ export class Account { * @returns {Promise} */ createAnonymousSession(): Promise { - const apiPath = '/account/sessions/anonymous'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * 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. - * + * * 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 {string} params.email - User email. @@ -2101,10 +2222,13 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createEmailPasswordSession(params: { email: string, password: string }): Promise; + createEmailPasswordSession(params: { + email: string; + password: string; + }): 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. - * + * * 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 {string} email - User email. @@ -2113,54 +2237,59 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEmailPasswordSession(email: string, password: string): Promise; createEmailPasswordSession( - paramsOrFirst: { email: string, password: string } | string, - ...rest: [(string)?] + email: string, + password: string, + ): Promise; + createEmailPasswordSession( + paramsOrFirst: { email: string; password: string } | string, + ...rest: [string?] ): Promise { - let params: { email: string, password: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { email: string, password: string }; + let params: { email: string; password: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + email: string; + password: string; + }; } else { params = { email: paramsOrFirst as string, - password: rest[0] as string + password: rest[0] as string, }; } - + const email = params.email; const password = params.password; - if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/account/sessions/email'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof password !== 'undefined') { - payload['password'] = password; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2172,7 +2301,10 @@ export class Account { * @returns {Promise} * @deprecated This API has been deprecated since 1.6.0. Please use `Account.createSession` instead. */ - updateMagicURLSession(params: { userId: string, secret: string }): Promise; + updateMagicURLSession(params: { + userId: string; + secret: string; + }): Promise; /** * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * @@ -2182,54 +2314,57 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMagicURLSession(userId: string, secret: string): Promise; updateMagicURLSession( - paramsOrFirst: { userId: string, secret: string } | string, - ...rest: [(string)?] + userId: string, + secret: string, + ): Promise; + updateMagicURLSession( + 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 }; + 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 + 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/sessions/magic-url'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2241,7 +2376,10 @@ export class Account { * @returns {Promise} * @deprecated This API has been deprecated since 1.6.0. Please use `Account.createSession` instead. */ - updatePhoneSession(params: { userId: string, secret: string }): Promise; + updatePhoneSession(params: { + userId: string; + secret: string; + }): Promise; /** * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * @@ -2253,52 +2391,52 @@ export class Account { */ updatePhoneSession(userId: string, secret: string): Promise; updatePhoneSession( - paramsOrFirst: { userId: string, secret: string } | string, - ...rest: [(string)?] + 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 }; + 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 + 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/sessions/phone'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2309,7 +2447,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createSession(params: { userId: string, secret: string }): Promise; + createSession(params: { + userId: string; + secret: string; + }): Promise; /** * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * @@ -2321,52 +2462,52 @@ export class Account { */ createSession(userId: string, secret: string): Promise; createSession( - paramsOrFirst: { userId: string, secret: string } | string, - ...rest: [(string)?] + 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 }; + 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 + 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/sessions/token'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2387,39 +2528,41 @@ export class Account { */ getSession(sessionId: string): Promise; getSession( - paramsOrFirst: { sessionId: string } | string + paramsOrFirst: { sessionId: string } | string, ): Promise { let params: { sessionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { sessionId: string }; } else { params = { - sessionId: paramsOrFirst as string + sessionId: paramsOrFirst as string, }; } - - const sessionId = params.sessionId; + const sessionId = params.sessionId; if (typeof sessionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "sessionId"'); + throw new AppwriteException( + 'Missing required parameter: "sessionId"', + ); } - - const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', encodeURIComponent(String(sessionId))); - const payload: Payload = {}; + const apiPath = '/account/sessions/{sessionId}'.replace( + '{sessionId}', + encodeURIComponent(String(sessionId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2440,40 +2583,42 @@ export class Account { */ updateSession(sessionId: string): Promise; updateSession( - paramsOrFirst: { sessionId: string } | string + paramsOrFirst: { sessionId: string } | string, ): Promise { let params: { sessionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { sessionId: string }; } else { params = { - sessionId: paramsOrFirst as string + sessionId: paramsOrFirst as string, }; } - - const sessionId = params.sessionId; + const sessionId = params.sessionId; if (typeof sessionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "sessionId"'); + throw new AppwriteException( + 'Missing required parameter: "sessionId"', + ); } - - const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', encodeURIComponent(String(sessionId))); - const payload: Payload = {}; + const apiPath = '/account/sessions/{sessionId}'.replace( + '{sessionId}', + encodeURIComponent(String(sessionId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2493,40 +2638,40 @@ export class Account { * @deprecated Use the object parameter style method for a better developer experience. */ deleteSession(sessionId: string): Promise<{}>; - deleteSession( - paramsOrFirst: { sessionId: string } | string - ): Promise<{}> { + deleteSession(paramsOrFirst: { sessionId: string } | string): Promise<{}> { let params: { sessionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { sessionId: string }; } else { params = { - sessionId: paramsOrFirst as string + sessionId: paramsOrFirst as string, }; } - - const sessionId = params.sessionId; + const sessionId = params.sessionId; if (typeof sessionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "sessionId"'); + throw new AppwriteException( + 'Missing required parameter: "sessionId"', + ); } - - const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', encodeURIComponent(String(sessionId))); - const payload: Payload = {}; + const apiPath = '/account/sessions/{sessionId}'.replace( + '{sessionId}', + encodeURIComponent(String(sessionId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -2535,31 +2680,27 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - updateStatus(): Promise> { - + updateStatus< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(): Promise> { const apiPath = '/account/status'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Sends the user an email with a secret key for creating a session. If the email address has never been used, a **new account is created** using the provided `userId`. Otherwise, if the email address is already attached to an account, the **user ID is ignored**. Then, the user will receive an email with the one-time password. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes. - * + * * 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 {string} params.userId - User 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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. * @param {string} params.email - User email. @@ -2567,12 +2708,16 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createEmailToken(params: { userId: string, email: string, phrase?: boolean }): Promise; + createEmailToken(params: { + userId: string; + email: string; + phrase?: boolean; + }): Promise; /** * Sends the user an email with a secret key for creating a session. If the email address has never been used, a **new account is created** using the provided `userId`. Otherwise, if the email address is already attached to an account, the **user ID is ignored**. Then, the user will receive an email with the one-time password. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes. - * + * * 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 {string} userId - User 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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. * @param {string} email - User email. @@ -2581,66 +2726,72 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEmailToken(userId: string, email: string, phrase?: boolean): Promise; createEmailToken( - paramsOrFirst: { userId: string, email: string, phrase?: boolean } | string, - ...rest: [(string)?, (boolean)?] + userId: string, + email: string, + phrase?: boolean, + ): Promise; + createEmailToken( + paramsOrFirst: + { userId: string; email: string; phrase?: boolean } | string, + ...rest: [string?, boolean?] ): Promise { - let params: { userId: string, email: string, phrase?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, phrase?: boolean }; + let params: { userId: string; email: string; phrase?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + phrase?: boolean; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, - phrase: rest[1] as boolean + phrase: rest[1] as boolean, }; } - + const userId = params.userId; const email = params.email; const phrase = params.phrase; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } - const apiPath = '/account/tokens/email'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof phrase !== 'undefined') { - payload['phrase'] = phrase; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. - * + * * 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 {string} params.userId - Unique 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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. * @param {string} params.email - User email. @@ -2649,12 +2800,17 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createMagicURLToken(params: { userId: string, email: string, url?: string, phrase?: boolean }): Promise; + createMagicURLToken(params: { + userId: string; + email: string; + url?: string; + phrase?: boolean; + }): Promise; /** * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. - * + * * 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 {string} userId - Unique 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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. * @param {string} email - User email. @@ -2664,89 +2820,108 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMagicURLToken(userId: string, email: string, url?: string, phrase?: boolean): Promise; createMagicURLToken( - paramsOrFirst: { userId: string, email: string, url?: string, phrase?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + userId: string, + email: string, + url?: string, + phrase?: boolean, + ): Promise; + createMagicURLToken( + paramsOrFirst: + | { userId: string; email: string; url?: string; phrase?: boolean } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { userId: string, email: string, url?: string, phrase?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, url?: string, phrase?: boolean }; + let params: { + userId: string; + email: string; + url?: string; + phrase?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + url?: string; + phrase?: boolean; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, url: rest[1] as string, - phrase: rest[2] as boolean + phrase: rest[2] as boolean, }; } - + const userId = params.userId; const email = params.email; const url = params.url; const phrase = params.phrase; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } - const apiPath = '/account/tokens/magic-url'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof url !== 'undefined') { - payload['url'] = url; + apiPayload['url'] = url; } if (typeof phrase !== 'undefined') { - payload['phrase'] = phrase; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** - * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. - * + * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. + * * If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. - * + * * 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 {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. * @param {string} params.success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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.failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's 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.scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. * @throws {AppwriteException} * @returns {Promise} */ - createOAuth2Token(params: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }): Promise; + createOAuth2Token(params: { + provider: OAuthProvider; + success?: string; + failure?: string; + scopes?: string[]; + }): Promise; /** - * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. - * + * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. + * * If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. - * + * * 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 {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. * @param {string} success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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} failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's 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[]} scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. @@ -2754,62 +2929,90 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createOAuth2Token(provider: OAuthProvider, success?: string, failure?: string, scopes?: string[]): Promise; createOAuth2Token( - paramsOrFirst: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] } | OAuthProvider, - ...rest: [(string)?, (string)?, (string[])?] + provider: OAuthProvider, + success?: string, + failure?: string, + scopes?: string[], + ): Promise; + createOAuth2Token( + paramsOrFirst: + | { + provider: OAuthProvider; + success?: string; + failure?: string; + scopes?: string[]; + } + | OAuthProvider, + ...rest: [string?, string?, string[]?] ): Promise { - let params: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || 'scopes' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }; + let params: { + provider: OAuthProvider; + success?: string; + failure?: string; + scopes?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('provider' in paramsOrFirst || + 'success' in paramsOrFirst || + 'failure' in paramsOrFirst || + 'scopes' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + provider: OAuthProvider; + success?: string; + failure?: string; + scopes?: string[]; + }; } else { params = { provider: paramsOrFirst as OAuthProvider, success: rest[0] as string, failure: rest[1] as string, - scopes: rest[2] as string[] + scopes: rest[2] as string[], }; } - + const provider = params.provider; const success = params.success; const failure = params.failure; const scopes = params.scopes; - if (typeof provider === 'undefined') { - throw new AppwriteException('Missing required parameter: "provider"'); + throw new AppwriteException( + 'Missing required parameter: "provider"', + ); } - - const apiPath = '/account/tokens/oauth2/{provider}'.replace('{provider}', encodeURIComponent(String(provider))); - const payload: Payload = {}; + const apiPath = '/account/tokens/oauth2/{provider}'.replace( + '{provider}', + encodeURIComponent(String(provider)), + ); + const apiPayload: Payload = {}; if (typeof success !== 'undefined') { - payload['success'] = success; + apiPayload['success'] = success; } if (typeof failure !== 'undefined') { - payload['failure'] = failure; + apiPayload['failure'] = failure; } if (typeof scopes !== 'undefined') { - payload['scopes'] = scopes; + apiPayload['scopes'] = scopes; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'text/html', - } + accept: 'text/html', + }; - return this.client.redirect( - 'get', - uri, - apiHeaders, - payload - ); + return this.client.redirect('get', uri, apiHeaders, apiPayload); } /** * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. - * + * * 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 {string} params.userId - Unique 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. If the phone number has never been used, a new account is created using the provided userId. Otherwise, if the phone number is already attached to an account, the user ID is ignored. @@ -2817,10 +3020,13 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - createPhoneToken(params: { userId: string, phone: string }): Promise; + createPhoneToken(params: { + userId: string; + phone: string; + }): Promise; /** * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. - * + * * 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 {string} userId - Unique 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. If the phone number has never been used, a new account is created using the provided userId. Otherwise, if the phone number is already attached to an account, the user ID is ignored. @@ -2831,59 +3037,56 @@ export class Account { */ createPhoneToken(userId: string, phone: string): Promise; createPhoneToken( - paramsOrFirst: { userId: string, phone: string } | string, - ...rest: [(string)?] + paramsOrFirst: { userId: string; phone: string } | string, + ...rest: [string?] ): Promise { - let params: { userId: string, phone: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, phone: string }; + let params: { userId: string; phone: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { userId: string; phone: string }; } else { params = { userId: paramsOrFirst as string, - phone: rest[0] as string + phone: rest[0] as string, }; } - + const userId = params.userId; const phone = params.phone; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof phone === 'undefined') { throw new AppwriteException('Missing required parameter: "phone"'); } - const apiPath = '/account/tokens/phone'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof phone !== 'undefined') { - payload['phone'] = phone; + apiPayload['phone'] = phone; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. - * + * * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. - * + * * * @param {string} params.url - URL to redirect the user back to your app from the verification email. 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. * @throws {AppwriteException} @@ -2892,9 +3095,9 @@ export class Account { createEmailVerification(params: { url: string }): Promise; /** * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. - * + * * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. - * + * * * @param {string} url - URL to redirect the user back to your app from the verification email. 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. * @throws {AppwriteException} @@ -2903,50 +3106,47 @@ export class Account { */ createEmailVerification(url: string): Promise; createEmailVerification( - paramsOrFirst: { url: string } | string + paramsOrFirst: { url: string } | string, ): Promise { let params: { url: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { url: string }; } else { params = { - url: paramsOrFirst as string + url: paramsOrFirst as string, }; } - - const url = params.url; + const url = params.url; if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } - const apiPath = '/account/verifications/email'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof url !== 'undefined') { - payload['url'] = url; + apiPayload['url'] = url; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. - * + * * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. - * + * * * @param {string} params.url - URL to redirect the user back to your app from the verification email. 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. * @throws {AppwriteException} @@ -2956,9 +3156,9 @@ export class Account { createVerification(params: { url: string }): Promise; /** * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. - * + * * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. - * + * * * @param {string} url - URL to redirect the user back to your app from the verification email. 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. * @throws {AppwriteException} @@ -2967,43 +3167,40 @@ export class Account { */ createVerification(url: string): Promise; createVerification( - paramsOrFirst: { url: string } | string + paramsOrFirst: { url: string } | string, ): Promise { let params: { url: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { url: string }; } else { params = { - url: paramsOrFirst as string + url: paramsOrFirst as string, }; } - - const url = params.url; + const url = params.url; if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } - const apiPath = '/account/verifications/email'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof url !== 'undefined') { - payload['url'] = url; + apiPayload['url'] = url; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3014,7 +3211,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - updateEmailVerification(params: { userId: string, secret: string }): Promise; + updateEmailVerification(params: { + userId: string; + secret: string; + }): Promise; /** * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. * @@ -3024,54 +3224,57 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmailVerification(userId: string, secret: string): Promise; updateEmailVerification( - paramsOrFirst: { userId: string, secret: string } | string, - ...rest: [(string)?] + userId: string, + secret: string, + ): Promise; + updateEmailVerification( + 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 }; + 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 + 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'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -3083,7 +3286,10 @@ export class Account { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead. */ - updateVerification(params: { userId: string, secret: string }): Promise; + updateVerification(params: { + userId: string; + secret: string; + }): Promise; /** * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. * @@ -3095,52 +3301,52 @@ export class Account { */ updateVerification(userId: string, secret: string): Promise; updateVerification( - paramsOrFirst: { userId: string, secret: string } | string, - ...rest: [(string)?] + 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 }; + 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 + 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'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -3150,23 +3356,17 @@ export class Account { * @returns {Promise} */ createPhoneVerification(): Promise { - const apiPath = '/account/verifications/phone'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3177,7 +3377,10 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ - updatePhoneVerification(params: { userId: string, secret: string }): Promise; + updatePhoneVerification(params: { + userId: string; + secret: string; + }): Promise; /** * Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code. * @@ -3187,53 +3390,56 @@ export class Account { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePhoneVerification(userId: string, secret: string): Promise; updatePhoneVerification( - paramsOrFirst: { userId: string, secret: string } | string, - ...rest: [(string)?] + userId: string, + secret: string, + ): Promise; + updatePhoneVerification( + 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 }; + 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 + 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/phone'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } } diff --git a/src/services/activities.ts b/src/services/activities.ts index 53fca89c..0b5eb511 100644 --- a/src/services/activities.ts +++ b/src/services/activities.ts @@ -1,8 +1,6 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - - export class Activities { client: Client; @@ -17,7 +15,9 @@ export class Activities { * @throws {AppwriteException} * @returns {Promise} */ - listEvents(params?: { queries?: string[] }): Promise; + listEvents(params?: { + queries?: string[]; + }): Promise; /** * List all events for selected filters. * @@ -28,44 +28,42 @@ export class Activities { */ listEvents(queries?: string[]): Promise; listEvents( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; - + const queries = params.queries; const apiPath = '/activities/events'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Get event by ID. - * + * * * @param {string} params.eventId - Event ID. * @throws {AppwriteException} @@ -74,7 +72,7 @@ export class Activities { getEvent(params: { eventId: string }): Promise; /** * Get event by ID. - * + * * * @param {string} eventId - Event ID. * @throws {AppwriteException} @@ -83,38 +81,40 @@ export class Activities { */ getEvent(eventId: string): Promise; getEvent( - paramsOrFirst: { eventId: string } | string + paramsOrFirst: { eventId: string } | string, ): Promise { let params: { eventId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { eventId: string }; } else { params = { - eventId: paramsOrFirst as string + eventId: paramsOrFirst as string, }; } - - const eventId = params.eventId; + const eventId = params.eventId; if (typeof eventId === 'undefined') { - throw new AppwriteException('Missing required parameter: "eventId"'); + throw new AppwriteException( + 'Missing required parameter: "eventId"', + ); } - - const apiPath = '/activities/events/{eventId}'.replace('{eventId}', encodeURIComponent(String(eventId))); - const payload: Payload = {}; + const apiPath = '/activities/events/{eventId}'.replace( + '{eventId}', + encodeURIComponent(String(eventId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } } diff --git a/src/services/advisor.ts b/src/services/advisor.ts index ccb67d33..d511b8e9 100644 --- a/src/services/advisor.ts +++ b/src/services/advisor.ts @@ -1,8 +1,6 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - - export class Advisor { client: Client; @@ -12,17 +10,20 @@ export class Advisor { /** * Get a list of all the project's analyzer reports. 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: appId, type, targetType, target, analyzedAt * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ - listReports(params?: { queries?: string[], total?: boolean }): Promise; + listReports(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all the project's analyzer reports. 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: appId, type, targetType, target, analyzedAt * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. @@ -30,52 +31,56 @@ export class Advisor { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listReports(queries?: string[], total?: boolean): Promise; listReports( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listReports( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/reports'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Get an analyzer report by its unique ID. The response includes the report's metadata and the nested insights it produced. - * + * * * @param {string} params.reportId - Report ID. * @throws {AppwriteException} @@ -84,7 +89,7 @@ export class Advisor { getReport(params: { reportId: string }): Promise; /** * Get an analyzer report by its unique ID. The response includes the report's metadata and the nested insights it produced. - * + * * * @param {string} reportId - Report ID. * @throws {AppwriteException} @@ -93,44 +98,46 @@ export class Advisor { */ getReport(reportId: string): Promise; getReport( - paramsOrFirst: { reportId: string } | string + paramsOrFirst: { reportId: string } | string, ): Promise { let params: { reportId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { reportId: string }; } else { params = { - reportId: paramsOrFirst as string + reportId: paramsOrFirst as string, }; } - - const reportId = params.reportId; + const reportId = params.reportId; if (typeof reportId === 'undefined') { - throw new AppwriteException('Missing required parameter: "reportId"'); + throw new AppwriteException( + 'Missing required parameter: "reportId"', + ); } - - const apiPath = '/reports/{reportId}'.replace('{reportId}', encodeURIComponent(String(reportId))); - const payload: Payload = {}; + const apiPath = '/reports/{reportId}'.replace( + '{reportId}', + encodeURIComponent(String(reportId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Delete an analyzer report by its unique ID. Nested insights and CTA metadata are removed asynchronously by the deletes worker. - * + * * * @param {string} params.reportId - Report ID. * @throws {AppwriteException} @@ -139,7 +146,7 @@ export class Advisor { deleteReport(params: { reportId: string }): Promise<{}>; /** * Delete an analyzer report by its unique ID. Nested insights and CTA metadata are removed asynchronously by the deletes worker. - * + * * * @param {string} reportId - Report ID. * @throws {AppwriteException} @@ -147,45 +154,45 @@ export class Advisor { * @deprecated Use the object parameter style method for a better developer experience. */ deleteReport(reportId: string): Promise<{}>; - deleteReport( - paramsOrFirst: { reportId: string } | string - ): Promise<{}> { + deleteReport(paramsOrFirst: { reportId: string } | string): Promise<{}> { let params: { reportId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { reportId: string }; } else { params = { - reportId: paramsOrFirst as string + reportId: paramsOrFirst as string, }; } - - const reportId = params.reportId; + const reportId = params.reportId; if (typeof reportId === 'undefined') { - throw new AppwriteException('Missing required parameter: "reportId"'); + throw new AppwriteException( + 'Missing required parameter: "reportId"', + ); } - - const apiPath = '/reports/{reportId}'.replace('{reportId}', encodeURIComponent(String(reportId))); - const payload: Payload = {}; + const apiPath = '/reports/{reportId}'.replace( + '{reportId}', + encodeURIComponent(String(reportId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** * List the insights produced under a single analyzer report. You can use the query params to filter your results further. - * + * * * @param {string} params.reportId - Parent report 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: type, severity, status, resourceType, resourceId, parentResourceType, parentResourceId, analyzedAt, dismissedAt, dismissedBy @@ -193,10 +200,14 @@ export class Advisor { * @throws {AppwriteException} * @returns {Promise} */ - listInsights(params: { reportId: string, queries?: string[], total?: boolean }): Promise; + listInsights(params: { + reportId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List the insights produced under a single analyzer report. You can use the query params to filter your results further. - * + * * * @param {string} reportId - Parent report 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: type, severity, status, resourceType, resourceId, parentResourceType, parentResourceId, analyzedAt, dismissedAt, dismissedBy @@ -205,67 +216,81 @@ export class Advisor { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listInsights(reportId: string, queries?: string[], total?: boolean): Promise; listInsights( - paramsOrFirst: { reportId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + reportId: string, + queries?: string[], + total?: boolean, + ): Promise; + listInsights( + paramsOrFirst: + { reportId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { reportId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { reportId: string, queries?: string[], total?: boolean }; + let params: { reportId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + reportId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { reportId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const reportId = params.reportId; const queries = params.queries; const total = params.total; - if (typeof reportId === 'undefined') { - throw new AppwriteException('Missing required parameter: "reportId"'); + throw new AppwriteException( + 'Missing required parameter: "reportId"', + ); } - - const apiPath = '/reports/{reportId}/insights'.replace('{reportId}', encodeURIComponent(String(reportId))); - const payload: Payload = {}; + const apiPath = '/reports/{reportId}/insights'.replace( + '{reportId}', + encodeURIComponent(String(reportId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Get an insight by its unique ID, scoped to its parent report. - * + * * * @param {string} params.reportId - Parent report ID. * @param {string} params.insightId - Insight ID. * @throws {AppwriteException} * @returns {Promise} */ - getInsight(params: { reportId: string, insightId: string }): Promise; + getInsight(params: { + reportId: string; + insightId: string; + }): Promise; /** * Get an insight by its unique ID, scoped to its parent report. - * + * * * @param {string} reportId - Parent report ID. * @param {string} insightId - Insight ID. @@ -275,44 +300,50 @@ export class Advisor { */ getInsight(reportId: string, insightId: string): Promise; getInsight( - paramsOrFirst: { reportId: string, insightId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { reportId: string; insightId: string } | string, + ...rest: [string?] ): Promise { - let params: { reportId: string, insightId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { reportId: string, insightId: string }; + let params: { reportId: string; insightId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + reportId: string; + insightId: string; + }; } else { params = { reportId: paramsOrFirst as string, - insightId: rest[0] as string + insightId: rest[0] as string, }; } - + const reportId = params.reportId; const insightId = params.insightId; - if (typeof reportId === 'undefined') { - throw new AppwriteException('Missing required parameter: "reportId"'); + throw new AppwriteException( + 'Missing required parameter: "reportId"', + ); } if (typeof insightId === 'undefined') { - throw new AppwriteException('Missing required parameter: "insightId"'); + throw new AppwriteException( + 'Missing required parameter: "insightId"', + ); } - - const apiPath = '/reports/{reportId}/insights/{insightId}'.replace('{reportId}', encodeURIComponent(String(reportId))).replace('{insightId}', encodeURIComponent(String(insightId))); - const payload: Payload = {}; + const apiPath = '/reports/{reportId}/insights/{insightId}' + .replace('{reportId}', encodeURIComponent(String(reportId))) + .replace('{insightId}', encodeURIComponent(String(insightId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } } diff --git a/src/services/apps.ts b/src/services/apps.ts index f47da03c..d13ab47a 100644 --- a/src/services/apps.ts +++ b/src/services/apps.ts @@ -1,8 +1,6 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - - export class Apps { client: Client; @@ -18,7 +16,10 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], total?: boolean }): Promise; + list(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * List applications. * @@ -30,45 +31,46 @@ export class Apps { */ list(queries?: string[], total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/apps'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -96,7 +98,27 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - create(params: { appId: string, name: string, redirectUris: string[], description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, postLogoutRedirectUris?: string[], enabled?: boolean, type?: string, deviceFlow?: boolean, teamId?: string }): Promise; + create(params: { + appId: string; + name: string; + redirectUris: string[]; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + postLogoutRedirectUris?: string[]; + enabled?: boolean; + type?: string; + deviceFlow?: boolean; + teamId?: string; + }): Promise; /** * Create a new application. * @@ -123,15 +145,120 @@ export class Apps { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(appId: string, name: string, redirectUris: string[], description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, postLogoutRedirectUris?: string[], enabled?: boolean, type?: string, deviceFlow?: boolean, teamId?: string): Promise; create( - paramsOrFirst: { appId: string, name: string, redirectUris: string[], description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, postLogoutRedirectUris?: string[], enabled?: boolean, type?: string, deviceFlow?: boolean, teamId?: string } | string, - ...rest: [(string)?, (string[])?, (string)?, (string)?, (string)?, (string)?, (string)?, (string[])?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (string[])?, (boolean)?, (string)?, (boolean)?, (string)?] + appId: string, + name: string, + redirectUris: string[], + description?: string, + clientUri?: string, + logoUri?: string, + privacyPolicyUrl?: string, + termsUrl?: string, + contacts?: string[], + tagline?: string, + tags?: string[], + images?: string[], + supportUrl?: string, + dataDeletionUrl?: string, + postLogoutRedirectUris?: string[], + enabled?: boolean, + type?: string, + deviceFlow?: boolean, + teamId?: string, + ): Promise; + create( + paramsOrFirst: + | { + appId: string; + name: string; + redirectUris: string[]; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + postLogoutRedirectUris?: string[]; + enabled?: boolean; + type?: string; + deviceFlow?: boolean; + teamId?: string; + } + | string, + ...rest: [ + string?, + string[]?, + string?, + string?, + string?, + string?, + string?, + string[]?, + string?, + string[]?, + string[]?, + string?, + string?, + string[]?, + boolean?, + string?, + boolean?, + string?, + ] ): Promise { - let params: { appId: string, name: string, redirectUris: string[], description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, postLogoutRedirectUris?: string[], enabled?: boolean, type?: string, deviceFlow?: boolean, teamId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, name: string, redirectUris: string[], description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, postLogoutRedirectUris?: string[], enabled?: boolean, type?: string, deviceFlow?: boolean, teamId?: string }; + let params: { + appId: string; + name: string; + redirectUris: string[]; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + postLogoutRedirectUris?: string[]; + enabled?: boolean; + type?: string; + deviceFlow?: boolean; + teamId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + name: string; + redirectUris: string[]; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + postLogoutRedirectUris?: string[]; + enabled?: boolean; + type?: string; + deviceFlow?: boolean; + teamId?: string; + }; } else { params = { appId: paramsOrFirst as string, @@ -152,10 +279,10 @@ export class Apps { enabled: rest[14] as boolean, type: rest[15] as string, deviceFlow: rest[16] as boolean, - teamId: rest[17] as string + teamId: rest[17] as string, }; } - + const appId = params.appId; const name = params.name; const redirectUris = params.redirectUris; @@ -175,7 +302,6 @@ export class Apps { const type = params.type; const deviceFlow = params.deviceFlow; const teamId = params.teamId; - if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } @@ -183,82 +309,78 @@ export class Apps { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof redirectUris === 'undefined') { - throw new AppwriteException('Missing required parameter: "redirectUris"'); + throw new AppwriteException( + 'Missing required parameter: "redirectUris"', + ); } - const apiPath = '/apps'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof appId !== 'undefined') { - payload['appId'] = appId; + apiPayload['appId'] = appId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof description !== 'undefined') { - payload['description'] = description; + apiPayload['description'] = description; } if (typeof clientUri !== 'undefined') { - payload['clientUri'] = clientUri; + apiPayload['clientUri'] = clientUri; } if (typeof logoUri !== 'undefined') { - payload['logoUri'] = logoUri; + apiPayload['logoUri'] = logoUri; } if (typeof privacyPolicyUrl !== 'undefined') { - payload['privacyPolicyUrl'] = privacyPolicyUrl; + apiPayload['privacyPolicyUrl'] = privacyPolicyUrl; } if (typeof termsUrl !== 'undefined') { - payload['termsUrl'] = termsUrl; + apiPayload['termsUrl'] = termsUrl; } if (typeof contacts !== 'undefined') { - payload['contacts'] = contacts; + apiPayload['contacts'] = contacts; } if (typeof tagline !== 'undefined') { - payload['tagline'] = tagline; + apiPayload['tagline'] = tagline; } if (typeof tags !== 'undefined') { - payload['tags'] = tags; + apiPayload['tags'] = tags; } if (typeof images !== 'undefined') { - payload['images'] = images; + apiPayload['images'] = images; } if (typeof supportUrl !== 'undefined') { - payload['supportUrl'] = supportUrl; + apiPayload['supportUrl'] = supportUrl; } if (typeof dataDeletionUrl !== 'undefined') { - payload['dataDeletionUrl'] = dataDeletionUrl; + apiPayload['dataDeletionUrl'] = dataDeletionUrl; } if (typeof redirectUris !== 'undefined') { - payload['redirectUris'] = redirectUris; + apiPayload['redirectUris'] = redirectUris; } if (typeof postLogoutRedirectUris !== 'undefined') { - payload['postLogoutRedirectUris'] = postLogoutRedirectUris; + apiPayload['postLogoutRedirectUris'] = postLogoutRedirectUris; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof type !== 'undefined') { - payload['type'] = type; + apiPayload['type'] = type; } if (typeof deviceFlow !== 'undefined') { - payload['deviceFlow'] = deviceFlow; + apiPayload['deviceFlow'] = deviceFlow; } if (typeof teamId !== 'undefined') { - payload['teamId'] = teamId; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -268,22 +390,16 @@ export class Apps { * @returns {Promise} */ listInstallationScopes(): Promise { - const apiPath = '/apps/scopes/installations'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -293,22 +409,16 @@ export class Apps { * @returns {Promise} */ listOAuth2Scopes(): Promise { - const apiPath = '/apps/scopes/oauth2'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -328,40 +438,38 @@ export class Apps { * @deprecated Use the object parameter style method for a better developer experience. */ get(appId: string): Promise; - get( - paramsOrFirst: { appId: string } | string - ): Promise { + get(paramsOrFirst: { appId: string } | string): Promise { let params: { appId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { appId: string }; } else { params = { - appId: paramsOrFirst as string + appId: paramsOrFirst as string, }; } - - const appId = params.appId; + const appId = params.appId; if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}'.replace('{appId}', encodeURIComponent(String(appId))); - const payload: Payload = {}; + const apiPath = '/apps/{appId}'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -390,7 +498,28 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { appId: string, name: string, description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, enabled?: boolean, redirectUris?: string[], postLogoutRedirectUris?: string[], type?: string, deviceFlow?: boolean, installationScopes?: string[], installationRedirectUrl?: string }): Promise; + update(params: { + appId: string; + name: string; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + enabled?: boolean; + redirectUris?: string[]; + postLogoutRedirectUris?: string[]; + type?: string; + deviceFlow?: boolean; + installationScopes?: string[]; + installationRedirectUrl?: string; + }): Promise; /** * Update an application by its unique ID. * @@ -418,15 +547,125 @@ export class Apps { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(appId: string, name: string, description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, enabled?: boolean, redirectUris?: string[], postLogoutRedirectUris?: string[], type?: string, deviceFlow?: boolean, installationScopes?: string[], installationRedirectUrl?: string): Promise; update( - paramsOrFirst: { appId: string, name: string, description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, enabled?: boolean, redirectUris?: string[], postLogoutRedirectUris?: string[], type?: string, deviceFlow?: boolean, installationScopes?: string[], installationRedirectUrl?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string[])?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (boolean)?, (string[])?, (string[])?, (string)?, (boolean)?, (string[])?, (string)?] + appId: string, + name: string, + description?: string, + clientUri?: string, + logoUri?: string, + privacyPolicyUrl?: string, + termsUrl?: string, + contacts?: string[], + tagline?: string, + tags?: string[], + images?: string[], + supportUrl?: string, + dataDeletionUrl?: string, + enabled?: boolean, + redirectUris?: string[], + postLogoutRedirectUris?: string[], + type?: string, + deviceFlow?: boolean, + installationScopes?: string[], + installationRedirectUrl?: string, + ): Promise; + update( + paramsOrFirst: + | { + appId: string; + name: string; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + enabled?: boolean; + redirectUris?: string[]; + postLogoutRedirectUris?: string[]; + type?: string; + deviceFlow?: boolean; + installationScopes?: string[]; + installationRedirectUrl?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + string[]?, + string?, + string[]?, + string[]?, + string?, + string?, + boolean?, + string[]?, + string[]?, + string?, + boolean?, + string[]?, + string?, + ] ): Promise { - let params: { appId: string, name: string, description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, enabled?: boolean, redirectUris?: string[], postLogoutRedirectUris?: string[], type?: string, deviceFlow?: boolean, installationScopes?: string[], installationRedirectUrl?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, name: string, description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, enabled?: boolean, redirectUris?: string[], postLogoutRedirectUris?: string[], type?: string, deviceFlow?: boolean, installationScopes?: string[], installationRedirectUrl?: string }; + let params: { + appId: string; + name: string; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + enabled?: boolean; + redirectUris?: string[]; + postLogoutRedirectUris?: string[]; + type?: string; + deviceFlow?: boolean; + installationScopes?: string[]; + installationRedirectUrl?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + name: string; + description?: string; + clientUri?: string; + logoUri?: string; + privacyPolicyUrl?: string; + termsUrl?: string; + contacts?: string[]; + tagline?: string; + tags?: string[]; + images?: string[]; + supportUrl?: string; + dataDeletionUrl?: string; + enabled?: boolean; + redirectUris?: string[]; + postLogoutRedirectUris?: string[]; + type?: string; + deviceFlow?: boolean; + installationScopes?: string[]; + installationRedirectUrl?: string; + }; } else { params = { appId: paramsOrFirst as string, @@ -448,10 +687,10 @@ export class Apps { type: rest[15] as string, deviceFlow: rest[16] as boolean, installationScopes: rest[17] as string[], - installationRedirectUrl: rest[18] as string + installationRedirectUrl: rest[18] as string, }; } - + const appId = params.appId; const name = params.name; const description = params.description; @@ -472,87 +711,83 @@ export class Apps { const deviceFlow = params.deviceFlow; const installationScopes = params.installationScopes; const installationRedirectUrl = params.installationRedirectUrl; - if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/apps/{appId}'.replace('{appId}', encodeURIComponent(String(appId))); - const payload: Payload = {}; + const apiPath = '/apps/{appId}'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof description !== 'undefined') { - payload['description'] = description; + apiPayload['description'] = description; } if (typeof clientUri !== 'undefined') { - payload['clientUri'] = clientUri; + apiPayload['clientUri'] = clientUri; } if (typeof logoUri !== 'undefined') { - payload['logoUri'] = logoUri; + apiPayload['logoUri'] = logoUri; } if (typeof privacyPolicyUrl !== 'undefined') { - payload['privacyPolicyUrl'] = privacyPolicyUrl; + apiPayload['privacyPolicyUrl'] = privacyPolicyUrl; } if (typeof termsUrl !== 'undefined') { - payload['termsUrl'] = termsUrl; + apiPayload['termsUrl'] = termsUrl; } if (typeof contacts !== 'undefined') { - payload['contacts'] = contacts; + apiPayload['contacts'] = contacts; } if (typeof tagline !== 'undefined') { - payload['tagline'] = tagline; + apiPayload['tagline'] = tagline; } if (typeof tags !== 'undefined') { - payload['tags'] = tags; + apiPayload['tags'] = tags; } if (typeof images !== 'undefined') { - payload['images'] = images; + apiPayload['images'] = images; } if (typeof supportUrl !== 'undefined') { - payload['supportUrl'] = supportUrl; + apiPayload['supportUrl'] = supportUrl; } if (typeof dataDeletionUrl !== 'undefined') { - payload['dataDeletionUrl'] = dataDeletionUrl; + apiPayload['dataDeletionUrl'] = dataDeletionUrl; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof redirectUris !== 'undefined') { - payload['redirectUris'] = redirectUris; + apiPayload['redirectUris'] = redirectUris; } if (typeof postLogoutRedirectUris !== 'undefined') { - payload['postLogoutRedirectUris'] = postLogoutRedirectUris; + apiPayload['postLogoutRedirectUris'] = postLogoutRedirectUris; } if (typeof type !== 'undefined') { - payload['type'] = type; + apiPayload['type'] = type; } if (typeof deviceFlow !== 'undefined') { - payload['deviceFlow'] = deviceFlow; + apiPayload['deviceFlow'] = deviceFlow; } if (typeof installationScopes !== 'undefined') { - payload['installationScopes'] = installationScopes; + apiPayload['installationScopes'] = installationScopes; } if (typeof installationRedirectUrl !== 'undefined') { - payload['installationRedirectUrl'] = installationRedirectUrl; + apiPayload['installationRedirectUrl'] = installationRedirectUrl; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -572,41 +807,39 @@ export class Apps { * @deprecated Use the object parameter style method for a better developer experience. */ delete(appId: string): Promise<{}>; - delete( - paramsOrFirst: { appId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { appId: string } | string): Promise<{}> { let params: { appId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { appId: string }; } else { params = { - appId: paramsOrFirst as string + appId: paramsOrFirst as string, }; } - - const appId = params.appId; + const appId = params.appId; if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}'.replace('{appId}', encodeURIComponent(String(appId))); - const payload: Payload = {}; + const apiPath = '/apps/{appId}'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -618,7 +851,11 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - listInstallations(params: { appId: string, queries?: string[], total?: boolean }): Promise; + listInstallations(params: { + appId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List installations of an application. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header, or a caller with update access to the app. * @@ -629,52 +866,61 @@ export class Apps { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listInstallations(appId: string, queries?: string[], total?: boolean): Promise; listInstallations( - paramsOrFirst: { appId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + appId: string, + queries?: string[], + total?: boolean, + ): Promise; + listInstallations( + paramsOrFirst: + { appId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { appId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, queries?: string[], total?: boolean }; + let params: { appId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { appId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const appId = params.appId; const queries = params.queries; const total = params.total; - if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}/installations'.replace('{appId}', encodeURIComponent(String(appId))); - const payload: Payload = {}; + const apiPath = '/apps/{appId}/installations'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -685,7 +931,10 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - getInstallation(params: { appId: string, installationId: string }): Promise; + getInstallation(params: { + appId: string; + installationId: string; + }): Promise; /** * Get an installation of an application by its unique ID. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header, or a caller with update access to the app. * @@ -695,47 +944,57 @@ export class Apps { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getInstallation(appId: string, installationId: string): Promise; getInstallation( - paramsOrFirst: { appId: string, installationId: string } | string, - ...rest: [(string)?] + appId: string, + installationId: string, + ): Promise; + getInstallation( + paramsOrFirst: { appId: string; installationId: string } | string, + ...rest: [string?] ): Promise { - let params: { appId: string, installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, installationId: string }; + let params: { appId: string; installationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + installationId: string; + }; } else { params = { appId: paramsOrFirst as string, - installationId: rest[0] as string + installationId: rest[0] as string, }; } - + const appId = params.appId; const installationId = params.installationId; - if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); - } - - const apiPath = '/apps/{appId}/installations/{installationId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{installationId}', encodeURIComponent(String(installationId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); + } + const apiPath = '/apps/{appId}/installations/{installationId}' + .replace('{appId}', encodeURIComponent(String(appId))) + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -746,7 +1005,10 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteInstallation(params: { appId: string, installationId: string }): Promise<{}>; + deleteInstallation(params: { + appId: string; + installationId: string; + }): Promise<{}>; /** * Delete an installation of an application by its unique ID. Requires a caller with update access to the app. Previously issued installation access tokens are revoked. * @@ -758,46 +1020,53 @@ export class Apps { */ deleteInstallation(appId: string, installationId: string): Promise<{}>; deleteInstallation( - paramsOrFirst: { appId: string, installationId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { appId: string; installationId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { appId: string, installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, installationId: string }; + let params: { appId: string; installationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + installationId: string; + }; } else { params = { appId: paramsOrFirst as string, - installationId: rest[0] as string + installationId: rest[0] as string, }; } - + const appId = params.appId; const installationId = params.installationId; - if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); - } - - const apiPath = '/apps/{appId}/installations/{installationId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{installationId}', encodeURIComponent(String(installationId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); + } + const apiPath = '/apps/{appId}/installations/{installationId}' + .replace('{appId}', encodeURIComponent(String(appId))) + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -808,7 +1077,10 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - createInstallationToken(params: { appId: string, installationId: string }): Promise; + createInstallationToken(params: { + appId: string; + installationId: string; + }): Promise; /** * Create a token for an installation of an application. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header, or a caller with update access to the app. The returned token carries the scopes and authorization details granted to the installation, and can be used as an `Authorization: Bearer` header everywhere OAuth2 access tokens are accepted. Multiple tokens can be active for the same installation at once; each token stays valid until it expires or the installation is updated or deleted. * @@ -818,48 +1090,58 @@ export class Apps { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createInstallationToken(appId: string, installationId: string): Promise; createInstallationToken( - paramsOrFirst: { appId: string, installationId: string } | string, - ...rest: [(string)?] + appId: string, + installationId: string, + ): Promise; + createInstallationToken( + paramsOrFirst: { appId: string; installationId: string } | string, + ...rest: [string?] ): Promise { - let params: { appId: string, installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, installationId: string }; + let params: { appId: string; installationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + installationId: string; + }; } else { params = { appId: paramsOrFirst as string, - installationId: rest[0] as string + installationId: rest[0] as string, }; } - + const appId = params.appId; const installationId = params.installationId; - if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); - } - - const apiPath = '/apps/{appId}/installations/{installationId}/tokens'.replace('{appId}', encodeURIComponent(String(appId))).replace('{installationId}', encodeURIComponent(String(installationId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); + } + const apiPath = '/apps/{appId}/installations/{installationId}/tokens' + .replace('{appId}', encodeURIComponent(String(appId))) + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -871,7 +1153,11 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - listKeys(params: { appId: string, queries?: string[], total?: boolean }): Promise; + listKeys(params: { + appId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List app keys for an application. * @@ -882,52 +1168,61 @@ export class Apps { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listKeys(appId: string, queries?: string[], total?: boolean): Promise; listKeys( - paramsOrFirst: { appId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + appId: string, + queries?: string[], + total?: boolean, + ): Promise; + listKeys( + paramsOrFirst: + { appId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { appId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, queries?: string[], total?: boolean }; + let params: { appId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { appId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const appId = params.appId; const queries = params.queries; const total = params.total; - if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}/keys'.replace('{appId}', encodeURIComponent(String(appId))); - const payload: Payload = {}; + const apiPath = '/apps/{appId}/keys'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -948,40 +1243,40 @@ export class Apps { */ createKey(appId: string): Promise; createKey( - paramsOrFirst: { appId: string } | string + paramsOrFirst: { appId: string } | string, ): Promise { let params: { appId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { appId: string }; } else { params = { - appId: paramsOrFirst as string + appId: paramsOrFirst as string, }; } - - const appId = params.appId; + const appId = params.appId; if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}/keys'.replace('{appId}', encodeURIComponent(String(appId))); - const payload: Payload = {}; + const apiPath = '/apps/{appId}/keys'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -992,7 +1287,7 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - getKey(params: { appId: string, keyId: string }): Promise; + getKey(params: { appId: string; keyId: string }): Promise; /** * Get an app key by its unique ID. * @@ -1004,45 +1299,44 @@ export class Apps { */ getKey(appId: string, keyId: string): Promise; getKey( - paramsOrFirst: { appId: string, keyId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { appId: string; keyId: string } | string, + ...rest: [string?] ): Promise { - let params: { appId: string, keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, keyId: string }; + let params: { appId: string; keyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { appId: string; keyId: string }; } else { params = { appId: paramsOrFirst as string, - keyId: rest[0] as string + keyId: rest[0] as string, }; } - + const appId = params.appId; const keyId = params.keyId; - if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } if (typeof keyId === 'undefined') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/apps/{appId}/keys/{keyId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{keyId}', encodeURIComponent(String(keyId))); - const payload: Payload = {}; + const apiPath = '/apps/{appId}/keys/{keyId}' + .replace('{appId}', encodeURIComponent(String(appId))) + .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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1053,7 +1347,7 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteKey(params: { appId: string, keyId: string }): Promise<{}>; + deleteKey(params: { appId: string; keyId: string }): Promise<{}>; /** * Delete an app key by its unique ID. * @@ -1065,46 +1359,45 @@ export class Apps { */ deleteKey(appId: string, keyId: string): Promise<{}>; deleteKey( - paramsOrFirst: { appId: string, keyId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { appId: string; keyId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { appId: string, keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, keyId: string }; + let params: { appId: string; keyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { appId: string; keyId: string }; } else { params = { appId: paramsOrFirst as string, - keyId: rest[0] as string + keyId: rest[0] as string, }; } - + const appId = params.appId; const keyId = params.keyId; - if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } if (typeof keyId === 'undefined') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/apps/{appId}/keys/{keyId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{keyId}', encodeURIComponent(String(keyId))); - const payload: Payload = {}; + const apiPath = '/apps/{appId}/keys/{keyId}' + .replace('{appId}', encodeURIComponent(String(appId))) + .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', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1115,7 +1408,10 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - updateLabels(params: { appId: string, labels: string[] }): Promise; + updateLabels(params: { + appId: string; + labels: string[]; + }): Promise; /** * Update the labels of an application. Labels are read-only for clients; only a server SDK using a project API key can set them. Replaces the previous labels. * @@ -1127,49 +1423,52 @@ export class Apps { */ updateLabels(appId: string, labels: string[]): Promise; updateLabels( - paramsOrFirst: { appId: string, labels: string[] } | string, - ...rest: [(string[])?] + paramsOrFirst: { appId: string; labels: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { appId: string, labels: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, labels: string[] }; + let params: { appId: string; labels: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + labels: string[]; + }; } else { params = { appId: paramsOrFirst as string, - labels: rest[0] as string[] + labels: rest[0] as string[], }; } - + const appId = params.appId; const labels = params.labels; - if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } if (typeof labels === 'undefined') { throw new AppwriteException('Missing required parameter: "labels"'); } - - const apiPath = '/apps/{appId}/labels'.replace('{appId}', encodeURIComponent(String(appId))); - const payload: Payload = {}; + const apiPath = '/apps/{appId}/labels'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); + const apiPayload: Payload = {}; if (typeof labels !== 'undefined') { - payload['labels'] = labels; + apiPayload['labels'] = labels; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1181,7 +1480,11 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - listSecrets(params: { appId: string, queries?: string[], total?: boolean }): Promise; + listSecrets(params: { + appId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List client secrets for an application. * @@ -1192,52 +1495,61 @@ export class Apps { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listSecrets(appId: string, queries?: string[], total?: boolean): Promise; listSecrets( - paramsOrFirst: { appId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + appId: string, + queries?: string[], + total?: boolean, + ): Promise; + listSecrets( + paramsOrFirst: + { appId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { appId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, queries?: string[], total?: boolean }; + let params: { appId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { appId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const appId = params.appId; const queries = params.queries; const total = params.total; - if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}/secrets'.replace('{appId}', encodeURIComponent(String(appId))); - const payload: Payload = {}; + const apiPath = '/apps/{appId}/secrets'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1258,40 +1570,40 @@ export class Apps { */ createSecret(appId: string): Promise; createSecret( - paramsOrFirst: { appId: string } | string + paramsOrFirst: { appId: string } | string, ): Promise { let params: { appId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { appId: string }; } else { params = { - appId: paramsOrFirst as string + appId: paramsOrFirst as string, }; } - - const appId = params.appId; + const appId = params.appId; if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}/secrets'.replace('{appId}', encodeURIComponent(String(appId))); - const payload: Payload = {}; + const apiPath = '/apps/{appId}/secrets'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1302,7 +1614,10 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - getSecret(params: { appId: string, secretId: string }): Promise; + getSecret(params: { + appId: string; + secretId: string; + }): Promise; /** * Get an application client secret by its unique ID. * @@ -1314,45 +1629,49 @@ export class Apps { */ getSecret(appId: string, secretId: string): Promise; getSecret( - paramsOrFirst: { appId: string, secretId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { appId: string; secretId: string } | string, + ...rest: [string?] ): Promise { - let params: { appId: string, secretId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, secretId: string }; + let params: { appId: string; secretId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + secretId: string; + }; } else { params = { appId: paramsOrFirst as string, - secretId: rest[0] as string + secretId: rest[0] as string, }; } - + const appId = params.appId; const secretId = params.secretId; - if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } if (typeof secretId === 'undefined') { - throw new AppwriteException('Missing required parameter: "secretId"'); - } - - const apiPath = '/apps/{appId}/secrets/{secretId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{secretId}', encodeURIComponent(String(secretId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "secretId"', + ); + } + const apiPath = '/apps/{appId}/secrets/{secretId}' + .replace('{appId}', encodeURIComponent(String(appId))) + .replace('{secretId}', encodeURIComponent(String(secretId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1363,7 +1682,7 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteSecret(params: { appId: string, secretId: string }): Promise<{}>; + deleteSecret(params: { appId: string; secretId: string }): Promise<{}>; /** * Delete an application client secret by its unique ID. * @@ -1375,46 +1694,50 @@ export class Apps { */ deleteSecret(appId: string, secretId: string): Promise<{}>; deleteSecret( - paramsOrFirst: { appId: string, secretId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { appId: string; secretId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { appId: string, secretId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, secretId: string }; + let params: { appId: string; secretId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + secretId: string; + }; } else { params = { appId: paramsOrFirst as string, - secretId: rest[0] as string + secretId: rest[0] as string, }; } - + const appId = params.appId; const secretId = params.secretId; - if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } if (typeof secretId === 'undefined') { - throw new AppwriteException('Missing required parameter: "secretId"'); - } - - const apiPath = '/apps/{appId}/secrets/{secretId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{secretId}', encodeURIComponent(String(secretId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "secretId"', + ); + } + const apiPath = '/apps/{appId}/secrets/{secretId}' + .replace('{appId}', encodeURIComponent(String(appId))) + .replace('{secretId}', encodeURIComponent(String(secretId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1425,7 +1748,7 @@ export class Apps { * @throws {AppwriteException} * @returns {Promise} */ - updateTeam(params: { appId: string, teamId: string }): Promise; + updateTeam(params: { appId: string; teamId: string }): Promise; /** * Transfer an application to another team by its unique ID. * @@ -1437,49 +1760,49 @@ export class Apps { */ updateTeam(appId: string, teamId: string): Promise; updateTeam( - paramsOrFirst: { appId: string, teamId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { appId: string; teamId: string } | string, + ...rest: [string?] ): Promise { - let params: { appId: string, teamId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, teamId: string }; + let params: { appId: string; teamId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { appId: string; teamId: string }; } else { params = { appId: paramsOrFirst as string, - teamId: rest[0] as string + teamId: rest[0] as string, }; } - + const appId = params.appId; const teamId = params.teamId; - if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } - - const apiPath = '/apps/{appId}/team'.replace('{appId}', encodeURIComponent(String(appId))); - const payload: Payload = {}; + const apiPath = '/apps/{appId}/team'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); + const apiPayload: Payload = {}; if (typeof teamId !== 'undefined') { - payload['teamId'] = teamId; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1499,40 +1822,38 @@ export class Apps { * @deprecated Use the object parameter style method for a better developer experience. */ deleteTokens(appId: string): Promise<{}>; - deleteTokens( - paramsOrFirst: { appId: string } | string - ): Promise<{}> { + deleteTokens(paramsOrFirst: { appId: string } | string): Promise<{}> { let params: { appId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { appId: string }; } else { params = { - appId: paramsOrFirst as string + appId: paramsOrFirst as string, }; } - - const appId = params.appId; + const appId = params.appId; if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/apps/{appId}/tokens'.replace('{appId}', encodeURIComponent(String(appId))); - const payload: Payload = {}; + const apiPath = '/apps/{appId}/tokens'.replace( + '{appId}', + encodeURIComponent(String(appId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } } diff --git a/src/services/avatars.ts b/src/services/avatars.ts index d6914c0b..2ffb0dac 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -1,6 +1,4 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; -import type { Models } from '../models'; - +import { AppwriteException, Client, type Payload } from '../client'; import { Browser } from '../enums/browser'; import { CreditCard } from '../enums/credit-card'; @@ -9,7 +7,6 @@ import { BrowserTheme } from '../enums/browser-theme'; import { Timezone } from '../enums/timezone'; import { BrowserPermission } from '../enums/browser-permission'; import { ImageFormat } from '../enums/image-format'; - export class Avatars { client: Client; @@ -19,7 +16,7 @@ export class Avatars { /** * You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user [GET /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) endpoint. Use width, height and quality arguments to change the output settings. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. * * @param {Browser} params.code - Browser Code. @@ -29,10 +26,15 @@ export class Avatars { * @throws {AppwriteException} * @returns {Promise} */ - getBrowser(params: { code: Browser, width?: number, height?: number, quality?: number }): Promise; + getBrowser(params: { + code: Browser; + width?: number; + height?: number; + quality?: number; + }): Promise; /** * You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user [GET /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) endpoint. Use width, height and quality arguments to change the output settings. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. * * @param {Browser} code - Browser Code. @@ -43,65 +45,96 @@ export class Avatars { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getBrowser(code: Browser, width?: number, height?: number, quality?: number): Promise; getBrowser( - paramsOrFirst: { code: Browser, width?: number, height?: number, quality?: number } | Browser, - ...rest: [(number)?, (number)?, (number)?] + code: Browser, + width?: number, + height?: number, + quality?: number, + ): Promise; + getBrowser( + paramsOrFirst: + | { + code: Browser; + width?: number; + height?: number; + quality?: number; + } + | Browser, + ...rest: [number?, number?, number?] ): Promise { - let params: { code: Browser, width?: number, height?: number, quality?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { code: Browser, width?: number, height?: number, quality?: number }; + let params: { + code: Browser; + width?: number; + height?: number; + quality?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('code' in paramsOrFirst || + 'width' in paramsOrFirst || + 'height' in paramsOrFirst || + 'quality' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + code: Browser; + width?: number; + height?: number; + quality?: number; + }; } else { params = { code: paramsOrFirst as Browser, width: rest[0] as number, height: rest[1] as number, - quality: rest[2] as number + quality: rest[2] as number, }; } - + const code = params.code; const width = params.width; const height = params.height; const quality = params.quality; - if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } - - const apiPath = '/avatars/browsers/{code}'.replace('{code}', encodeURIComponent(String(code))); - const payload: Payload = {}; + const apiPath = '/avatars/browsers/{code}'.replace( + '{code}', + encodeURIComponent(String(code)), + ); + const apiPayload: Payload = {}; if (typeof width !== 'undefined') { - payload['width'] = width; + apiPayload['width'] = width; } if (typeof height !== 'undefined') { - payload['height'] = height; + apiPayload['height'] = height; } if (typeof quality !== 'undefined') { - payload['quality'] = quality; + apiPayload['quality'] = quality; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/png', - } + accept: 'image/png', + }; return this.client.call( 'get', uri, apiHeaders, - payload, - 'arrayBuffer' + apiPayload, + 'arrayBuffer', ); } /** * The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. - * + * * * @param {CreditCard} params.code - Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, unionpay, visa, mir, maestro, rupay. * @param {number} params.width - Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -110,12 +143,17 @@ export class Avatars { * @throws {AppwriteException} * @returns {Promise} */ - getCreditCard(params: { code: CreditCard, width?: number, height?: number, quality?: number }): Promise; + getCreditCard(params: { + code: CreditCard; + width?: number; + height?: number; + quality?: number; + }): Promise; /** * The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. - * + * * * @param {CreditCard} code - Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, unionpay, visa, mir, maestro, rupay. * @param {number} width - Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -125,63 +163,94 @@ export class Avatars { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getCreditCard(code: CreditCard, width?: number, height?: number, quality?: number): Promise; getCreditCard( - paramsOrFirst: { code: CreditCard, width?: number, height?: number, quality?: number } | CreditCard, - ...rest: [(number)?, (number)?, (number)?] + code: CreditCard, + width?: number, + height?: number, + quality?: number, + ): Promise; + getCreditCard( + paramsOrFirst: + | { + code: CreditCard; + width?: number; + height?: number; + quality?: number; + } + | CreditCard, + ...rest: [number?, number?, number?] ): Promise { - let params: { code: CreditCard, width?: number, height?: number, quality?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { code: CreditCard, width?: number, height?: number, quality?: number }; + let params: { + code: CreditCard; + width?: number; + height?: number; + quality?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('code' in paramsOrFirst || + 'width' in paramsOrFirst || + 'height' in paramsOrFirst || + 'quality' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + code: CreditCard; + width?: number; + height?: number; + quality?: number; + }; } else { params = { code: paramsOrFirst as CreditCard, width: rest[0] as number, height: rest[1] as number, - quality: rest[2] as number + quality: rest[2] as number, }; } - + const code = params.code; const width = params.width; const height = params.height; const quality = params.quality; - if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } - - const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', encodeURIComponent(String(code))); - const payload: Payload = {}; + const apiPath = '/avatars/credit-cards/{code}'.replace( + '{code}', + encodeURIComponent(String(code)), + ); + const apiPayload: Payload = {}; if (typeof width !== 'undefined') { - payload['width'] = width; + apiPayload['width'] = width; } if (typeof height !== 'undefined') { - payload['height'] = height; + apiPayload['height'] = height; } if (typeof quality !== 'undefined') { - payload['quality'] = quality; + apiPayload['quality'] = quality; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/png', - } + accept: 'image/png', + }; return this.client.call( 'get', uri, apiHeaders, - payload, - 'arrayBuffer' + apiPayload, + 'arrayBuffer', ); } /** * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL. - * + * * This endpoint does not follow HTTP redirects. * * @param {string} params.url - Website URL which you want to fetch the favicon from. @@ -191,7 +260,7 @@ export class Avatars { getFavicon(params: { url: string }): Promise; /** * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL. - * + * * This endpoint does not follow HTTP redirects. * * @param {string} url - Website URL which you want to fetch the favicon from. @@ -200,51 +269,51 @@ export class Avatars { * @deprecated Use the object parameter style method for a better developer experience. */ getFavicon(url: string): Promise; - getFavicon( - paramsOrFirst: { url: string } | string - ): Promise { + getFavicon(paramsOrFirst: { url: string } | string): Promise { let params: { url: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { url: string }; } else { params = { - url: paramsOrFirst as string + url: paramsOrFirst as string, }; } - - const url = params.url; + const url = params.url; if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } - const apiPath = '/avatars/favicon'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof url !== 'undefined') { - payload['url'] = url; + apiPayload['url'] = url; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/*', - } + accept: 'image/*', + }; return this.client.call( 'get', uri, apiHeaders, - payload, - 'arrayBuffer' + apiPayload, + 'arrayBuffer', ); } /** * You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. Country codes follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. - * + * * * @param {Flag} params.code - Country Code. ISO Alpha-2 country code format. * @param {number} params.width - Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -253,12 +322,17 @@ export class Avatars { * @throws {AppwriteException} * @returns {Promise} */ - getFlag(params: { code: Flag, width?: number, height?: number, quality?: number }): Promise; + getFlag(params: { + code: Flag; + width?: number; + height?: number; + quality?: number; + }): Promise; /** * You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. Country codes follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. - * + * * * @param {Flag} code - Country Code. ISO Alpha-2 country code format. * @param {number} width - Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -268,65 +342,91 @@ export class Avatars { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getFlag(code: Flag, width?: number, height?: number, quality?: number): Promise; getFlag( - paramsOrFirst: { code: Flag, width?: number, height?: number, quality?: number } | Flag, - ...rest: [(number)?, (number)?, (number)?] + code: Flag, + width?: number, + height?: number, + quality?: number, + ): Promise; + getFlag( + paramsOrFirst: + | { code: Flag; width?: number; height?: number; quality?: number } + | Flag, + ...rest: [number?, number?, number?] ): Promise { - let params: { code: Flag, width?: number, height?: number, quality?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { code: Flag, width?: number, height?: number, quality?: number }; + let params: { + code: Flag; + width?: number; + height?: number; + quality?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('code' in paramsOrFirst || + 'width' in paramsOrFirst || + 'height' in paramsOrFirst || + 'quality' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + code: Flag; + width?: number; + height?: number; + quality?: number; + }; } else { params = { code: paramsOrFirst as Flag, width: rest[0] as number, height: rest[1] as number, - quality: rest[2] as number + quality: rest[2] as number, }; } - + const code = params.code; const width = params.width; const height = params.height; const quality = params.quality; - if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } - - const apiPath = '/avatars/flags/{code}'.replace('{code}', encodeURIComponent(String(code))); - const payload: Payload = {}; + const apiPath = '/avatars/flags/{code}'.replace( + '{code}', + encodeURIComponent(String(code)), + ); + const apiPayload: Payload = {}; if (typeof width !== 'undefined') { - payload['width'] = width; + apiPayload['width'] = width; } if (typeof height !== 'undefined') { - payload['height'] = height; + apiPayload['height'] = height; } if (typeof quality !== 'undefined') { - payload['quality'] = quality; + apiPayload['quality'] = quality; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/png', - } + accept: 'image/png', + }; return this.client.call( 'get', uri, apiHeaders, - payload, - 'arrayBuffer' + apiPayload, + 'arrayBuffer', ); } /** * Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 400x400px. - * + * * This endpoint does not follow HTTP redirects. * * @param {string} params.url - Image URL which you want to crop. @@ -335,12 +435,16 @@ export class Avatars { * @throws {AppwriteException} * @returns {Promise} */ - getImage(params: { url: string, width?: number, height?: number }): Promise; + getImage(params: { + url: string; + width?: number; + height?: number; + }): Promise; /** * Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 400x400px. - * + * * This endpoint does not follow HTTP redirects. * * @param {string} url - Image URL which you want to crop. @@ -350,65 +454,76 @@ export class Avatars { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getImage(url: string, width?: number, height?: number): Promise; getImage( - paramsOrFirst: { url: string, width?: number, height?: number } | string, - ...rest: [(number)?, (number)?] + url: string, + width?: number, + height?: number, + ): Promise; + getImage( + paramsOrFirst: + { url: string; width?: number; height?: number } | string, + ...rest: [number?, number?] ): Promise { - let params: { url: string, width?: number, height?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { url: string, width?: number, height?: number }; + let params: { url: string; width?: number; height?: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + url: string; + width?: number; + height?: number; + }; } else { params = { url: paramsOrFirst as string, width: rest[0] as number, - height: rest[1] as number + height: rest[1] as number, }; } - + const url = params.url; const width = params.width; const height = params.height; - if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } - const apiPath = '/avatars/image'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof url !== 'undefined') { - payload['url'] = url; + apiPayload['url'] = url; } if (typeof width !== 'undefined') { - payload['width'] = width; + apiPayload['width'] = width; } if (typeof height !== 'undefined') { - payload['height'] = height; + apiPayload['height'] = height; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/*', - } + accept: 'image/*', + }; return this.client.call( 'get', uri, apiHeaders, - payload, - 'arrayBuffer' + apiPayload, + 'arrayBuffer', ); } /** * Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. - * + * * You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. - * + * * * @param {string} params.name - Full Name. When empty, current user name or email will be used. Max length: 128 chars. * @param {number} params.width - Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -417,14 +532,19 @@ export class Avatars { * @throws {AppwriteException} * @returns {Promise} */ - getInitials(params?: { name?: string, width?: number, height?: number, background?: string }): Promise; + getInitials(params?: { + name?: string; + width?: number; + height?: number; + background?: string; + }): Promise; /** * Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. - * + * * You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials. - * + * * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. - * + * * * @param {string} name - Full Name. When empty, current user name or email will be used. Max length: 128 chars. * @param {number} width - Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -434,63 +554,246 @@ export class Avatars { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getInitials(name?: string, width?: number, height?: number, background?: string): Promise; getInitials( - paramsOrFirst?: { name?: string, width?: number, height?: number, background?: string } | string, - ...rest: [(number)?, (number)?, (string)?] + name?: string, + width?: number, + height?: number, + background?: string, + ): Promise; + getInitials( + paramsOrFirst?: + | { + name?: string; + width?: number; + height?: number; + background?: string; + } + | string, + ...rest: [number?, number?, string?] ): Promise { - let params: { name?: string, width?: number, height?: number, background?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { name?: string, width?: number, height?: number, background?: string }; + let params: { + name?: string; + width?: number; + height?: number; + background?: string; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + name?: string; + width?: number; + height?: number; + background?: string; + }; } else { params = { name: paramsOrFirst as string, width: rest[0] as number, height: rest[1] as number, - background: rest[2] as string + background: rest[2] as string, }; } - + const name = params.name; const width = params.width; const height = params.height; const background = params.background; - - const apiPath = '/avatars/initials'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof width !== 'undefined') { - payload['width'] = width; + apiPayload['width'] = width; } if (typeof height !== 'undefined') { - payload['height'] = height; + apiPayload['height'] = height; } if (typeof background !== 'undefined') { - payload['background'] = background; + apiPayload['background'] = background; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/png', + accept: 'image/png', + }; + + return this.client.call( + 'get', + uri, + apiHeaders, + apiPayload, + 'arrayBuffer', + ); + } + + /** + * Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback. + * + * The photo resolves for the currently authenticated user unless `userId` points at another user. Passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the user's own identity photos, email, and name leave the chain so they never shadow the avatar being asked for. Emails are only ever accepted pre-hashed, so no address ends up in a URL. + * + * @param {number} params.width - Output image width in pixels. Pass an integer between 0 and 2000. Defaults to 256. + * @param {number} params.height - Output image height in pixels. Pass an integer between 0 and 2000. Defaults to 256. + * @param {number} params.quality - Output image quality between 0 and 100. Defaults to 100. + * @param {string} params.output - Output image format. Defaults to 'png'. + * @param {string} params.rating - Maximum image rating to fetch from Gravatar/Libravatar. Defaults to 'g'. + * @param {string} params.userId - User ID to resolve the photo for. Defaults to 'current()' for the currently authenticated user. + * @param {string} params.emailHash - SHA256 hash of the lowercase, trimmed email address to look up on Gravatar and Libravatar instead of the user's own photo sources. Pass the hash, never the address itself. + * @param {string} params.name - Name to render initials from instead of the user's own photo sources. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPhoto(params?: { + width?: number; + height?: number; + quality?: number; + output?: string; + rating?: string; + userId?: string; + emailHash?: string; + name?: string; + }): Promise; + /** + * Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback. + * + * The photo resolves for the currently authenticated user unless `userId` points at another user. Passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the user's own identity photos, email, and name leave the chain so they never shadow the avatar being asked for. Emails are only ever accepted pre-hashed, so no address ends up in a URL. + * + * @param {number} width - Output image width in pixels. Pass an integer between 0 and 2000. Defaults to 256. + * @param {number} height - Output image height in pixels. Pass an integer between 0 and 2000. Defaults to 256. + * @param {number} quality - Output image quality between 0 and 100. Defaults to 100. + * @param {string} output - Output image format. Defaults to 'png'. + * @param {string} rating - Maximum image rating to fetch from Gravatar/Libravatar. Defaults to 'g'. + * @param {string} userId - User ID to resolve the photo for. Defaults to 'current()' for the currently authenticated user. + * @param {string} emailHash - SHA256 hash of the lowercase, trimmed email address to look up on Gravatar and Libravatar instead of the user's own photo sources. Pass the hash, never the address itself. + * @param {string} name - Name to render initials from instead of the user's own photo sources. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPhoto( + width?: number, + height?: number, + quality?: number, + output?: string, + rating?: string, + userId?: string, + emailHash?: string, + name?: string, + ): Promise; + getPhoto( + paramsOrFirst?: + | { + width?: number; + height?: number; + quality?: number; + output?: string; + rating?: string; + userId?: string; + emailHash?: string; + name?: string; + } + | number, + ...rest: [number?, number?, string?, string?, string?, string?, string?] + ): Promise { + let params: { + width?: number; + height?: number; + quality?: number; + output?: string; + rating?: string; + userId?: string; + emailHash?: string; + name?: string; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + width?: number; + height?: number; + quality?: number; + output?: string; + rating?: string; + userId?: string; + emailHash?: string; + name?: string; + }; + } else { + params = { + width: paramsOrFirst as number, + height: rest[0] as number, + quality: rest[1] as number, + output: rest[2] as string, + rating: rest[3] as string, + userId: rest[4] as string, + emailHash: rest[5] as string, + name: rest[6] as string, + }; } + const width = params.width; + const height = params.height; + const quality = params.quality; + const output = params.output; + const rating = params.rating; + const userId = params.userId; + const emailHash = params.emailHash; + const name = params.name; + const apiPath = '/avatars/photo'; + const apiPayload: Payload = {}; + if (typeof width !== 'undefined') { + apiPayload['width'] = width; + } + if (typeof height !== 'undefined') { + apiPayload['height'] = height; + } + if (typeof quality !== 'undefined') { + apiPayload['quality'] = quality; + } + if (typeof output !== 'undefined') { + apiPayload['output'] = output; + } + if (typeof rating !== 'undefined') { + apiPayload['rating'] = rating; + } + if (typeof userId !== 'undefined') { + apiPayload['userId'] = userId; + } + if (typeof emailHash !== 'undefined') { + apiPayload['emailHash'] = emailHash; + } + 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, + accept: 'image/*', + }; + return this.client.call( 'get', uri, apiHeaders, - payload, - 'arrayBuffer' + apiPayload, + 'arrayBuffer', ); } /** * 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. - * + * * * @param {string} params.text - Plain text to be converted to QR code image. * @param {number} params.size - QR code size. Pass an integer between 1 to 1000. Defaults to 400. @@ -499,10 +802,15 @@ export class Avatars { * @throws {AppwriteException} * @returns {Promise} */ - getQR(params: { text: string, size?: number, margin?: number, download?: boolean }): Promise; + getQR(params: { + text: string; + size?: number; + margin?: number; + download?: boolean; + }): Promise; /** * 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. - * + * * * @param {string} text - Plain text to be converted to QR code image. * @param {number} size - QR code size. Pass an integer between 1 to 1000. Defaults to 400. @@ -512,68 +820,92 @@ export class Avatars { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getQR(text: string, size?: number, margin?: number, download?: boolean): Promise; getQR( - paramsOrFirst: { text: string, size?: number, margin?: number, download?: boolean } | string, - ...rest: [(number)?, (number)?, (boolean)?] + text: string, + size?: number, + margin?: number, + download?: boolean, + ): Promise; + getQR( + paramsOrFirst: + | { + text: string; + size?: number; + margin?: number; + download?: boolean; + } + | string, + ...rest: [number?, number?, boolean?] ): Promise { - let params: { text: string, size?: number, margin?: number, download?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { text: string, size?: number, margin?: number, download?: boolean }; + let params: { + text: string; + size?: number; + margin?: number; + download?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + text: string; + size?: number; + margin?: number; + download?: boolean; + }; } else { params = { text: paramsOrFirst as string, size: rest[0] as number, margin: rest[1] as number, - download: rest[2] as boolean + download: rest[2] as boolean, }; } - + const text = params.text; const size = params.size; const margin = params.margin; const download = params.download; - if (typeof text === 'undefined') { throw new AppwriteException('Missing required parameter: "text"'); } - const apiPath = '/avatars/qr'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof text !== 'undefined') { - payload['text'] = text; + apiPayload['text'] = text; } if (typeof size !== 'undefined') { - payload['size'] = size; + apiPayload['size'] = size; } if (typeof margin !== 'undefined') { - payload['margin'] = margin; + apiPayload['margin'] = margin; } if (typeof download !== 'undefined') { - payload['download'] = download; + apiPayload['download'] = download; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/png', - } + accept: 'image/png', + }; return this.client.call( 'get', uri, apiHeaders, - payload, - 'arrayBuffer' + apiPayload, + 'arrayBuffer', ); } /** * Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image. - * + * * You can configure the browser viewport size, theme, user agent, geolocation, permissions, and more. Capture either just the viewport or the full page scroll. - * + * * When width and height are specified, the image is resized accordingly. If both dimensions are 0, the API provides an image at original size. If dimensions are not specified, the default viewport size is 1280x720px. * * @param {string} params.url - Website URL which you want to capture. @@ -599,12 +931,33 @@ export class Avatars { * @throws {AppwriteException} * @returns {Promise} */ - getScreenshot(params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }): Promise; + getScreenshot(params: { + url: string; + headers?: object; + viewportWidth?: number; + viewportHeight?: number; + scale?: number; + theme?: BrowserTheme; + userAgent?: string; + fullpage?: boolean; + locale?: string; + timezone?: Timezone; + latitude?: number; + longitude?: number; + accuracy?: number; + touch?: boolean; + permissions?: BrowserPermission[]; + sleep?: number; + width?: number; + height?: number; + quality?: number; + output?: ImageFormat; + }): Promise; /** * Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image. - * + * * You can configure the browser viewport size, theme, user agent, geolocation, permissions, and more. Capture either just the viewport or the full page scroll. - * + * * When width and height are specified, the image is resized accordingly. If both dimensions are 0, the API provides an image at original size. If dimensions are not specified, the default viewport size is 1280x720px. * * @param {string} url - Website URL which you want to capture. @@ -631,15 +984,125 @@ export class Avatars { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getScreenshot(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat): Promise; getScreenshot( - paramsOrFirst: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat } | string, - ...rest: [(object)?, (number)?, (number)?, (number)?, (BrowserTheme)?, (string)?, (boolean)?, (string)?, (Timezone)?, (number)?, (number)?, (number)?, (boolean)?, (BrowserPermission[])?, (number)?, (number)?, (number)?, (number)?, (ImageFormat)?] + url: string, + headers?: object, + viewportWidth?: number, + viewportHeight?: number, + scale?: number, + theme?: BrowserTheme, + userAgent?: string, + fullpage?: boolean, + locale?: string, + timezone?: Timezone, + latitude?: number, + longitude?: number, + accuracy?: number, + touch?: boolean, + permissions?: BrowserPermission[], + sleep?: number, + width?: number, + height?: number, + quality?: number, + output?: ImageFormat, + ): Promise; + getScreenshot( + paramsOrFirst: + | { + url: string; + headers?: object; + viewportWidth?: number; + viewportHeight?: number; + scale?: number; + theme?: BrowserTheme; + userAgent?: string; + fullpage?: boolean; + locale?: string; + timezone?: Timezone; + latitude?: number; + longitude?: number; + accuracy?: number; + touch?: boolean; + permissions?: BrowserPermission[]; + sleep?: number; + width?: number; + height?: number; + quality?: number; + output?: ImageFormat; + } + | string, + ...rest: [ + object?, + number?, + number?, + number?, + BrowserTheme?, + string?, + boolean?, + string?, + Timezone?, + number?, + number?, + number?, + boolean?, + BrowserPermission[]?, + number?, + number?, + number?, + number?, + ImageFormat?, + ] ): Promise { - let params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }; + let params: { + url: string; + headers?: object; + viewportWidth?: number; + viewportHeight?: number; + scale?: number; + theme?: BrowserTheme; + userAgent?: string; + fullpage?: boolean; + locale?: string; + timezone?: Timezone; + latitude?: number; + longitude?: number; + accuracy?: number; + touch?: boolean; + permissions?: BrowserPermission[]; + sleep?: number; + width?: number; + height?: number; + quality?: number; + output?: ImageFormat; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + url: string; + headers?: object; + viewportWidth?: number; + viewportHeight?: number; + scale?: number; + theme?: BrowserTheme; + userAgent?: string; + fullpage?: boolean; + locale?: string; + timezone?: Timezone; + latitude?: number; + longitude?: number; + accuracy?: number; + touch?: boolean; + permissions?: BrowserPermission[]; + sleep?: number; + width?: number; + height?: number; + quality?: number; + output?: ImageFormat; + }; } else { params = { url: paramsOrFirst as string, @@ -661,10 +1124,10 @@ export class Avatars { width: rest[15] as number, height: rest[16] as number, quality: rest[17] as number, - output: rest[18] as ImageFormat + output: rest[18] as ImageFormat, }; } - + const url = params.url; const headers = params.headers; const viewportWidth = params.viewportWidth; @@ -685,86 +1148,84 @@ export class Avatars { const height = params.height; const quality = params.quality; const output = params.output; - if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } - const apiPath = '/avatars/screenshots'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof url !== 'undefined') { - payload['url'] = url; + apiPayload['url'] = url; } if (typeof headers !== 'undefined') { - payload['headers'] = headers; + apiPayload['headers'] = headers; } if (typeof viewportWidth !== 'undefined') { - payload['viewportWidth'] = viewportWidth; + apiPayload['viewportWidth'] = viewportWidth; } if (typeof viewportHeight !== 'undefined') { - payload['viewportHeight'] = viewportHeight; + apiPayload['viewportHeight'] = viewportHeight; } if (typeof scale !== 'undefined') { - payload['scale'] = scale; + apiPayload['scale'] = scale; } if (typeof theme !== 'undefined') { - payload['theme'] = theme; + apiPayload['theme'] = theme; } if (typeof userAgent !== 'undefined') { - payload['userAgent'] = userAgent; + apiPayload['userAgent'] = userAgent; } if (typeof fullpage !== 'undefined') { - payload['fullpage'] = fullpage; + apiPayload['fullpage'] = fullpage; } if (typeof locale !== 'undefined') { - payload['locale'] = locale; + apiPayload['locale'] = locale; } if (typeof timezone !== 'undefined') { - payload['timezone'] = timezone; + apiPayload['timezone'] = timezone; } if (typeof latitude !== 'undefined') { - payload['latitude'] = latitude; + apiPayload['latitude'] = latitude; } if (typeof longitude !== 'undefined') { - payload['longitude'] = longitude; + apiPayload['longitude'] = longitude; } if (typeof accuracy !== 'undefined') { - payload['accuracy'] = accuracy; + apiPayload['accuracy'] = accuracy; } if (typeof touch !== 'undefined') { - payload['touch'] = touch; + apiPayload['touch'] = touch; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof sleep !== 'undefined') { - payload['sleep'] = sleep; + apiPayload['sleep'] = sleep; } if (typeof width !== 'undefined') { - payload['width'] = width; + apiPayload['width'] = width; } if (typeof height !== 'undefined') { - payload['height'] = height; + apiPayload['height'] = height; } if (typeof quality !== 'undefined') { - payload['quality'] = quality; + apiPayload['quality'] = quality; } if (typeof output !== 'undefined') { - payload['output'] = output; + apiPayload['output'] = output; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/png', - } + accept: 'image/png', + }; return this.client.call( 'get', uri, apiHeaders, - payload, - 'arrayBuffer' + apiPayload, + 'arrayBuffer', ); } } diff --git a/src/services/backups.ts b/src/services/backups.ts index 7902c675..dad80a1c 100644 --- a/src/services/backups.ts +++ b/src/services/backups.ts @@ -1,9 +1,7 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - import { BackupServices } from '../enums/backup-services'; - export class Backups { client: Client; @@ -18,7 +16,9 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - listArchives(params?: { queries?: string[] }): Promise; + listArchives(params?: { + queries?: string[]; + }): Promise; /** * List all archives for a project. * @@ -29,39 +29,37 @@ export class Backups { */ listArchives(queries?: string[]): Promise; listArchives( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; - + const queries = params.queries; const apiPath = '/backups/archives'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -72,7 +70,10 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - createArchive(params: { services: BackupServices[], resourceId?: string }): Promise; + createArchive(params: { + services: BackupServices[]; + resourceId?: string; + }): Promise; /** * Create a new archive asynchronously for a project. * @@ -82,51 +83,59 @@ export class Backups { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createArchive(services: BackupServices[], resourceId?: string): Promise; createArchive( - paramsOrFirst: { services: BackupServices[], resourceId?: string } | BackupServices[], - ...rest: [(string)?] + services: BackupServices[], + resourceId?: string, + ): Promise; + createArchive( + paramsOrFirst: + | { services: BackupServices[]; resourceId?: string } + | BackupServices[], + ...rest: [string?] ): Promise { - let params: { services: BackupServices[], resourceId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('services' in paramsOrFirst || 'resourceId' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { services: BackupServices[], resourceId?: string }; + let params: { services: BackupServices[]; resourceId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('services' in paramsOrFirst || 'resourceId' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + services: BackupServices[]; + resourceId?: string; + }; } else { params = { services: paramsOrFirst as BackupServices[], - resourceId: rest[0] as string + resourceId: rest[0] as string, }; } - + const services = params.services; const resourceId = params.resourceId; - if (typeof services === 'undefined') { - throw new AppwriteException('Missing required parameter: "services"'); + throw new AppwriteException( + 'Missing required parameter: "services"', + ); } - const apiPath = '/backups/archives'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof services !== 'undefined') { - payload['services'] = services; + apiPayload['services'] = services; } if (typeof resourceId !== 'undefined') { - payload['resourceId'] = resourceId; + apiPayload['resourceId'] = resourceId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -147,39 +156,41 @@ export class Backups { */ getArchive(archiveId: string): Promise; getArchive( - paramsOrFirst: { archiveId: string } | string + paramsOrFirst: { archiveId: string } | string, ): Promise { let params: { archiveId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { archiveId: string }; } else { params = { - archiveId: paramsOrFirst as string + archiveId: paramsOrFirst as string, }; } - - const archiveId = params.archiveId; + const archiveId = params.archiveId; if (typeof archiveId === 'undefined') { - throw new AppwriteException('Missing required parameter: "archiveId"'); + throw new AppwriteException( + 'Missing required parameter: "archiveId"', + ); } - - const apiPath = '/backups/archives/{archiveId}'.replace('{archiveId}', encodeURIComponent(String(archiveId))); - const payload: Payload = {}; + const apiPath = '/backups/archives/{archiveId}'.replace( + '{archiveId}', + encodeURIComponent(String(archiveId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -199,41 +210,41 @@ export class Backups { * @deprecated Use the object parameter style method for a better developer experience. */ deleteArchive(archiveId: string): Promise<{}>; - deleteArchive( - paramsOrFirst: { archiveId: string } | string - ): Promise<{}> { + deleteArchive(paramsOrFirst: { archiveId: string } | string): Promise<{}> { let params: { archiveId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { archiveId: string }; } else { params = { - archiveId: paramsOrFirst as string + archiveId: paramsOrFirst as string, }; } - - const archiveId = params.archiveId; + const archiveId = params.archiveId; if (typeof archiveId === 'undefined') { - throw new AppwriteException('Missing required parameter: "archiveId"'); + throw new AppwriteException( + 'Missing required parameter: "archiveId"', + ); } - - const apiPath = '/backups/archives/{archiveId}'.replace('{archiveId}', encodeURIComponent(String(archiveId))); - const payload: Payload = {}; + const apiPath = '/backups/archives/{archiveId}'.replace( + '{archiveId}', + encodeURIComponent(String(archiveId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -243,7 +254,9 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - listPolicies(params?: { queries?: string[] }): Promise; + listPolicies(params?: { + queries?: string[]; + }): Promise; /** * List all policies for a project. * @@ -254,39 +267,37 @@ export class Backups { */ listPolicies(queries?: string[]): Promise; listPolicies( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; - + const queries = params.queries; const apiPath = '/backups/policies'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -302,7 +313,15 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - createPolicy(params: { policyId: string, services: BackupServices[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean }): Promise; + createPolicy(params: { + policyId: string; + services: BackupServices[]; + retention: number; + schedule: string; + name?: string; + resourceId?: string; + enabled?: boolean; + }): Promise; /** * Create a new backup policy. * @@ -317,15 +336,60 @@ export class Backups { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPolicy(policyId: string, services: BackupServices[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean): Promise; createPolicy( - paramsOrFirst: { policyId: string, services: BackupServices[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean } | string, - ...rest: [(BackupServices[])?, (number)?, (string)?, (string)?, (string)?, (boolean)?] + policyId: string, + services: BackupServices[], + retention: number, + schedule: string, + name?: string, + resourceId?: string, + enabled?: boolean, + ): Promise; + createPolicy( + paramsOrFirst: + | { + policyId: string; + services: BackupServices[]; + retention: number; + schedule: string; + name?: string; + resourceId?: string; + enabled?: boolean; + } + | string, + ...rest: [ + BackupServices[]?, + number?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { policyId: string, services: BackupServices[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { policyId: string, services: BackupServices[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean }; + let params: { + policyId: string; + services: BackupServices[]; + retention: number; + schedule: string; + name?: string; + resourceId?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + policyId: string; + services: BackupServices[]; + retention: number; + schedule: string; + name?: string; + resourceId?: string; + enabled?: boolean; + }; } else { params = { policyId: paramsOrFirst as string, @@ -334,10 +398,10 @@ export class Backups { schedule: rest[2] as string, name: rest[3] as string, resourceId: rest[4] as string, - enabled: rest[5] as boolean + enabled: rest[5] as boolean, }; } - + const policyId = params.policyId; const services = params.services; const retention = params.retention; @@ -345,57 +409,58 @@ export class Backups { const name = params.name; const resourceId = params.resourceId; const enabled = params.enabled; - if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } if (typeof services === 'undefined') { - throw new AppwriteException('Missing required parameter: "services"'); + throw new AppwriteException( + 'Missing required parameter: "services"', + ); } if (typeof retention === 'undefined') { - throw new AppwriteException('Missing required parameter: "retention"'); + throw new AppwriteException( + 'Missing required parameter: "retention"', + ); } if (typeof schedule === 'undefined') { - throw new AppwriteException('Missing required parameter: "schedule"'); + throw new AppwriteException( + 'Missing required parameter: "schedule"', + ); } - const apiPath = '/backups/policies'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof policyId !== 'undefined') { - payload['policyId'] = policyId; + apiPayload['policyId'] = policyId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof services !== 'undefined') { - payload['services'] = services; + apiPayload['services'] = services; } if (typeof resourceId !== 'undefined') { - payload['resourceId'] = resourceId; + apiPayload['resourceId'] = resourceId; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof retention !== 'undefined') { - payload['retention'] = retention; + apiPayload['retention'] = retention; } if (typeof schedule !== 'undefined') { - payload['schedule'] = schedule; + apiPayload['schedule'] = schedule; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -416,39 +481,41 @@ export class Backups { */ getPolicy(policyId: string): Promise; getPolicy( - paramsOrFirst: { policyId: string } | string + paramsOrFirst: { policyId: string } | string, ): Promise { let params: { policyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { policyId: string }; } else { params = { - policyId: paramsOrFirst as string + policyId: paramsOrFirst as string, }; } - - const policyId = params.policyId; + const policyId = params.policyId; if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/backups/policies/{policyId}'.replace('{policyId}', encodeURIComponent(String(policyId))); - const payload: Payload = {}; + const apiPath = '/backups/policies/{policyId}'.replace( + '{policyId}', + encodeURIComponent(String(policyId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -462,7 +529,13 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - updatePolicy(params: { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean }): Promise; + updatePolicy(params: { + policyId: string; + name?: string; + retention?: number; + schedule?: string; + enabled?: boolean; + }): Promise; /** * Update an existing policy using it's ID. * @@ -475,63 +548,91 @@ export class Backups { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePolicy(policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean): Promise; updatePolicy( - paramsOrFirst: { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean } | string, - ...rest: [(string)?, (number)?, (string)?, (boolean)?] + policyId: string, + name?: string, + retention?: number, + schedule?: string, + enabled?: boolean, + ): Promise; + updatePolicy( + paramsOrFirst: + | { + policyId: string; + name?: string; + retention?: number; + schedule?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, number?, string?, boolean?] ): Promise { - let params: { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean }; + let params: { + policyId: string; + name?: string; + retention?: number; + schedule?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + policyId: string; + name?: string; + retention?: number; + schedule?: string; + enabled?: boolean; + }; } else { params = { policyId: paramsOrFirst as string, name: rest[0] as string, retention: rest[1] as number, schedule: rest[2] as string, - enabled: rest[3] as boolean + enabled: rest[3] as boolean, }; } - + const policyId = params.policyId; const name = params.name; const retention = params.retention; const schedule = params.schedule; const enabled = params.enabled; - if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/backups/policies/{policyId}'.replace('{policyId}', encodeURIComponent(String(policyId))); - const payload: Payload = {}; + const apiPath = '/backups/policies/{policyId}'.replace( + '{policyId}', + encodeURIComponent(String(policyId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof retention !== 'undefined') { - payload['retention'] = retention; + apiPayload['retention'] = retention; } if (typeof schedule !== 'undefined') { - payload['schedule'] = schedule; + apiPayload['schedule'] = schedule; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -551,54 +652,54 @@ export class Backups { * @deprecated Use the object parameter style method for a better developer experience. */ deletePolicy(policyId: string): Promise<{}>; - deletePolicy( - paramsOrFirst: { policyId: string } | string - ): Promise<{}> { + deletePolicy(paramsOrFirst: { policyId: string } | string): Promise<{}> { let params: { policyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { policyId: string }; } else { params = { - policyId: paramsOrFirst as string + policyId: paramsOrFirst as string, }; } - - const policyId = params.policyId; + const policyId = params.policyId; if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/backups/policies/{policyId}'.replace('{policyId}', encodeURIComponent(String(policyId))); - const payload: Payload = {}; + const apiPath = '/backups/policies/{policyId}'.replace( + '{policyId}', + encodeURIComponent(String(policyId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** * Create and trigger a new restoration for a backup on a project. - * + * * For a backup of one database, the restoration resolves its destination before it is queued. When `newResourceId` is omitted, the archived database is restored in place and its own ID is returned in `options`. Pass a different `newResourceId` to restore alongside it as a new database instead. - * + * * The restoration migration records the archived database in `resourceId` and `resourceType`, and the resolved database in `destinationResourceId` and `destinationResourceType`. Database types are stored canonically as `database`, `documentsdb`, or `vectorsdb`. Project-wide restorations leave these fields empty because they do not have a single source or destination database. - * + * * To list every migration related to one database, use its canonical type in a nested `OR(AND(...), AND(...), AND(...))` across the root, parent, and destination relation pairs: `(resourceType, resourceId)`, `(parentResourceType, parentResourceId)`, and `(destinationResourceType, destinationResourceId)`. Legacy and TablesDB databases use `database`; the operational `resourceType` of a table migration is not rewritten to `tablesdb`. - * + * * When restoring a DocumentsDB or VectorsDB database from a dedicated source, the restore provisions a fresh dedicated backing database at the source database's own specification and lands the data there. An in-place restore swaps the database onto that backing only once the restore has succeeded, and retires the backing it displaced only once that swap is confirmed, so the source keeps serving its own data until the restored data is in place and any failure leaves it untouched. A serverless source has no dedicated backing to clone and restores onto the archived database instead. - * + * * * @param {string} params.archiveId - Backup archive ID to restore * @param {BackupServices[]} params.services - Array of services to restore @@ -607,18 +708,23 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - createRestoration(params: { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string }): Promise; + createRestoration(params: { + archiveId: string; + services: BackupServices[]; + newResourceId?: string; + newResourceName?: string; + }): Promise; /** * Create and trigger a new restoration for a backup on a project. - * + * * For a backup of one database, the restoration resolves its destination before it is queued. When `newResourceId` is omitted, the archived database is restored in place and its own ID is returned in `options`. Pass a different `newResourceId` to restore alongside it as a new database instead. - * + * * The restoration migration records the archived database in `resourceId` and `resourceType`, and the resolved database in `destinationResourceId` and `destinationResourceType`. Database types are stored canonically as `database`, `documentsdb`, or `vectorsdb`. Project-wide restorations leave these fields empty because they do not have a single source or destination database. - * + * * To list every migration related to one database, use its canonical type in a nested `OR(AND(...), AND(...), AND(...))` across the root, parent, and destination relation pairs: `(resourceType, resourceId)`, `(parentResourceType, parentResourceId)`, and `(destinationResourceType, destinationResourceId)`. Legacy and TablesDB databases use `database`; the operational `resourceType` of a table migration is not rewritten to `tablesdb`. - * + * * When restoring a DocumentsDB or VectorsDB database from a dedicated source, the restore provisions a fresh dedicated backing database at the source database's own specification and lands the data there. An in-place restore swaps the database onto that backing only once the restore has succeeded, and retires the backing it displaced only once that swap is confirmed, so the source keeps serving its own data until the restored data is in place and any failure leaves it untouched. A serverless source has no dedicated backing to clone and restores onto the archived database instead. - * + * * * @param {string} archiveId - Backup archive ID to restore * @param {BackupServices[]} services - Array of services to restore @@ -628,64 +734,87 @@ export class Backups { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRestoration(archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string): Promise; createRestoration( - paramsOrFirst: { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string } | string, - ...rest: [(BackupServices[])?, (string)?, (string)?] + archiveId: string, + services: BackupServices[], + newResourceId?: string, + newResourceName?: string, + ): Promise; + createRestoration( + paramsOrFirst: + | { + archiveId: string; + services: BackupServices[]; + newResourceId?: string; + newResourceName?: string; + } + | string, + ...rest: [BackupServices[]?, string?, string?] ): Promise { - let params: { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string }; + let params: { + archiveId: string; + services: BackupServices[]; + newResourceId?: string; + newResourceName?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + archiveId: string; + services: BackupServices[]; + newResourceId?: string; + newResourceName?: string; + }; } else { params = { archiveId: paramsOrFirst as string, services: rest[0] as BackupServices[], newResourceId: rest[1] as string, - newResourceName: rest[2] as string + newResourceName: rest[2] as string, }; } - + const archiveId = params.archiveId; const services = params.services; const newResourceId = params.newResourceId; const newResourceName = params.newResourceName; - if (typeof archiveId === 'undefined') { - throw new AppwriteException('Missing required parameter: "archiveId"'); + throw new AppwriteException( + 'Missing required parameter: "archiveId"', + ); } if (typeof services === 'undefined') { - throw new AppwriteException('Missing required parameter: "services"'); + throw new AppwriteException( + 'Missing required parameter: "services"', + ); } - const apiPath = '/backups/restoration'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof archiveId !== 'undefined') { - payload['archiveId'] = archiveId; + apiPayload['archiveId'] = archiveId; } if (typeof services !== 'undefined') { - payload['services'] = services; + apiPayload['services'] = services; } if (typeof newResourceId !== 'undefined') { - payload['newResourceId'] = newResourceId; + apiPayload['newResourceId'] = newResourceId; } if (typeof newResourceName !== 'undefined') { - payload['newResourceName'] = newResourceName; + apiPayload['newResourceName'] = newResourceName; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -695,7 +824,9 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - listRestorations(params?: { queries?: string[] }): Promise; + listRestorations(params?: { + queries?: string[]; + }): Promise; /** * List all backup restorations for a project. * @@ -706,39 +837,37 @@ export class Backups { */ listRestorations(queries?: string[]): Promise; listRestorations( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; - + const queries = params.queries; const apiPath = '/backups/restorations'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -748,7 +877,9 @@ export class Backups { * @throws {AppwriteException} * @returns {Promise} */ - getRestoration(params: { restorationId: string }): Promise; + getRestoration(params: { + restorationId: string; + }): Promise; /** * Get the current status of a backup restoration. * @@ -759,38 +890,40 @@ export class Backups { */ getRestoration(restorationId: string): Promise; getRestoration( - paramsOrFirst: { restorationId: string } | string + paramsOrFirst: { restorationId: string } | string, ): Promise { let params: { restorationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { restorationId: string }; } else { params = { - restorationId: paramsOrFirst as string + restorationId: paramsOrFirst as string, }; } - - const restorationId = params.restorationId; + const restorationId = params.restorationId; if (typeof restorationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "restorationId"'); + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); } - - const apiPath = '/backups/restorations/{restorationId}'.replace('{restorationId}', encodeURIComponent(String(restorationId))); - const payload: Payload = {}; + const apiPath = '/backups/restorations/{restorationId}'.replace( + '{restorationId}', + encodeURIComponent(String(restorationId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } } diff --git a/src/services/databases.ts b/src/services/databases.ts index 6a3ee13e..5d06492c 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1,12 +1,10 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - import { RelationshipType } from '../enums/relationship-type'; import { RelationMutate } from '../enums/relation-mutate'; import { DatabasesIndexType } from '../enums/databases-index-type'; import { OrderBy } from '../enums/order-by'; - export class Databases { client: Client; @@ -24,7 +22,11 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.list` instead. */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + list(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. * @@ -35,57 +37,64 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string, total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + list( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - - const apiPath = '/databases'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Create a new Database. - * + * * * @param {string} params.databaseId - Unique 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 - Database name. Max length: 128 chars. @@ -94,10 +103,14 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.create` instead. */ - create(params: { databaseId: string, name: string, enabled?: boolean }): Promise; + create(params: { + databaseId: string; + name: string; + enabled?: boolean; + }): Promise; /** * Create a new Database. - * + * * * @param {string} databaseId - Unique 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 - Database name. Max length: 128 chars. @@ -106,59 +119,67 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, enabled?: boolean): Promise; create( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + databaseId: string, + name: string, + enabled?: boolean, + ): Promise; + create( + paramsOrFirst: + { databaseId: string; name: string; enabled?: boolean } | string, + ...rest: [string?, boolean?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; + let params: { databaseId: string; name: string; enabled?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + enabled?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/databases'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof databaseId !== 'undefined') { - payload['databaseId'] = databaseId; + apiPayload['databaseId'] = databaseId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -169,7 +190,9 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead. */ - listTransactions(params?: { queries?: string[] }): Promise; + listTransactions(params?: { + queries?: string[]; + }): Promise; /** * List transactions across all databases. * @@ -180,39 +203,37 @@ export class Databases { */ listTransactions(queries?: string[]): Promise; listTransactions( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; - + const queries = params.queries; const apiPath = '/databases/transactions'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -234,40 +255,38 @@ export class Databases { */ createTransaction(ttl?: number): Promise; createTransaction( - paramsOrFirst?: { ttl?: number } | number + paramsOrFirst?: { ttl?: number } | number, ): Promise { let params: { ttl?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { ttl?: number }; } else { params = { - ttl: paramsOrFirst as number + ttl: paramsOrFirst as number, }; } - - const ttl = params.ttl; - + const ttl = params.ttl; const apiPath = '/databases/transactions'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof ttl !== 'undefined') { - payload['ttl'] = ttl; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -278,7 +297,9 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead. */ - getTransaction(params: { transactionId: string }): Promise; + getTransaction(params: { + transactionId: string; + }): Promise; /** * Get a transaction by its unique ID. * @@ -289,39 +310,41 @@ export class Databases { */ getTransaction(transactionId: string): Promise; getTransaction( - paramsOrFirst: { transactionId: string } | string + paramsOrFirst: { transactionId: string } | string, ): Promise { let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { transactionId: string }; } else { params = { - transactionId: paramsOrFirst as string + transactionId: paramsOrFirst as string, }; } - - const transactionId = params.transactionId; + const transactionId = params.transactionId; if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/databases/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); - const payload: Payload = {}; + const apiPath = '/databases/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -334,7 +357,11 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead. */ - updateTransaction(params: { transactionId: string, commit?: boolean, rollback?: boolean }): Promise; + updateTransaction(params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }): Promise; /** * Update a transaction, to either commit or roll back its operations. * @@ -345,53 +372,69 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTransaction(transactionId: string, commit?: boolean, rollback?: boolean): Promise; updateTransaction( - paramsOrFirst: { transactionId: string, commit?: boolean, rollback?: boolean } | string, - ...rest: [(boolean)?, (boolean)?] + transactionId: string, + commit?: boolean, + rollback?: boolean, + ): Promise; + updateTransaction( + paramsOrFirst: + | { transactionId: string; commit?: boolean; rollback?: boolean } + | string, + ...rest: [boolean?, boolean?] ): Promise { - let params: { transactionId: string, commit?: boolean, rollback?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, commit?: boolean, rollback?: boolean }; + let params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; } else { params = { transactionId: paramsOrFirst as string, commit: rest[0] as boolean, - rollback: rest[1] as boolean + rollback: rest[1] as boolean, }; } - + const transactionId = params.transactionId; const commit = params.commit; const rollback = params.rollback; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/databases/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); - const payload: Payload = {}; + const apiPath = '/databases/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + const apiPayload: Payload = {}; if (typeof commit !== 'undefined') { - payload['commit'] = commit; + apiPayload['commit'] = commit; } if (typeof rollback !== 'undefined') { - payload['rollback'] = rollback; + apiPayload['rollback'] = rollback; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -413,39 +456,41 @@ export class Databases { */ deleteTransaction(transactionId: string): Promise<{}>; deleteTransaction( - paramsOrFirst: { transactionId: string } | string + paramsOrFirst: { transactionId: string } | string, ): Promise<{}> { let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { transactionId: string }; } else { params = { - transactionId: paramsOrFirst as string + transactionId: paramsOrFirst as string, }; } - - const transactionId = params.transactionId; + const transactionId = params.transactionId; if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/databases/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); - const payload: Payload = {}; + const apiPath = '/databases/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -457,7 +502,10 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead. */ - createOperations(params: { transactionId: string, operations?: object[] }): Promise; + createOperations(params: { + transactionId: string; + operations?: object[]; + }): Promise; /** * Create multiple operations in a single transaction. * @@ -467,48 +515,58 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createOperations(transactionId: string, operations?: object[]): Promise; createOperations( - paramsOrFirst: { transactionId: string, operations?: object[] } | string, - ...rest: [(object[])?] + transactionId: string, + operations?: object[], + ): Promise; + createOperations( + paramsOrFirst: + { transactionId: string; operations?: object[] } | string, + ...rest: [object[]?] ): Promise { - let params: { transactionId: string, operations?: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, operations?: object[] }; + let params: { transactionId: string; operations?: object[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + transactionId: string; + operations?: object[]; + }; } else { params = { transactionId: paramsOrFirst as string, - operations: rest[0] as object[] + operations: rest[0] as object[], }; } - + const transactionId = params.transactionId; const operations = params.operations; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); - } - - const apiPath = '/databases/transactions/{transactionId}/operations'.replace('{transactionId}', encodeURIComponent(String(transactionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); + } + const apiPath = + '/databases/transactions/{transactionId}/operations'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + const apiPayload: Payload = {}; if (typeof operations !== 'undefined') { - payload['operations'] = operations; + apiPayload['operations'] = operations; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -530,39 +588,41 @@ export class Databases { */ get(databaseId: string): Promise; get( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - - const databaseId = params.databaseId; + const databaseId = params.databaseId; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/databases/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/databases/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -575,7 +635,11 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.update` instead. */ - update(params: { databaseId: string, name?: string, enabled?: boolean }): Promise; + update(params: { + databaseId: string; + name?: string; + enabled?: boolean; + }): Promise; /** * Update a database by its unique ID. * @@ -586,53 +650,64 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name?: string, enabled?: boolean): Promise; update( - paramsOrFirst: { databaseId: string, name?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + databaseId: string, + name?: string, + enabled?: boolean, + ): Promise; + update( + paramsOrFirst: + { databaseId: string; name?: string; enabled?: boolean } | string, + ...rest: [string?, boolean?] ): Promise { - let params: { databaseId: string, name?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name?: string, enabled?: boolean }; + let params: { databaseId: string; name?: string; enabled?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name?: string; + enabled?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/databases/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/databases/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -653,40 +728,40 @@ export class Databases { * @deprecated Use the object parameter style method for a better developer experience. */ delete(databaseId: string): Promise<{}>; - delete( - paramsOrFirst: { databaseId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { databaseId: string } | string): Promise<{}> { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - - const databaseId = params.databaseId; + const databaseId = params.databaseId; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/databases/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/databases/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -700,7 +775,12 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listTables` instead. */ - listCollections(params: { databaseId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listCollections(params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. * @@ -712,57 +792,81 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listCollections(databaseId: string, queries?: string[], search?: string, total?: boolean): Promise; listCollections( - paramsOrFirst: { databaseId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + databaseId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listCollections( + paramsOrFirst: + | { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { databaseId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/databases/{databaseId}/collections'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/databases/{databaseId}/collections'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -780,7 +884,16 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createTable` instead. */ - createCollection(params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }): Promise; + createCollection(params: { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + }): Promise; /** * Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * @@ -796,15 +909,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[]): Promise; createCollection( - paramsOrFirst: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (object[])?, (object[])?] + databaseId: string, + collectionId: string, + name: string, + permissions?: string[], + documentSecurity?: boolean, + enabled?: boolean, + attributes?: object[], + indexes?: object[], + ): Promise; + createCollection( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + } + | string, + ...rest: [ + string?, + string?, + string[]?, + boolean?, + boolean?, + object[]?, + object[]?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }; + let params: { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -814,10 +977,10 @@ export class Databases { documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, attributes: rest[5] as object[], - indexes: rest[6] as object[] + indexes: rest[6] as object[], }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const name = params.name; @@ -826,54 +989,54 @@ export class Databases { const enabled = params.enabled; const attributes = params.attributes; const indexes = params.indexes; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/databases/{databaseId}/collections'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/databases/{databaseId}/collections'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; if (typeof collectionId !== 'undefined') { - payload['collectionId'] = collectionId; + apiPayload['collectionId'] = collectionId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof documentSecurity !== 'undefined') { - payload['documentSecurity'] = documentSecurity; + apiPayload['documentSecurity'] = documentSecurity; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof attributes !== 'undefined') { - payload['attributes'] = attributes; + apiPayload['attributes'] = attributes; } if (typeof indexes !== 'undefined') { - payload['indexes'] = indexes; + apiPayload['indexes'] = indexes; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -885,7 +1048,10 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getTable` instead. */ - getCollection(params: { databaseId: string, collectionId: string }): Promise; + getCollection(params: { + databaseId: string; + collectionId: string; + }): Promise; /** * Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. * @@ -895,47 +1061,59 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getCollection(databaseId: string, collectionId: string): Promise; getCollection( - paramsOrFirst: { databaseId: string, collectionId: string } | string, - ...rest: [(string)?] + databaseId: string, + collectionId: string, + ): Promise; + getCollection( + paramsOrFirst: { databaseId: string; collectionId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, collectionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + let params: { databaseId: string; collectionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - collectionId: rest[0] as string + collectionId: rest[0] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = '/databases/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -952,7 +1130,15 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTable` instead. */ - updateCollection(params: { databaseId: string, collectionId: string, name?: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean }): Promise; + updateCollection(params: { + databaseId: string; + collectionId: string; + name?: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }): Promise; /** * Update a collection by its unique ID. * @@ -967,15 +1153,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateCollection(databaseId: string, collectionId: string, name?: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean): Promise; updateCollection( - paramsOrFirst: { databaseId: string, collectionId: string, name?: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + name?: string, + permissions?: string[], + documentSecurity?: boolean, + enabled?: boolean, + purge?: boolean, + ): Promise; + updateCollection( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + name?: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + } + | string, + ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, name?: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name?: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean }; + let params: { + databaseId: string; + collectionId: string; + name?: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + name?: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -984,10 +1208,10 @@ export class Databases { permissions: rest[2] as string[], documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, - purge: rest[5] as boolean + purge: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const name = params.name; @@ -995,45 +1219,47 @@ export class Databases { const documentSecurity = params.documentSecurity; const enabled = params.enabled; const purge = params.purge; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = '/databases/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof documentSecurity !== 'undefined') { - payload['documentSecurity'] = documentSecurity; + apiPayload['documentSecurity'] = documentSecurity; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof purge !== 'undefined') { - payload['purge'] = purge; + apiPayload['purge'] = purge; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1045,7 +1271,10 @@ export class Databases { * @returns {Promise<{}>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTable` instead. */ - deleteCollection(params: { databaseId: string, collectionId: string }): Promise<{}>; + deleteCollection(params: { + databaseId: string; + collectionId: string; + }): Promise<{}>; /** * Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. * @@ -1057,45 +1286,54 @@ export class Databases { */ deleteCollection(databaseId: string, collectionId: string): Promise<{}>; deleteCollection( - paramsOrFirst: { databaseId: string, collectionId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; collectionId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { databaseId: string, collectionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + let params: { databaseId: string; collectionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - collectionId: rest[0] as string + collectionId: rest[0] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = '/databases/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1109,7 +1347,12 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listColumns` instead. */ - listAttributes(params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }): Promise; + listAttributes(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List attributes in the collection. * @@ -1121,62 +1364,91 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listAttributes(databaseId: string, collectionId: string, queries?: string[], total?: boolean): Promise; listAttributes( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?] + databaseId: string, + collectionId: string, + queries?: string[], + total?: boolean, + ): Promise; + listAttributes( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + } + | string, + ...rest: [string?, string[]?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, queries: rest[1] as string[], - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Create a bigint attribute. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -1190,10 +1462,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createBigIntColumn` instead. */ - createBigIntAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise; + createBigIntAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }): Promise; /** * Create a bigint attribute. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -1207,15 +1488,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBigIntAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise; createBigIntAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + min?: number | bigint, + max?: number | bigint, + xdefault?: number | bigint, + array?: boolean, + ): Promise; + createBigIntAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + boolean?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1225,10 +1556,10 @@ export class Databases { min: rest[3] as number | bigint, max: rest[4] as number | bigint, xdefault: rest[5] as number | bigint, - array: rest[6] as boolean + array: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -1237,59 +1568,64 @@ export class Databases { const max = params.max; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/bigint' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof min !== 'undefined') { - payload['min'] = min; + apiPayload['min'] = min; } if (typeof max !== 'undefined') { - payload['max'] = max; + apiPayload['max'] = max; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update a bigint attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -1303,10 +1639,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBigIntColumn` instead. */ - updateBigIntAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise; + updateBigIntAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }): Promise; /** * Update a bigint attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -1320,15 +1665,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBigIntAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise; updateBigIntAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: number | bigint, + min?: number | bigint, + max?: number | bigint, + newKey?: string, + ): Promise; + updateBigIntAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1338,10 +1733,10 @@ export class Databases { xdefault: rest[3] as number | bigint, min: rest[4] as number | bigint, max: rest[5] as number | bigint, - newKey: rest[6] as string + newKey: rest[6] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -1350,59 +1745,67 @@ export class Databases { const min = params.min; const max = params.max; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof min !== 'undefined') { - payload['min'] = min; + apiPayload['min'] = min; } if (typeof max !== 'undefined') { - payload['max'] = max; + apiPayload['max'] = max; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create a boolean attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -1414,10 +1817,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createBooleanColumn` instead. */ - createBooleanAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }): Promise; + createBooleanAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + }): Promise; /** * Create a boolean attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -1429,15 +1839,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise; createBooleanAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: boolean, + array?: boolean, + ): Promise; + createBooleanAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1445,58 +1889,63 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as boolean, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/boolean' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1512,7 +1961,14 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBooleanColumn` instead. */ - updateBooleanAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }): Promise; + updateBooleanAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + }): Promise; /** * Update a boolean attribute. Changing the `default` value will not update already existing documents. * @@ -1526,15 +1982,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise; updateBooleanAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: boolean, + newKey?: string, + ): Promise; + updateBooleanAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, boolean?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1542,58 +2032,66 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as boolean, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1609,7 +2107,14 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createDatetimeColumn` instead. */ - createDatetimeAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createDatetimeAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create a date time attribute according to the ISO 8601 standard. * @@ -1623,15 +2128,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createDatetimeAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createDatetimeAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1639,58 +2178,63 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/datetime' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1706,7 +2250,14 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateDatetimeColumn` instead. */ - updateDatetimeAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateDatetimeAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a date time attribute. Changing the `default` value will not update already existing documents. * @@ -1720,15 +2271,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateDatetimeAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateDatetimeAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1736,63 +2321,71 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create an email attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -1804,10 +2397,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createEmailColumn` instead. */ - createEmailAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createEmailAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create an email attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -1819,15 +2419,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createEmailAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createEmailAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1835,63 +2469,68 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/email' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update an email attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -1903,10 +2542,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEmailColumn` instead. */ - updateEmailAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateEmailAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an email attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -1918,15 +2564,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateEmailAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateEmailAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1934,63 +2614,71 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** - * Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. - * + * Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2003,10 +2691,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createEnumColumn` instead. */ - createEnumAttribute(params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }): Promise; + createEnumAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** - * Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. - * + * Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2019,15 +2715,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise; createEnumAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + elements: string[], + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createEnumAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, string[]?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2036,10 +2770,10 @@ export class Databases { elements: rest[2] as string[], required: rest[3] as boolean, xdefault: rest[4] as string, - array: rest[5] as boolean + array: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2047,59 +2781,66 @@ export class Databases { const required = params.required; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof elements === 'undefined') { - throw new AppwriteException('Missing required parameter: "elements"'); + throw new AppwriteException( + 'Missing required parameter: "elements"', + ); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/enum' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof elements !== 'undefined') { - payload['elements'] = elements; + apiPayload['elements'] = elements; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update an enum attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2112,10 +2853,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEnumColumn` instead. */ - updateEnumAttribute(params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }): Promise; + updateEnumAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an enum attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2128,15 +2877,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise; updateEnumAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + elements: string[], + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateEnumAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, string[]?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2145,10 +2932,10 @@ export class Databases { elements: rest[2] as string[], required: rest[3] as boolean, xdefault: rest[4] as string, - newKey: rest[5] as string + newKey: rest[5] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2156,59 +2943,69 @@ export class Databases { const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof elements === 'undefined') { - throw new AppwriteException('Missing required parameter: "elements"'); + throw new AppwriteException( + 'Missing required parameter: "elements"', + ); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof elements !== 'undefined') { - payload['elements'] = elements; + apiPayload['elements'] = elements; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create a float attribute. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2222,10 +3019,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createFloatColumn` instead. */ - createFloatAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }): Promise; + createFloatAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + }): Promise; /** * Create a float attribute. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2239,15 +3045,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise; createFloatAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + min?: number, + max?: number, + xdefault?: number, + array?: boolean, + ): Promise; + createFloatAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + number?, + number?, + number?, + boolean?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2257,10 +3113,10 @@ export class Databases { min: rest[3] as number, max: rest[4] as number, xdefault: rest[5] as number, - array: rest[6] as boolean + array: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2269,59 +3125,64 @@ export class Databases { const max = params.max; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/float' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof min !== 'undefined') { - payload['min'] = min; + apiPayload['min'] = min; } if (typeof max !== 'undefined') { - payload['max'] = max; + apiPayload['max'] = max; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update a float attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2335,10 +3196,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateFloatColumn` instead. */ - updateFloatAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }): Promise; + updateFloatAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + }): Promise; /** * Update a float attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2352,15 +3222,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise; updateFloatAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: number, + min?: number, + max?: number, + newKey?: string, + ): Promise; + updateFloatAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + number?, + number?, + number?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2370,10 +3290,10 @@ export class Databases { xdefault: rest[3] as number, min: rest[4] as number, max: rest[5] as number, - newKey: rest[6] as string + newKey: rest[6] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2382,59 +3302,67 @@ export class Databases { const min = params.min; const max = params.max; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof min !== 'undefined') { - payload['min'] = min; + apiPayload['min'] = min; } if (typeof max !== 'undefined') { - payload['max'] = max; + apiPayload['max'] = max; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create an integer attribute. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2448,10 +3376,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIntegerColumn` instead. */ - createIntegerAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise; + createIntegerAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }): Promise; /** * Create an integer attribute. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2465,15 +3402,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise; createIntegerAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + min?: number | bigint, + max?: number | bigint, + xdefault?: number | bigint, + array?: boolean, + ): Promise; + createIntegerAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + boolean?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2483,10 +3470,10 @@ export class Databases { min: rest[3] as number | bigint, max: rest[4] as number | bigint, xdefault: rest[5] as number | bigint, - array: rest[6] as boolean + array: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2495,59 +3482,64 @@ export class Databases { const max = params.max; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/integer' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof min !== 'undefined') { - payload['min'] = min; + apiPayload['min'] = min; } if (typeof max !== 'undefined') { - payload['max'] = max; + apiPayload['max'] = max; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update an integer attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2561,10 +3553,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIntegerColumn` instead. */ - updateIntegerAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise; + updateIntegerAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }): Promise; /** * Update an integer attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2578,15 +3579,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise; updateIntegerAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: number | bigint, + min?: number | bigint, + max?: number | bigint, + newKey?: string, + ): Promise; + updateIntegerAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2596,10 +3647,10 @@ export class Databases { xdefault: rest[3] as number | bigint, min: rest[4] as number | bigint, max: rest[5] as number | bigint, - newKey: rest[6] as string + newKey: rest[6] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -2608,59 +3659,67 @@ export class Databases { const min = params.min; const max = params.max; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof min !== 'undefined') { - payload['min'] = min; + apiPayload['min'] = min; } if (typeof max !== 'undefined') { - payload['max'] = max; + apiPayload['max'] = max; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create IP address attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2672,10 +3731,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIpColumn` instead. */ - createIpAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createIpAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create IP address attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2687,15 +3753,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createIpAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createIpAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2703,63 +3803,68 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/ip' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update an ip attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -2771,10 +3876,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIpColumn` instead. */ - updateIpAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateIpAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an ip attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -2786,15 +3898,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateIpAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateIpAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2802,58 +3948,66 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2868,7 +4022,13 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createLineColumn` instead. */ - createLineAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] }): Promise; + createLineAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }): Promise; /** * Create a geometric line attribute. * @@ -2881,69 +4041,104 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createLineAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][]): Promise; createLineAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: any[][], + ): Promise; + createLineAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][] + xdefault: rest[3] as any[][], }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/line'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/line' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2959,7 +4154,14 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateLineColumn` instead. */ - updateLineAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }): Promise; + updateLineAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }): Promise; /** * Update a line attribute. Changing the `default` value will not update already existing documents. * @@ -2973,15 +4175,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateLineAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string): Promise; updateLineAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: any[][], + newKey?: string, + ): Promise; + updateLineAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2989,60 +4225,66 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as any[][], - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create a longtext attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3055,10 +4297,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createLongtextColumn` instead. */ - createLongtextAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createLongtextAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a longtext attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3071,15 +4321,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createLongtextAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createLongtextAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createLongtextAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3088,10 +4376,10 @@ export class Databases { required: rest[2] as boolean, xdefault: rest[3] as string, array: rest[4] as boolean, - encrypt: rest[5] as boolean + encrypt: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -3099,56 +4387,61 @@ export class Databases { const xdefault = params.xdefault; const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/longtext' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } if (typeof encrypt !== 'undefined') { - payload['encrypt'] = encrypt; + apiPayload['encrypt'] = encrypt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update a longtext attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3160,10 +4453,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateLongtextColumn` instead. */ - updateLongtextAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateLongtextAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a longtext attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3175,15 +4475,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateLongtextAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateLongtextAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateLongtextAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3191,63 +4525,71 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create a mediumtext attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3260,10 +4602,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createMediumtextColumn` instead. */ - createMediumtextAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createMediumtextAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a mediumtext attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3276,15 +4626,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMediumtextAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createMediumtextAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createMediumtextAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3293,10 +4681,10 @@ export class Databases { required: rest[2] as boolean, xdefault: rest[3] as string, array: rest[4] as boolean, - encrypt: rest[5] as boolean + encrypt: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -3304,56 +4692,61 @@ export class Databases { const xdefault = params.xdefault; const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } if (typeof encrypt !== 'undefined') { - payload['encrypt'] = encrypt; + apiPayload['encrypt'] = encrypt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update a mediumtext attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3365,10 +4758,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateMediumtextColumn` instead. */ - updateMediumtextAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateMediumtextAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a mediumtext attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -3380,15 +4780,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMediumtextAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateMediumtextAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateMediumtextAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3396,58 +4830,66 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3462,7 +4904,13 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPointColumn` instead. */ - createPointAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[] }): Promise; + createPointAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + }): Promise; /** * Create a geometric point attribute. * @@ -3475,69 +4923,104 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPointAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[]): Promise; createPointAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[] } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number[])?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: number[], + ): Promise; + createPointAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + } + | string, + ...rest: [string?, string?, boolean?, number[]?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[] }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number[] + xdefault: rest[3] as number[], }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/point'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/point' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3553,7 +5036,14 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePointColumn` instead. */ - updatePointAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[], newKey?: string }): Promise; + updatePointAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + }): Promise; /** * Update a point attribute. Changing the `default` value will not update already existing documents. * @@ -3567,15 +5057,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePointAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[], newKey?: string): Promise; updatePointAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[], newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number[])?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: number[], + newKey?: string, + ): Promise; + updatePointAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, number[]?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[], newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number[], newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3583,55 +5107,61 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as number[], - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3646,7 +5176,13 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPolygonColumn` instead. */ - createPolygonAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] }): Promise; + createPolygonAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }): Promise; /** * Create a geometric polygon attribute. * @@ -3659,69 +5195,104 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPolygonAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][]): Promise; createPolygonAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: any[][], + ): Promise; + createPolygonAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][] }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][] + xdefault: rest[3] as any[][], }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/polygon' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3737,7 +5308,14 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePolygonColumn` instead. */ - updatePolygonAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }): Promise; + updatePolygonAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }): Promise; /** * Update a polygon attribute. Changing the `default` value will not update already existing documents. * @@ -3751,15 +5329,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePolygonAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string): Promise; updatePolygonAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: any[][], + newKey?: string, + ): Promise; + updatePolygonAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3767,60 +5379,66 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as any[][], - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -3834,10 +5452,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRelationshipColumn` instead. */ - createRelationshipAttribute(params: { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }): Promise; + createRelationshipAttribute(params: { + databaseId: string; + collectionId: string; + relatedCollectionId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + }): Promise; /** * Create relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -3851,15 +5478,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRelationshipAttribute(databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise; createRelationshipAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate } | string, - ...rest: [(string)?, (string)?, (RelationshipType)?, (boolean)?, (string)?, (string)?, (RelationMutate)?] + databaseId: string, + collectionId: string, + relatedCollectionId: string, + type: RelationshipType, + twoWay?: boolean, + key?: string, + twoWayKey?: string, + onDelete?: RelationMutate, + ): Promise; + createRelationshipAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + relatedCollectionId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + } + | string, + ...rest: [ + string?, + string?, + RelationshipType?, + boolean?, + string?, + string?, + RelationMutate?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; + let params: { + databaseId: string; + collectionId: string; + relatedCollectionId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + relatedCollectionId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3869,10 +5546,10 @@ export class Databases { twoWay: rest[3] as boolean, key: rest[4] as string, twoWayKey: rest[5] as string, - onDelete: rest[6] as RelationMutate + onDelete: rest[6] as RelationMutate, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const relatedCollectionId = params.relatedCollectionId; @@ -3881,59 +5558,64 @@ export class Databases { const key = params.key; const twoWayKey = params.twoWayKey; const onDelete = params.onDelete; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof relatedCollectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "relatedCollectionId"'); + throw new AppwriteException( + 'Missing required parameter: "relatedCollectionId"', + ); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/relationship' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof relatedCollectionId !== 'undefined') { - payload['relatedCollectionId'] = relatedCollectionId; + apiPayload['relatedCollectionId'] = relatedCollectionId; } if (typeof type !== 'undefined') { - payload['type'] = type; + apiPayload['type'] = type; } if (typeof twoWay !== 'undefined') { - payload['twoWay'] = twoWay; + apiPayload['twoWay'] = twoWay; } if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof twoWayKey !== 'undefined') { - payload['twoWayKey'] = twoWayKey; + apiPayload['twoWayKey'] = twoWayKey; } if (typeof onDelete !== 'undefined') { - payload['onDelete'] = onDelete; + apiPayload['onDelete'] = onDelete; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -3944,10 +5626,16 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead. */ - updateRelationshipAttribute(params: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string }): Promise; + updateRelationshipAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + }): Promise; /** * Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -3958,68 +5646,102 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRelationshipAttribute(databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise; updateRelationshipAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string } | string, - ...rest: [(string)?, (string)?, (RelationMutate)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + onDelete?: RelationMutate, + newKey?: string, + ): Promise; + updateRelationshipAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + } + | string, + ...rest: [string?, string?, RelationMutate?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, key: rest[1] as string, onDelete: rest[2] as RelationMutate, - newKey: rest[3] as string + newKey: rest[3] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const onDelete = params.onDelete; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof onDelete !== 'undefined') { - payload['onDelete'] = onDelete; + apiPayload['onDelete'] = onDelete; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create a string attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4033,10 +5755,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createStringColumn` instead. */ - createStringAttribute(params: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createStringAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a string attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4050,15 +5781,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createStringAttribute(databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createStringAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + size: number, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createStringAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + boolean?, + string?, + boolean?, + boolean?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4068,10 +5849,10 @@ export class Databases { required: rest[3] as boolean, xdefault: rest[4] as string, array: rest[5] as boolean, - encrypt: rest[6] as boolean + encrypt: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -4080,12 +5861,15 @@ export class Databases { const xdefault = params.xdefault; const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -4094,48 +5878,50 @@ export class Databases { throw new AppwriteException('Missing required parameter: "size"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/string' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof size !== 'undefined') { - payload['size'] = size; + apiPayload['size'] = size; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } if (typeof encrypt !== 'undefined') { - payload['encrypt'] = encrypt; + apiPayload['encrypt'] = encrypt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update a string attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4148,10 +5934,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateStringColumn` instead. */ - updateStringAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }): Promise; + updateStringAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }): Promise; /** * Update a string attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4164,15 +5958,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateStringAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise; updateStringAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + size?: number, + newKey?: string, + ): Promise; + updateStringAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4181,10 +6013,10 @@ export class Databases { required: rest[2] as boolean, xdefault: rest[3] as string, size: rest[4] as number, - newKey: rest[5] as string + newKey: rest[5] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -4192,56 +6024,64 @@ export class Databases { const xdefault = params.xdefault; const size = params.size; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof size !== 'undefined') { - payload['size'] = size; + apiPayload['size'] = size; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create a text attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4254,10 +6094,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createTextColumn` instead. */ - createTextAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createTextAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a text attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4270,15 +6118,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTextAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createTextAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createTextAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4287,10 +6173,10 @@ export class Databases { required: rest[2] as boolean, xdefault: rest[3] as string, array: rest[4] as boolean, - encrypt: rest[5] as boolean + encrypt: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -4298,56 +6184,61 @@ export class Databases { const xdefault = params.xdefault; const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/text'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/text' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } if (typeof encrypt !== 'undefined') { - payload['encrypt'] = encrypt; + apiPayload['encrypt'] = encrypt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update a text attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4359,10 +6250,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. */ - updateTextAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateTextAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a text attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4374,15 +6272,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTextAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateTextAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateTextAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4390,63 +6322,71 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create a URL attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -4458,10 +6398,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createUrlColumn` instead. */ - createUrlAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createUrlAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create a URL attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -4473,15 +6420,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createUrlAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createUrlAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4489,63 +6470,68 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/url' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update an url attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -4557,10 +6543,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateUrlColumn` instead. */ - updateUrlAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateUrlAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an url attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -4572,15 +6565,49 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateUrlAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateUrlAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4588,63 +6615,71 @@ export class Databases { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create a varchar attribute. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4658,10 +6693,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createVarcharColumn` instead. */ - createVarcharAttribute(params: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createVarcharAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a varchar attribute. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4675,15 +6719,65 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVarcharAttribute(databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createVarcharAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + collectionId: string, + key: string, + size: number, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createVarcharAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + boolean?, + string?, + boolean?, + boolean?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4693,10 +6787,10 @@ export class Databases { required: rest[3] as boolean, xdefault: rest[4] as string, array: rest[5] as boolean, - encrypt: rest[6] as boolean + encrypt: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -4705,12 +6799,15 @@ export class Databases { const xdefault = params.xdefault; const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -4719,48 +6816,50 @@ export class Databases { throw new AppwriteException('Missing required parameter: "size"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/varchar' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof size !== 'undefined') { - payload['size'] = size; + apiPayload['size'] = size; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } if (typeof encrypt !== 'undefined') { - payload['encrypt'] = encrypt; + apiPayload['encrypt'] = encrypt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update a varchar attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4773,10 +6872,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateVarcharColumn` instead. */ - updateVarcharAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }): Promise; + updateVarcharAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }): Promise; /** * Update a varchar attribute. Changing the `default` value will not update already existing documents. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4789,15 +6896,53 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateVarcharAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise; updateVarcharAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + required: boolean, + xdefault?: string, + size?: number, + newKey?: string, + ): Promise; + updateVarcharAttribute( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + let params: { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4806,10 +6951,10 @@ export class Databases { required: rest[2] as boolean, xdefault: rest[3] as string, size: rest[4] as number, - newKey: rest[5] as string + newKey: rest[5] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -4817,51 +6962,59 @@ export class Databases { const xdefault = params.xdefault; const size = params.size; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof size !== 'undefined') { - payload['size'] = size; + apiPayload['size'] = size; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4874,7 +7027,22 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getColumn` instead. */ - getAttribute(params: { databaseId: string, collectionId: string, key: string }): Promise; + getAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise< + | Models.AttributeBoolean + | Models.AttributeInteger + | Models.AttributeFloat + | Models.AttributeEmail + | Models.AttributeEnum + | Models.AttributeUrl + | Models.AttributeIp + | Models.AttributeDatetime + | Models.AttributeRelationship + | Models.AttributeString + >; /** * Get attribute by ID. * @@ -4885,52 +7053,91 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getAttribute(databaseId: string, collectionId: string, key: string): Promise; getAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + databaseId: string, + collectionId: string, + key: string, + ): Promise< + | Models.AttributeBoolean + | Models.AttributeInteger + | Models.AttributeFloat + | Models.AttributeEmail + | Models.AttributeEnum + | Models.AttributeUrl + | Models.AttributeIp + | Models.AttributeDatetime + | Models.AttributeRelationship + | Models.AttributeString + >; + getAttribute( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] + ): Promise< + | Models.AttributeBoolean + | Models.AttributeInteger + | Models.AttributeFloat + | Models.AttributeEmail + | Models.AttributeEnum + | Models.AttributeUrl + | Models.AttributeIp + | Models.AttributeDatetime + | Models.AttributeRelationship + | Models.AttributeString + > { + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4943,7 +7150,11 @@ export class Databases { * @returns {Promise<{}>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteColumn` instead. */ - deleteAttribute(params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; + deleteAttribute(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise<{}>; /** * Deletes an attribute. * @@ -4954,52 +7165,69 @@ export class Databases { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteAttribute(databaseId: string, collectionId: string, key: string): Promise<{}>; deleteAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + ): Promise<{}>; + deleteAttribute( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] ): Promise<{}> { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -5015,7 +7243,16 @@ export class Databases { * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead. */ - listDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }): Promise>; + listDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }): Promise>; /** * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. * @@ -5029,15 +7266,49 @@ export class Databases { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - listDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number): Promise>; listDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number } | string, - ...rest: [(string)?, (string[])?, (string)?, (boolean)?, (number)?] + databaseId: string, + collectionId: string, + queries?: string[], + transactionId?: string, + total?: boolean, + ttl?: number, + ): Promise>; + listDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + } + | string, + ...rest: [string?, string[]?, string?, boolean?, number?] ): Promise> { - let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5045,51 +7316,54 @@ export class Databases { queries: rest[1] as string[], transactionId: rest[2] as string, total: rest[3] as boolean, - ttl: rest[4] as number + ttl: rest[4] as number, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; const transactionId = params.transactionId; const total = params.total; const ttl = params.ttl; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } if (typeof total !== 'undefined') { - payload['total'] = total; + apiPayload['total'] = total; } if (typeof ttl !== 'undefined') { - payload['ttl'] = ttl; + apiPayload['ttl'] = ttl; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -5105,7 +7379,18 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead. */ - createDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }): Promise; + createDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & Omit; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * @@ -5119,74 +7404,136 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string): Promise; createDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & Omit, + permissions?: string[], + transactionId?: string, + ): Promise; + createDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; const data = params.data; const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); } if (typeof data === 'undefined') { throw new AppwriteException('Missing required parameter: "data"'); } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof documentId !== 'undefined') { - payload['documentId'] = documentId; + apiPayload['documentId'] = documentId; } if (typeof data !== 'undefined') { - payload['data'] = data; + apiPayload['data'] = data; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5200,7 +7547,14 @@ export class Databases { * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRows` instead. */ - createDocuments(params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }): Promise>; + createDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }): Promise>; /** * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * @@ -5212,66 +7566,97 @@ export class Databases { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createDocuments(databaseId: string, collectionId: string, documents: object[], transactionId?: string): Promise>; createDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, documents: object[], transactionId?: string } | string, - ...rest: [(string)?, (object[])?, (string)?] + databaseId: string, + collectionId: string, + documents: object[], + transactionId?: string, + ): Promise>; + createDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + } + | string, + ...rest: [string?, object[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documents: rest[1] as object[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documents = params.documents; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documents === 'undefined') { - throw new AppwriteException('Missing required parameter: "documents"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "documents"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof documents !== 'undefined') { - payload['documents'] = documents; + apiPayload['documents'] = documents; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. @@ -5281,10 +7666,17 @@ export class Databases { * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead. */ - upsertDocuments(params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }): Promise>; + upsertDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }): Promise>; /** * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. - * + * * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. @@ -5294,61 +7686,92 @@ export class Databases { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - upsertDocuments(databaseId: string, collectionId: string, documents: object[], transactionId?: string): Promise>; upsertDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, documents: object[], transactionId?: string } | string, - ...rest: [(string)?, (object[])?, (string)?] + databaseId: string, + collectionId: string, + documents: object[], + transactionId?: string, + ): Promise>; + upsertDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + } + | string, + ...rest: [string?, object[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documents: rest[1] as object[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documents = params.documents; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documents === 'undefined') { - throw new AppwriteException('Missing required parameter: "documents"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "documents"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof documents !== 'undefined') { - payload['documents'] = documents; + apiPayload['documents'] = documents; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -5363,7 +7786,15 @@ export class Databases { * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRows` instead. */ - updateDocuments(params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }): Promise>; + updateDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }): Promise>; /** * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. * @@ -5376,63 +7807,96 @@ export class Databases { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDocuments(databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string): Promise>; updateDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (object)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + data?: object, + queries?: string[], + transactionId?: string, + ): Promise>; + updateDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, object?, string[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, data: rest[1] as object, queries: rest[2] as string[], - transactionId: rest[3] as string + transactionId: rest[3] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const data = params.data; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof data !== 'undefined') { - payload['data'] = data; + apiPayload['data'] = data; } if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5446,7 +7910,14 @@ export class Databases { * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRows` instead. */ - deleteDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }): Promise>; + deleteDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }): Promise>; /** * Bulk delete documents using queries, if no queries are passed then all documents are deleted. * @@ -5458,58 +7929,87 @@ export class Databases { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string): Promise>; deleteDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + queries?: string[], + transactionId?: string, + ): Promise>; + deleteDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string[]?, string?] ): Promise> { - let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, queries: rest[1] as string[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -5524,7 +8024,15 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead. */ - getDocument(params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }): Promise; + getDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }): Promise; /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * @@ -5537,62 +8045,101 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string): Promise; getDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + queries?: string[], + transactionId?: string, + ): Promise; + getDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string[]?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, queries: rest[2] as string[], - transactionId: rest[3] as string + transactionId: rest[3] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -5608,7 +8155,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead. */ - upsertDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + upsertDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * @@ -5622,68 +8181,135 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - upsertDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; upsertDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + upsertDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; const data = params.data; const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); + const apiPayload: Payload = {}; if (typeof data !== 'undefined') { - payload['data'] = data; + apiPayload['data'] = data; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -5699,7 +8325,19 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead. */ - updateDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + updateDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. * @@ -5713,68 +8351,135 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; updateDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + updateDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; const data = params.data; const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); + const apiPayload: Payload = {}; if (typeof data !== 'undefined') { - payload['data'] = data; + apiPayload['data'] = data; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5788,7 +8493,12 @@ export class Databases { * @returns {Promise<{}>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead. */ - deleteDocument(params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }): Promise<{}>; + deleteDocument(params: { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }): Promise<{}>; /** * Delete a document by its unique ID. * @@ -5800,57 +8510,92 @@ export class Databases { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteDocument(databaseId: string, collectionId: string, documentId: string, transactionId?: string): Promise<{}>; deleteDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + databaseId: string, + collectionId: string, + documentId: string, + transactionId?: string, + ): Promise<{}>; + deleteDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?] ): Promise<{}> { - let params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, documentId: rest[1] as string, - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); + const apiPayload: Payload = {}; if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -5867,7 +8612,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead. */ - decrementDocumentAttribute(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }): Promise; + decrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + }): Promise; /** * Decrement a specific attribute of a document by a given value. * @@ -5882,15 +8637,57 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - decrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string): Promise; - decrementDocumentAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] + decrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + databaseId: string, + collectionId: string, + documentId: string, + attribute: string, + value?: number, + min?: number, + transactionId?: string, + ): Promise; + decrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?, number?, number?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5899,10 +8696,10 @@ export class Databases { attribute: rest[2] as string, value: rest[3] as number, min: rest[4] as number, - transactionId: rest[5] as string + transactionId: rest[5] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; @@ -5910,45 +8707,54 @@ export class Databases { const value = params.value; const min = params.min; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); } if (typeof attribute === 'undefined') { - throw new AppwriteException('Missing required parameter: "attribute"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))).replace('{attribute}', encodeURIComponent(String(attribute))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "attribute"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{documentId}', encodeURIComponent(String(documentId))) + .replace('{attribute}', encodeURIComponent(String(attribute))); + const apiPayload: Payload = {}; if (typeof value !== 'undefined') { - payload['value'] = value; + apiPayload['value'] = value; } if (typeof min !== 'undefined') { - payload['min'] = min; + apiPayload['min'] = min; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5965,7 +8771,17 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead. */ - incrementDocumentAttribute(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }): Promise; + incrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + }): Promise; /** * Increment a specific attribute of a document by a given value. * @@ -5980,15 +8796,57 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - incrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string): Promise; - incrementDocumentAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] + incrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + databaseId: string, + collectionId: string, + documentId: string, + attribute: string, + value?: number, + max?: number, + transactionId?: string, + ): Promise; + incrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?, number?, number?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }; + let params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5997,10 +8855,10 @@ export class Databases { attribute: rest[2] as string, value: rest[3] as number, max: rest[4] as number, - transactionId: rest[5] as string + transactionId: rest[5] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const documentId = params.documentId; @@ -6008,45 +8866,54 @@ export class Databases { const value = params.value; const max = params.max; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); } if (typeof attribute === 'undefined') { - throw new AppwriteException('Missing required parameter: "attribute"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{documentId}', encodeURIComponent(String(documentId))).replace('{attribute}', encodeURIComponent(String(attribute))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "attribute"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{documentId}', encodeURIComponent(String(documentId))) + .replace('{attribute}', encodeURIComponent(String(attribute))); + const apiPayload: Payload = {}; if (typeof value !== 'undefined') { - payload['value'] = value; + apiPayload['value'] = value; } if (typeof max !== 'undefined') { - payload['max'] = max; + apiPayload['max'] = max; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6060,7 +8927,12 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listIndexes` instead. */ - listIndexes(params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }): Promise; + listIndexes(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List indexes in the collection. * @@ -6072,57 +8944,86 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listIndexes(databaseId: string, collectionId: string, queries?: string[], total?: boolean): Promise; listIndexes( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?] + databaseId: string, + collectionId: string, + queries?: string[], + total?: boolean, + ): Promise; + listIndexes( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + } + | string, + ...rest: [string?, string[]?, boolean?] ): Promise { - let params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, queries: rest[1] as string[], - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -6140,7 +9041,15 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIndex` instead. */ - createIndex(params: { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }): Promise; + createIndex(params: { + databaseId: string; + collectionId: string; + key: string; + type: DatabasesIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }): Promise; /** * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. * Attributes can be `key`, `fulltext`, and `unique`. @@ -6156,15 +9065,60 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIndex(databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[]): Promise; createIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] } | string, - ...rest: [(string)?, (string)?, (DatabasesIndexType)?, (string[])?, (OrderBy[])?, (number[])?] + databaseId: string, + collectionId: string, + key: string, + type: DatabasesIndexType, + attributes: string[], + orders?: OrderBy[], + lengths?: number[], + ): Promise; + createIndex( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + type: DatabasesIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + } + | string, + ...rest: [ + string?, + string?, + DatabasesIndexType?, + string[]?, + OrderBy[]?, + number[]?, + ] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; + let params: { + databaseId: string; + collectionId: string; + key: string; + type: DatabasesIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + type: DatabasesIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -6173,10 +9127,10 @@ export class Databases { type: rest[2] as DatabasesIndexType, attributes: rest[3] as string[], orders: rest[4] as OrderBy[], - lengths: rest[5] as number[] + lengths: rest[5] as number[], }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; @@ -6184,12 +9138,15 @@ export class Databases { const attributes = params.attributes; const orders = params.orders; const lengths = params.lengths; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -6198,40 +9155,42 @@ export class Databases { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof attributes === 'undefined') { - throw new AppwriteException('Missing required parameter: "attributes"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "attributes"', + ); + } + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof type !== 'undefined') { - payload['type'] = type; + apiPayload['type'] = type; } if (typeof attributes !== 'undefined') { - payload['attributes'] = attributes; + apiPayload['attributes'] = attributes; } if (typeof orders !== 'undefined') { - payload['orders'] = orders; + apiPayload['orders'] = orders; } if (typeof lengths !== 'undefined') { - payload['lengths'] = lengths; + apiPayload['lengths'] = lengths; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -6244,7 +9203,11 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getIndex` instead. */ - getIndex(params: { databaseId: string, collectionId: string, key: string }): Promise; + getIndex(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise; /** * Get an index by its unique ID. * @@ -6255,52 +9218,69 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getIndex(databaseId: string, collectionId: string, key: string): Promise; getIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + ): Promise; + getIndex( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -6313,7 +9293,11 @@ export class Databases { * @returns {Promise<{}>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteIndex` instead. */ - deleteIndex(params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; + deleteIndex(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise<{}>; /** * Delete an index. * @@ -6324,51 +9308,68 @@ export class Databases { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteIndex(databaseId: string, collectionId: string, key: string): Promise<{}>; deleteIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] + databaseId: string, + collectionId: string, + key: string, + ): Promise<{}>; + deleteIndex( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] ): Promise<{}> { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const collectionId = params.collectionId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{collectionId}', encodeURIComponent(String(collectionId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + const apiPath = + '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } } diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts new file mode 100644 index 00000000..3e5525b1 --- /dev/null +++ b/src/services/documents-db.ts @@ -0,0 +1,3809 @@ +import { AppwriteException, Client, type Payload } from '../client'; +import type { Models } from '../models'; + +import { DocumentsDBIndexType } from '../enums/documents-db-index-type'; +import { OrderBy } from '../enums/order-by'; +export class DocumentsDB { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * Get a list of all databases from the current Appwrite project. You can use the search parameter 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 columns: name + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + list(params?: { + queries?: string[]; + total?: boolean; + }): Promise; + /** + * Get a list of all databases from the current Appwrite project. You can use the search parameter 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 columns: name + * @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. + */ + list(queries?: string[], total?: boolean): Promise; + list( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] + ): Promise { + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 = '/documentsdb'; + 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 Database. + * + * + * @param {string} params.databaseId - Unique 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 - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {string} params.specification - Database specification. Defaults to `serverless`, which creates the database on the shared pool. Any other value provisions a dedicated database on that specification. + * @param {number} params.replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Requires a dedicated `specification`; must be 0 for a serverless database. High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode for the dedicated database backing this database. Requires a dedicated `specification`; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. + * @throws {AppwriteException} + * @returns {Promise} + */ + create(params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }): Promise; + /** + * Create a new Database. + * + * + * @param {string} databaseId - Unique 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 - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {string} specification - Database specification. Defaults to `serverless`, which creates the database on the shared pool. Any other value provisions a dedicated database on that specification. + * @param {number} replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Requires a dedicated `specification`; must be 0 for a serverless database. High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode for the dedicated database backing this database. Requires a dedicated `specification`; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create( + databaseId: string, + name: string, + enabled?: boolean, + specification?: string, + replicas?: number, + syncMode?: string, + ): Promise; + create( + paramsOrFirst: + | { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + } + | string, + ...rest: [string?, boolean?, string?, number?, string?] + ): Promise { + let params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + specification: rest[2] as string, + replicas: rest[3] as number, + syncMode: rest[4] as string, + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + const specification = params.specification; + const replicas = params.replicas; + const syncMode = params.syncMode; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/documentsdb'; + const apiPayload: Payload = {}; + if (typeof databaseId !== 'undefined') { + apiPayload['databaseId'] = databaseId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof specification !== 'undefined') { + apiPayload['specification'] = specification; + } + if (typeof replicas !== 'undefined') { + apiPayload['replicas'] = replicas; + } + if (typeof syncMode !== 'undefined') { + apiPayload['syncMode'] = syncMode; + } + 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 the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + listSpecifications(): Promise { + const apiPath = '/documentsdb/specifications'; + 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); + } + + /** + * 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). + * @throws {AppwriteException} + * @returns {Promise} + */ + listTransactions(params?: { + queries?: string[]; + }): 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). + * @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[], + ): Promise { + let params: { queries?: string[] }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[], + }; + } + + const queries = params.queries; + const apiPath = '/documentsdb/transactions'; + 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 transaction. + * + * @param {number} params.ttl - Seconds before the transaction expires. + * @throws {AppwriteException} + * @returns {Promise} + */ + createTransaction(params?: { ttl?: number }): Promise; + /** + * Create a new transaction. + * + * @param {number} ttl - Seconds before the transaction expires. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTransaction(ttl?: number): Promise; + createTransaction( + paramsOrFirst?: { ttl?: number } | number, + ): Promise { + let params: { ttl?: number }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { ttl?: number }; + } else { + params = { + ttl: paramsOrFirst as number, + }; + } + + const ttl = params.ttl; + const apiPath = '/documentsdb/transactions'; + const apiPayload: Payload = {}; + 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); + } + + /** + * Get a transaction by its unique ID. + * + * @param {string} params.transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getTransaction(params: { + transactionId: string; + }): Promise; + /** + * Get a transaction by its unique ID. + * + * @param {string} transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getTransaction(transactionId: string): Promise; + getTransaction( + paramsOrFirst: { transactionId: string } | string, + ): Promise { + let params: { transactionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { transactionId: string }; + } else { + params = { + transactionId: paramsOrFirst as string, + }; + } + + const transactionId = params.transactionId; + if (typeof transactionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); + } + const apiPath = '/documentsdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + 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 transaction, to either commit or roll back its operations. + * + * @param {string} params.transactionId - Transaction ID. + * @param {boolean} params.commit - Commit transaction? + * @param {boolean} params.rollback - Rollback transaction? + * @throws {AppwriteException} + * @returns {Promise} + */ + updateTransaction(params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }): Promise; + /** + * Update a transaction, to either commit or roll back its operations. + * + * @param {string} transactionId - Transaction ID. + * @param {boolean} commit - Commit transaction? + * @param {boolean} rollback - Rollback transaction? + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTransaction( + transactionId: string, + commit?: boolean, + rollback?: boolean, + ): Promise; + updateTransaction( + paramsOrFirst: + | { transactionId: string; commit?: boolean; rollback?: boolean } + | string, + ...rest: [boolean?, boolean?] + ): Promise { + let params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; + } else { + params = { + transactionId: paramsOrFirst as string, + commit: rest[0] as boolean, + rollback: rest[1] as boolean, + }; + } + + const transactionId = params.transactionId; + const commit = params.commit; + const rollback = params.rollback; + if (typeof transactionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); + } + const apiPath = '/documentsdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + const apiPayload: Payload = {}; + if (typeof commit !== 'undefined') { + apiPayload['commit'] = commit; + } + if (typeof rollback !== 'undefined') { + apiPayload['rollback'] = rollback; + } + 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 a transaction by its unique ID. + * + * @param {string} params.transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteTransaction(params: { transactionId: string }): Promise<{}>; + /** + * Delete a transaction by its unique ID. + * + * @param {string} transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteTransaction(transactionId: string): Promise<{}>; + deleteTransaction( + paramsOrFirst: { transactionId: string } | string, + ): Promise<{}> { + let params: { transactionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { transactionId: string }; + } else { + params = { + transactionId: paramsOrFirst as string, + }; + } + + const transactionId = params.transactionId; + if (typeof transactionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); + } + const apiPath = '/documentsdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + 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', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } + + /** + * Create multiple operations in a single transaction. + * + * @param {string} params.transactionId - Transaction ID. + * @param {object[]} params.operations - Array of staged operations. + * @throws {AppwriteException} + * @returns {Promise} + */ + createOperations(params: { + transactionId: string; + operations?: object[]; + }): Promise; + /** + * Create multiple operations in a single transaction. + * + * @param {string} transactionId - Transaction ID. + * @param {object[]} operations - Array of staged operations. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createOperations( + transactionId: string, + operations?: object[], + ): Promise; + createOperations( + paramsOrFirst: + { transactionId: string; operations?: object[] } | string, + ...rest: [object[]?] + ): Promise { + let params: { transactionId: string; operations?: object[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + transactionId: string; + operations?: object[]; + }; + } else { + params = { + transactionId: paramsOrFirst as string, + operations: rest[0] as object[], + }; + } + + const transactionId = params.transactionId; + const operations = params.operations; + if (typeof transactionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); + } + const apiPath = + '/documentsdb/transactions/{transactionId}/operations'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + const apiPayload: Payload = {}; + if (typeof operations !== 'undefined') { + apiPayload['operations'] = operations; + } + 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 database by its unique ID. This endpoint response returns a JSON object with the database metadata. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + get(params: { databaseId: string }): Promise; + /** + * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(databaseId: string): Promise; + get( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/documentsdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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 database by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.name - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {string} params.specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. + * @param {number} params.replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. + * @throws {AppwriteException} + * @returns {Promise} + */ + update(params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }): Promise; + /** + * Update a database by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} name - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {string} specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. + * @param {number} replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update( + databaseId: string, + name: string, + enabled?: boolean, + specification?: string, + replicas?: number, + syncMode?: string, + ): Promise; + update( + paramsOrFirst: + | { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + } + | string, + ...rest: [string?, boolean?, string?, number?, string?] + ): Promise { + let params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + specification: rest[2] as string, + replicas: rest[3] as number, + syncMode: rest[4] as string, + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + const specification = params.specification; + const replicas = params.replicas; + const syncMode = params.syncMode; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/documentsdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof specification !== 'undefined') { + apiPayload['specification'] = specification; + } + if (typeof replicas !== 'undefined') { + apiPayload['replicas'] = replicas; + } + if (typeof syncMode !== 'undefined') { + apiPayload['syncMode'] = syncMode; + } + 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 database by its unique ID. Only API keys with with databases.write scope can delete a database. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { databaseId: string }): Promise<{}>; + /** + * Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(databaseId: string): Promise<{}>; + delete(paramsOrFirst: { databaseId: string } | string): Promise<{}> { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/documentsdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } + + /** + * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. + * + * @param {string} params.databaseId - Database 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: name, enabled, documentSecurity + * @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} + */ + listCollections(params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; + /** + * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. + * + * @param {string} databaseId - Database 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: name, enabled, documentSecurity + * @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. + */ + listCollections( + databaseId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listCollections( + paramsOrFirst: + | { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] + ): Promise { + let params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string, + total: rest[2] as boolean, + }; + } + + const databaseId = params.databaseId; + const queries = params.queries; + const search = params.search; + const total = params.total; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/documentsdb/{databaseId}/collections'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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 new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Unique 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 - Collection name. Max length: 128 chars. + * @param {string[]} params.permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @param {object[]} params.attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @throws {AppwriteException} + * @returns {Promise} + */ + createCollection(params: { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + }): Promise; + /** + * Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Unique 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 - Collection name. Max length: 128 chars. + * @param {string[]} permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @param {object[]} attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createCollection( + databaseId: string, + collectionId: string, + name: string, + permissions?: string[], + documentSecurity?: boolean, + enabled?: boolean, + attributes?: object[], + indexes?: object[], + ): Promise; + createCollection( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + } + | string, + ...rest: [ + string?, + string?, + string[]?, + boolean?, + boolean?, + object[]?, + object[]?, + ] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + attributes?: object[]; + indexes?: object[]; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + name: rest[1] as string, + permissions: rest[2] as string[], + documentSecurity: rest[3] as boolean, + enabled: rest[4] as boolean, + attributes: rest[5] as object[], + indexes: rest[6] as object[], + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const name = params.name; + const permissions = params.permissions; + const documentSecurity = params.documentSecurity; + const enabled = params.enabled; + const attributes = params.attributes; + const indexes = params.indexes; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/documentsdb/{databaseId}/collections'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof collectionId !== 'undefined') { + apiPayload['collectionId'] = collectionId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof permissions !== 'undefined') { + apiPayload['permissions'] = permissions; + } + if (typeof documentSecurity !== 'undefined') { + apiPayload['documentSecurity'] = documentSecurity; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof attributes !== 'undefined') { + apiPayload['attributes'] = attributes; + } + if (typeof indexes !== 'undefined') { + apiPayload['indexes'] = indexes; + } + 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 collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getCollection(params: { + databaseId: string; + collectionId: string; + }): Promise; + /** + * Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getCollection( + databaseId: string, + collectionId: string, + ): Promise; + getCollection( + paramsOrFirst: { databaseId: string; collectionId: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; collectionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + 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 collection by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.name - Collection name. Max length: 128 chars. + * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @param {boolean} params.purge - When true, purge all cached list responses for this collection as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateCollection(params: { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }): Promise; + /** + * Update a collection by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} name - Collection name. Max length: 128 chars. + * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @param {boolean} purge - When true, purge all cached list responses for this collection as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateCollection( + databaseId: string, + collectionId: string, + name: string, + permissions?: string[], + documentSecurity?: boolean, + enabled?: boolean, + purge?: boolean, + ): Promise; + updateCollection( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + } + | string, + ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + name: string; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + name: rest[1] as string, + permissions: rest[2] as string[], + documentSecurity: rest[3] as boolean, + enabled: rest[4] as boolean, + purge: rest[5] as boolean, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const name = params.name; + const permissions = params.permissions; + const documentSecurity = params.documentSecurity; + const enabled = params.enabled; + const purge = params.purge; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof permissions !== 'undefined') { + apiPayload['permissions'] = permissions; + } + if (typeof documentSecurity !== 'undefined') { + apiPayload['documentSecurity'] = documentSecurity; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof purge !== 'undefined') { + apiPayload['purge'] = purge; + } + 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 collection by its unique ID. Only users with write permissions have access to delete this resource. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteCollection(params: { + databaseId: string; + collectionId: string; + }): Promise<{}>; + /** + * Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteCollection(databaseId: string, collectionId: string): Promise<{}>; + deleteCollection( + paramsOrFirst: { databaseId: string; collectionId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { databaseId: string; collectionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + 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', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } + + /** + * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @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.transactionId - Transaction ID to read uncommitted changes within the transaction. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @param {number} params.ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + * @throws {AppwriteException} + * @returns {Promise>} + */ + listDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }): Promise>; + /** + * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @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} transactionId - Transaction ID to read uncommitted changes within the transaction. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @param {number} ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listDocuments( + databaseId: string, + collectionId: string, + queries?: string[], + transactionId?: string, + total?: boolean, + ttl?: number, + ): Promise>; + listDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + } + | string, + ...rest: [string?, string[]?, string?, boolean?, number?] + ): Promise> { + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + transactionId: rest[2] as string, + total: rest[3] as boolean, + ttl: rest[4] as number, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const transactionId = params.transactionId; + const total = params.total; + const ttl = params.ttl; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + 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, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {string} params.documentId - Document 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 {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} params.data - Document data as JSON object. + * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise} + */ + createDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & Omit; + permissions?: string[]; + }): Promise; + /** + * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {string} documentId - Document 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 {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} data - Document data as JSON object. + * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDocument( + databaseId: string, + collectionId: string, + documentId: string, + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & Omit, + permissions?: string[], + ): Promise; + createDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit)?, + string[]?, + ] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit, + permissions: rest[3] as string[], + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + if (typeof data === 'undefined') { + throw new AppwriteException('Missing required parameter: "data"'); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof documentId !== 'undefined') { + apiPayload['documentId'] = documentId; + } + if (typeof data !== 'undefined') { + apiPayload['data'] = data; + } + if (typeof permissions !== 'undefined') { + apiPayload['permissions'] = permissions; + } + 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); + } + + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {object[]} params.documents - Array of documents data as JSON objects. + * @throws {AppwriteException} + * @returns {Promise>} + */ + createDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documents: object[]; + }): Promise>; + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {object[]} documents - Array of documents data as JSON objects. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDocuments( + databaseId: string, + collectionId: string, + documents: object[], + ): Promise>; + createDocuments( + paramsOrFirst: + | { databaseId: string; collectionId: string; documents: object[] } + | string, + ...rest: [string?, object[]?] + ): Promise> { + let params: { + databaseId: string; + collectionId: string; + documents: object[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documents: object[]; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documents: rest[1] as object[], + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documents = params.documents; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documents === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documents"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof documents !== 'undefined') { + apiPayload['documents'] = documents; + } + 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); + } + + /** + * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {object[]} params.documents - Array of document data as JSON objects. May contain partial documents. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + */ + upsertDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }): Promise>; + /** + * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {object[]} documents - Array of document data as JSON objects. May contain partial documents. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + upsertDocuments( + databaseId: string, + collectionId: string, + documents: object[], + transactionId?: string, + ): Promise>; + upsertDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + } + | string, + ...rest: [string?, object[]?, string?] + ): Promise> { + let params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documents: rest[1] as object[], + transactionId: rest[2] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documents = params.documents; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documents === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documents"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof documents !== 'undefined') { + apiPayload['documents'] = documents; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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); + } + + /** + * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {object} params.data - Document data as JSON object. Include only attribute and value pairs to be updated. + * @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.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + */ + updateDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }): Promise>; + /** + * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {object} data - Document data as JSON object. Include only attribute and value pairs to be updated. + * @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} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDocuments( + databaseId: string, + collectionId: string, + data?: object, + queries?: string[], + transactionId?: string, + ): Promise>; + updateDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, object?, string[]?, string?] + ): Promise> { + let params: { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + data: rest[1] as object, + queries: rest[2] as string[], + transactionId: rest[3] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const data = params.data; + const queries = params.queries; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof data !== 'undefined') { + apiPayload['data'] = data; + } + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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); + } + + /** + * Bulk delete documents using queries, if no queries are passed then all documents are deleted. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @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.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + */ + deleteDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }): Promise>; + /** + * Bulk delete documents using queries, if no queries are passed then all documents are deleted. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @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} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteDocuments( + databaseId: string, + collectionId: string, + queries?: string[], + transactionId?: string, + ): Promise>; + deleteDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string[]?, string?] + ): Promise> { + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + transactionId: rest[2] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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 document by its unique ID. This endpoint response returns a JSON object with the document data. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.documentId - Document 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. + * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. + * @throws {AppwriteException} + * @returns {Promise} + */ + getDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }): Promise; + /** + * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} documentId - Document 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. + * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getDocument( + databaseId: string, + collectionId: string, + documentId: string, + queries?: string[], + transactionId?: string, + ): Promise; + getDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string[]?, string?] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + queries: rest[2] as string[], + transactionId: rest[3] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const queries = params.queries; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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 or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} params.data - Document data as JSON object. Include all required fields of the document to be created or updated. + * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + */ + upsertDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; + /** + * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} data - Document data as JSON object. Include all required fields of the document to be created or updated. + * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + upsertDocument( + databaseId: string, + collectionId: string, + documentId: string, + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + upsertDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>)?, + string[]?, + string?, + ] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions: rest[3] as string[], + transactionId: rest[4] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); + const apiPayload: Payload = {}; + if (typeof data !== 'undefined') { + apiPayload['data'] = data; + } + if (typeof permissions !== 'undefined') { + apiPayload['permissions'] = permissions; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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); + } + + /** + * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} params.data - Document data as JSON object. Include only fields and value pairs to be updated. + * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; + /** + * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} data - Document data as JSON object. Include only fields and value pairs to be updated. + * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDocument( + databaseId: string, + collectionId: string, + documentId: string, + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + updateDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>)?, + string[]?, + string?, + ] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions: rest[3] as string[], + transactionId: rest[4] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); + const apiPayload: Payload = {}; + if (typeof data !== 'undefined') { + apiPayload['data'] = data; + } + if (typeof permissions !== 'undefined') { + apiPayload['permissions'] = permissions; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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 a document by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.documentId - Document ID. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteDocument(params: { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }): Promise<{}>; + /** + * Delete a document by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} documentId - Document ID. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteDocument( + databaseId: string, + collectionId: string, + documentId: string, + transactionId?: string, + ): Promise<{}>; + deleteDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?] + ): Promise<{}> { + let params: { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + transactionId: rest[2] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); + const apiPayload: Payload = {}; + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } + + /** + * Decrement a specific column of a row by a given value. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {string} params.attribute - Attribute key. + * @param {number} params.value - Value to decrement the attribute by. The value must be a number. + * @param {number} params.min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + */ + decrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + }): Promise; + /** + * Decrement a specific column of a row by a given value. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {string} attribute - Attribute key. + * @param {number} value - Value to decrement the attribute by. The value must be a number. + * @param {number} min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + decrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + databaseId: string, + collectionId: string, + documentId: string, + attribute: string, + value?: number, + min?: number, + transactionId?: string, + ): Promise; + decrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?, number?, number?, string?] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + min?: number; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + attribute: rest[2] as string, + value: rest[3] as number, + min: rest[4] as number, + transactionId: rest[5] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const attribute = params.attribute; + const value = params.value; + const min = params.min; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + if (typeof attribute === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "attribute"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{documentId}', encodeURIComponent(String(documentId))) + .replace('{attribute}', encodeURIComponent(String(attribute))); + const apiPayload: Payload = {}; + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof min !== 'undefined') { + apiPayload['min'] = min; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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); + } + + /** + * Increment a specific column of a row by a given value. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {string} params.attribute - Attribute key. + * @param {number} params.value - Value to increment the attribute by. The value must be a number. + * @param {number} params.max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + */ + incrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + }): Promise; + /** + * Increment a specific column of a row by a given value. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {string} attribute - Attribute key. + * @param {number} value - Value to increment the attribute by. The value must be a number. + * @param {number} max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + incrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + databaseId: string, + collectionId: string, + documentId: string, + attribute: string, + value?: number, + max?: number, + transactionId?: string, + ): Promise; + incrementDocumentAttribute< + Document extends Models.Document = Models.DefaultDocument, + >( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?, number?, number?, string?] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + attribute: string; + value?: number; + max?: number; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + attribute: rest[2] as string, + value: rest[3] as number, + max: rest[4] as number, + transactionId: rest[5] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const attribute = params.attribute; + const value = params.value; + const max = params.max; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + if (typeof attribute === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "attribute"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{documentId}', encodeURIComponent(String(documentId))) + .replace('{attribute}', encodeURIComponent(String(attribute))); + const apiPayload: Payload = {}; + if (typeof value !== 'undefined') { + apiPayload['value'] = value; + } + if (typeof max !== 'undefined') { + apiPayload['max'] = max; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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 indexes in the collection. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @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: key, type, status, attributes, error + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listIndexes(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }): Promise; + /** + * List indexes in the collection. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @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: key, type, status, attributes, error + * @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. + */ + listIndexes( + databaseId: string, + collectionId: string, + queries?: string[], + total?: boolean, + ): Promise; + listIndexes( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + } + | string, + ...rest: [string?, string[]?, boolean?] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + total: rest[2] as boolean, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const total = params.total; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + 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); + } + + /** + * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. + * Attributes can be `key`, `fulltext`, and `unique`. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @param {DocumentsDBIndexType} params.type - Index type. + * @param {string[]} params.attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. + * @param {OrderBy[]} params.orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} params.lengths - Length of index. Maximum of 100 + * @throws {AppwriteException} + * @returns {Promise} + */ + createIndex(params: { + databaseId: string; + collectionId: string; + key: string; + type: DocumentsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }): Promise; + /** + * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. + * Attributes can be `key`, `fulltext`, and `unique`. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @param {DocumentsDBIndexType} type - Index type. + * @param {string[]} attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. + * @param {OrderBy[]} orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} lengths - Length of index. Maximum of 100 + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIndex( + databaseId: string, + collectionId: string, + key: string, + type: DocumentsDBIndexType, + attributes: string[], + orders?: OrderBy[], + lengths?: number[], + ): Promise; + createIndex( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + type: DocumentsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + } + | string, + ...rest: [ + string?, + string?, + DocumentsDBIndexType?, + string[]?, + OrderBy[]?, + number[]?, + ] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + key: string; + type: DocumentsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + type: DocumentsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + type: rest[2] as DocumentsDBIndexType, + attributes: rest[3] as string[], + orders: rest[4] as OrderBy[], + lengths: rest[5] as number[], + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const type = params.type; + const attributes = params.attributes; + const orders = params.orders; + const lengths = params.lengths; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (typeof attributes === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "attributes"', + ); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof type !== 'undefined') { + apiPayload['type'] = type; + } + if (typeof attributes !== 'undefined') { + apiPayload['attributes'] = attributes; + } + if (typeof orders !== 'undefined') { + apiPayload['orders'] = orders; + } + if (typeof lengths !== 'undefined') { + apiPayload['lengths'] = lengths; + } + 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 index by ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @throws {AppwriteException} + * @returns {Promise} + */ + getIndex(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise; + /** + * Get index by ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getIndex( + databaseId: string, + collectionId: string, + key: string, + ): Promise; + getIndex( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] + ): Promise { + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + 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 an index. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteIndex(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise<{}>; + /** + * Delete an index. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteIndex( + databaseId: string, + collectionId: string, + key: string, + ): Promise<{}>; + deleteIndex( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] + ): Promise<{}> { + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + const apiPath = + '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + 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', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } + + /** + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. + * @throws {AppwriteException} + * @returns {Promise} + */ + createFailover(params: { + databaseId: string; + targetReplicaId?: string; + }): Promise; + /** + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. + * + * @param {string} databaseId - Database ID. + * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFailover( + databaseId: string, + targetReplicaId?: string, + ): Promise; + createFailover( + paramsOrFirst: + { databaseId: string; targetReplicaId?: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; targetReplicaId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetReplicaId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + targetReplicaId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const targetReplicaId = params.targetReplicaId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/documentsdb/{databaseId}/failovers'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof targetReplicaId !== 'undefined') { + apiPayload['targetReplicaId'] = targetReplicaId; + } + 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 the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.status - Filter by operation status. + * @param {number} params.limit - Maximum number of operations to return. + * @param {number} params.offset - Number of operations to skip. + * @throws {AppwriteException} + * @returns {Promise} + */ + listOperations(params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }): Promise; + /** + * List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. + * + * @param {string} databaseId - Database ID. + * @param {string} status - Filter by operation status. + * @param {number} limit - Maximum number of operations to return. + * @param {number} offset - Number of operations to skip. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listOperations( + databaseId: string, + status?: string, + limit?: number, + offset?: number, + ): Promise; + listOperations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, number?, number?] + ): Promise { + let params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + status: rest[0] as string, + limit: rest[1] as number, + offset: rest[2] as number, + }; + } + + const databaseId = params.databaseId; + const status = params.status; + const limit = params.limit; + const offset = params.offset; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/documentsdb/{databaseId}/operations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof status !== 'undefined') { + apiPayload['status'] = status; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof offset !== 'undefined') { + apiPayload['offset'] = offset; + } + 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 high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getReplicas(params: { + databaseId: string; + }): Promise; + /** + * Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getReplicas(databaseId: string): Promise; + getReplicas( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/documentsdb/{databaseId}/replicas'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getStatus(params: { databaseId: string }): Promise; + /** + * Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getStatus(databaseId: string): Promise; + getStatus( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/documentsdb/{databaseId}/status'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } +} diff --git a/src/services/embeddings.ts b/src/services/embeddings.ts index 0a38c3a7..ff08ad9f 100644 --- a/src/services/embeddings.ts +++ b/src/services/embeddings.ts @@ -1,9 +1,7 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - import { EmbeddingModel } from '../enums/embedding-model'; - export class Embeddings { client: Client; @@ -13,17 +11,20 @@ export class Embeddings { /** * Generate vector embeddings for an array of text using the selected embedding model. Use the returned vectors to power semantic search and similarity queries against your vector collections. - * + * * * @param {string[]} params.texts - Array of text to generate embeddings. * @param {EmbeddingModel} params.model - The embedding model to use for generating vector embeddings. * @throws {AppwriteException} * @returns {Promise} */ - createTextEmbeddings(params: { texts: string[], model?: EmbeddingModel }): Promise; + createTextEmbeddings(params: { + texts: string[]; + model?: EmbeddingModel; + }): Promise; /** * Generate vector embeddings for an array of text using the selected embedding model. Use the returned vectors to power semantic search and similarity queries against your vector collections. - * + * * * @param {string[]} texts - Array of text to generate embeddings. * @param {EmbeddingModel} model - The embedding model to use for generating vector embeddings. @@ -31,50 +32,53 @@ export class Embeddings { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTextEmbeddings(texts: string[], model?: EmbeddingModel): Promise; createTextEmbeddings( - paramsOrFirst: { texts: string[], model?: EmbeddingModel } | string[], - ...rest: [(EmbeddingModel)?] + texts: string[], + model?: EmbeddingModel, + ): Promise; + createTextEmbeddings( + paramsOrFirst: { texts: string[]; model?: EmbeddingModel } | string[], + ...rest: [EmbeddingModel?] ): Promise { - let params: { texts: string[], model?: EmbeddingModel }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { texts: string[], model?: EmbeddingModel }; + let params: { texts: string[]; model?: EmbeddingModel }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + texts: string[]; + model?: EmbeddingModel; + }; } else { params = { texts: paramsOrFirst as string[], - model: rest[0] as EmbeddingModel + model: rest[0] as EmbeddingModel, }; } - + const texts = params.texts; const model = params.model; - if (typeof texts === 'undefined') { throw new AppwriteException('Missing required parameter: "texts"'); } - const apiPath = '/embeddings/text'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof texts !== 'undefined') { - payload['texts'] = texts; + apiPayload['texts'] = texts; } if (typeof model !== 'undefined') { - payload['model'] = model; + apiPayload['model'] = model; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } } diff --git a/src/services/functions.ts b/src/services/functions.ts index 66c218f8..612fd14f 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -1,6 +1,10 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { + AppwriteException, + Client, + type Payload, + UploadProgress, +} from '../client'; import type { Models } from '../models'; - import { InputFile } from '../inputFile'; import { Runtime } from '../enums/runtime'; @@ -9,7 +13,6 @@ import { TemplateReferenceType } from '../enums/template-reference-type'; import { VCSReferenceType } from '../enums/vcs-reference-type'; import { DeploymentDownloadType } from '../enums/deployment-download-type'; import { ExecutionMethod } from '../enums/execution-method'; - export class Functions { client: Client; @@ -26,7 +29,11 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + list(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all the project's functions. You can use the query params to filter your results. * @@ -37,52 +44,59 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string, total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + list( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - - const apiPath = '/functions'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -113,7 +127,30 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - create(params: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; + create(params: { + functionId: string; + name: string; + runtime: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + }): Promise; /** * Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API. * @@ -143,15 +180,135 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; create( - paramsOrFirst: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, - ...rest: [(string)?, (Runtime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (ProjectKeyScopes[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (number)?] + functionId: string, + name: string, + runtime: Runtime, + execute?: string[], + events?: string[], + schedule?: string, + timeout?: number, + enabled?: boolean, + logging?: boolean, + entrypoint?: string, + commands?: string, + scopes?: ProjectKeyScopes[], + installationId?: string, + providerRepositoryId?: string, + providerBranch?: string, + providerSilentMode?: boolean, + providerRootDirectory?: string, + providerBranches?: string[], + providerPaths?: string[], + buildSpecification?: string, + runtimeSpecification?: string, + deploymentRetention?: number, + ): Promise; + create( + paramsOrFirst: + | { + functionId: string; + name: string; + runtime: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + } + | string, + ...rest: [ + string?, + Runtime?, + string[]?, + string[]?, + string?, + number?, + boolean?, + boolean?, + string?, + string?, + ProjectKeyScopes[]?, + string?, + string?, + string?, + boolean?, + string?, + string[]?, + string[]?, + string?, + string?, + number?, + ] ): Promise { - let params: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + let params: { + functionId: string; + name: string; + runtime: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + name: string; + runtime: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + }; } else { params = { functionId: paramsOrFirst as string, @@ -175,10 +332,10 @@ export class Functions { providerPaths: rest[17] as string[], buildSpecification: rest[18] as string, runtimeSpecification: rest[19] as string, - deploymentRetention: rest[20] as number + deploymentRetention: rest[20] as number, }; } - + const functionId = params.functionId; const name = params.name; const runtime = params.runtime; @@ -201,99 +358,96 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof runtime === 'undefined') { - throw new AppwriteException('Missing required parameter: "runtime"'); + throw new AppwriteException( + 'Missing required parameter: "runtime"', + ); } - const apiPath = '/functions'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof functionId !== 'undefined') { - payload['functionId'] = functionId; + apiPayload['functionId'] = functionId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof runtime !== 'undefined') { - payload['runtime'] = runtime; + apiPayload['runtime'] = runtime; } if (typeof execute !== 'undefined') { - payload['execute'] = execute; + apiPayload['execute'] = execute; } if (typeof events !== 'undefined') { - payload['events'] = events; + apiPayload['events'] = events; } if (typeof schedule !== 'undefined') { - payload['schedule'] = schedule; + apiPayload['schedule'] = schedule; } if (typeof timeout !== 'undefined') { - payload['timeout'] = timeout; + apiPayload['timeout'] = timeout; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof logging !== 'undefined') { - payload['logging'] = logging; + apiPayload['logging'] = logging; } if (typeof entrypoint !== 'undefined') { - payload['entrypoint'] = entrypoint; + apiPayload['entrypoint'] = entrypoint; } if (typeof commands !== 'undefined') { - payload['commands'] = commands; + apiPayload['commands'] = commands; } if (typeof scopes !== 'undefined') { - payload['scopes'] = scopes; + apiPayload['scopes'] = scopes; } if (typeof installationId !== 'undefined') { - payload['installationId'] = installationId; + apiPayload['installationId'] = installationId; } if (typeof providerRepositoryId !== 'undefined') { - payload['providerRepositoryId'] = providerRepositoryId; + apiPayload['providerRepositoryId'] = providerRepositoryId; } if (typeof providerBranch !== 'undefined') { - payload['providerBranch'] = providerBranch; + apiPayload['providerBranch'] = providerBranch; } if (typeof providerSilentMode !== 'undefined') { - payload['providerSilentMode'] = providerSilentMode; + apiPayload['providerSilentMode'] = providerSilentMode; } if (typeof providerRootDirectory !== 'undefined') { - payload['providerRootDirectory'] = providerRootDirectory; + apiPayload['providerRootDirectory'] = providerRootDirectory; } if (typeof providerBranches !== 'undefined') { - payload['providerBranches'] = providerBranches; + apiPayload['providerBranches'] = providerBranches; } if (typeof providerPaths !== 'undefined') { - payload['providerPaths'] = providerPaths; + apiPayload['providerPaths'] = providerPaths; } if (typeof buildSpecification !== 'undefined') { - payload['buildSpecification'] = buildSpecification; + apiPayload['buildSpecification'] = buildSpecification; } if (typeof runtimeSpecification !== 'undefined') { - payload['runtimeSpecification'] = runtimeSpecification; + apiPayload['runtimeSpecification'] = runtimeSpecification; } if (typeof deploymentRetention !== 'undefined') { - payload['deploymentRetention'] = deploymentRetention; + apiPayload['deploymentRetention'] = deploymentRetention; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -303,22 +457,16 @@ export class Functions { * @returns {Promise} */ listRuntimes(): Promise { - const apiPath = '/functions/runtimes'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -328,7 +476,9 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - listSpecifications(params?: { type?: string }): Promise; + listSpecifications(params?: { + type?: string; + }): Promise; /** * List allowed function specifications for this instance. * @@ -339,39 +489,37 @@ export class Functions { */ listSpecifications(type?: string): Promise; listSpecifications( - paramsOrFirst?: { type?: string } | string + paramsOrFirst?: { type?: string } | string, ): Promise { let params: { type?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { type?: string }; } else { params = { - type: paramsOrFirst as string + type: paramsOrFirst as string, }; } - - const type = params.type; - + const type = params.type; const apiPath = '/functions/specifications'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof type !== 'undefined') { - payload['type'] = type; + apiPayload['type'] = type; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -392,39 +540,41 @@ export class Functions { */ get(functionId: string): Promise; get( - paramsOrFirst: { functionId: string } | string + paramsOrFirst: { functionId: string } | string, ): Promise { let params: { functionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { functionId: string }; } else { params = { - functionId: paramsOrFirst as string + functionId: paramsOrFirst as string, }; } - - const functionId = params.functionId; + const functionId = params.functionId; if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - - const apiPath = '/functions/{functionId}'.replace('{functionId}', encodeURIComponent(String(functionId))); - const payload: Payload = {}; + const apiPath = '/functions/{functionId}'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -455,7 +605,30 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; + update(params: { + functionId: string; + name: string; + runtime?: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + }): Promise; /** * Update function by its unique ID. * @@ -485,15 +658,135 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; update( - paramsOrFirst: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, - ...rest: [(string)?, (Runtime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (ProjectKeyScopes[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (number)?] + functionId: string, + name: string, + runtime?: Runtime, + execute?: string[], + events?: string[], + schedule?: string, + timeout?: number, + enabled?: boolean, + logging?: boolean, + entrypoint?: string, + commands?: string, + scopes?: ProjectKeyScopes[], + installationId?: string, + providerRepositoryId?: string, + providerBranch?: string, + providerSilentMode?: boolean, + providerRootDirectory?: string, + providerBranches?: string[], + providerPaths?: string[], + buildSpecification?: string, + runtimeSpecification?: string, + deploymentRetention?: number, + ): Promise; + update( + paramsOrFirst: + | { + functionId: string; + name: string; + runtime?: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + } + | string, + ...rest: [ + string?, + Runtime?, + string[]?, + string[]?, + string?, + number?, + boolean?, + boolean?, + string?, + string?, + ProjectKeyScopes[]?, + string?, + string?, + string?, + boolean?, + string?, + string[]?, + string[]?, + string?, + string?, + number?, + ] ): Promise { - let params: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + let params: { + functionId: string; + name: string; + runtime?: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + name: string; + runtime?: Runtime; + execute?: string[]; + events?: string[]; + schedule?: string; + timeout?: number; + enabled?: boolean; + logging?: boolean; + entrypoint?: string; + commands?: string; + scopes?: ProjectKeyScopes[]; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + }; } else { params = { functionId: paramsOrFirst as string, @@ -517,10 +810,10 @@ export class Functions { providerPaths: rest[17] as string[], buildSpecification: rest[18] as string, runtimeSpecification: rest[19] as string, - deploymentRetention: rest[20] as number + deploymentRetention: rest[20] as number, }; } - + const functionId = params.functionId; const name = params.name; const runtime = params.runtime; @@ -543,93 +836,91 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/functions/{functionId}'.replace('{functionId}', encodeURIComponent(String(functionId))); - const payload: Payload = {}; + const apiPath = '/functions/{functionId}'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof runtime !== 'undefined') { - payload['runtime'] = runtime; + apiPayload['runtime'] = runtime; } if (typeof execute !== 'undefined') { - payload['execute'] = execute; + apiPayload['execute'] = execute; } if (typeof events !== 'undefined') { - payload['events'] = events; + apiPayload['events'] = events; } if (typeof schedule !== 'undefined') { - payload['schedule'] = schedule; + apiPayload['schedule'] = schedule; } if (typeof timeout !== 'undefined') { - payload['timeout'] = timeout; + apiPayload['timeout'] = timeout; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof logging !== 'undefined') { - payload['logging'] = logging; + apiPayload['logging'] = logging; } if (typeof entrypoint !== 'undefined') { - payload['entrypoint'] = entrypoint; + apiPayload['entrypoint'] = entrypoint; } if (typeof commands !== 'undefined') { - payload['commands'] = commands; + apiPayload['commands'] = commands; } if (typeof scopes !== 'undefined') { - payload['scopes'] = scopes; + apiPayload['scopes'] = scopes; } if (typeof installationId !== 'undefined') { - payload['installationId'] = installationId; + apiPayload['installationId'] = installationId; } if (typeof providerRepositoryId !== 'undefined') { - payload['providerRepositoryId'] = providerRepositoryId; + apiPayload['providerRepositoryId'] = providerRepositoryId; } if (typeof providerBranch !== 'undefined') { - payload['providerBranch'] = providerBranch; + apiPayload['providerBranch'] = providerBranch; } if (typeof providerSilentMode !== 'undefined') { - payload['providerSilentMode'] = providerSilentMode; + apiPayload['providerSilentMode'] = providerSilentMode; } if (typeof providerRootDirectory !== 'undefined') { - payload['providerRootDirectory'] = providerRootDirectory; + apiPayload['providerRootDirectory'] = providerRootDirectory; } if (typeof providerBranches !== 'undefined') { - payload['providerBranches'] = providerBranches; + apiPayload['providerBranches'] = providerBranches; } if (typeof providerPaths !== 'undefined') { - payload['providerPaths'] = providerPaths; + apiPayload['providerPaths'] = providerPaths; } if (typeof buildSpecification !== 'undefined') { - payload['buildSpecification'] = buildSpecification; + apiPayload['buildSpecification'] = buildSpecification; } if (typeof runtimeSpecification !== 'undefined') { - payload['runtimeSpecification'] = runtimeSpecification; + apiPayload['runtimeSpecification'] = runtimeSpecification; } if (typeof deploymentRetention !== 'undefined') { - payload['deploymentRetention'] = deploymentRetention; + apiPayload['deploymentRetention'] = deploymentRetention; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -649,40 +940,40 @@ export class Functions { * @deprecated Use the object parameter style method for a better developer experience. */ delete(functionId: string): Promise<{}>; - delete( - paramsOrFirst: { functionId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { functionId: string } | string): Promise<{}> { let params: { functionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { functionId: string }; } else { params = { - functionId: paramsOrFirst as string + functionId: paramsOrFirst as string, }; } - - const functionId = params.functionId; + const functionId = params.functionId; if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - - const apiPath = '/functions/{functionId}'.replace('{functionId}', encodeURIComponent(String(functionId))); - const payload: Payload = {}; + const apiPath = '/functions/{functionId}'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -693,7 +984,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - updateFunctionDeployment(params: { functionId: string, deploymentId: string }): Promise; + updateFunctionDeployment(params: { + functionId: string; + deploymentId: string; + }): Promise; /** * Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function. * @@ -703,51 +997,61 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateFunctionDeployment(functionId: string, deploymentId: string): Promise; updateFunctionDeployment( - paramsOrFirst: { functionId: string, deploymentId: string } | string, - ...rest: [(string)?] + functionId: string, + deploymentId: string, + ): Promise; + updateFunctionDeployment( + paramsOrFirst: { functionId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise { - let params: { functionId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + let params: { functionId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + deploymentId: string; + }; } else { params = { functionId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const functionId = params.functionId; const deploymentId = params.deploymentId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); } - - const apiPath = '/functions/{functionId}/deployment'.replace('{functionId}', encodeURIComponent(String(functionId))); - const payload: Payload = {}; + const apiPath = '/functions/{functionId}/deployment'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); + const apiPayload: Payload = {}; if (typeof deploymentId !== 'undefined') { - payload['deploymentId'] = deploymentId; + apiPayload['deploymentId'] = deploymentId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -760,7 +1064,12 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - listDeployments(params: { functionId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listDeployments(params: { + functionId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all the function's code deployments. You can use the query params to filter your results. * @@ -772,64 +1081,88 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listDeployments(functionId: string, queries?: string[], search?: string, total?: boolean): Promise; listDeployments( - paramsOrFirst: { functionId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + functionId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listDeployments( + paramsOrFirst: + | { + functionId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { functionId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + functionId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { functionId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const functionId = params.functionId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - - const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', encodeURIComponent(String(functionId))); - const payload: Payload = {}; + const apiPath = '/functions/{functionId}/deployments'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. - * + * * This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](https://appwrite.io/docs/functions). - * + * * Use the "command" param to set the entrypoint used to execute your code. * * @param {string} params.functionId - Function ID. @@ -840,12 +1173,19 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - createDeployment(params: { functionId: string, code: File | InputFile, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void }): Promise; + createDeployment(params: { + functionId: string; + code: File | InputFile; + activate: boolean; + entrypoint?: string; + commands?: string; + onProgress?: (progress: UploadProgress) => void; + }): Promise; /** * Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. - * + * * This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](https://appwrite.io/docs/functions). - * + * * Use the "command" param to set the entrypoint used to execute your code. * * @param {string} functionId - Function ID. @@ -857,72 +1197,117 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDeployment(functionId: string, code: File | InputFile, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void): Promise; createDeployment( - paramsOrFirst: { functionId: string, code: File | InputFile, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void } | string, - ...rest: [(File | InputFile)?, (boolean)?, (string)?, (string)?,((progress: UploadProgress) => void)?] + functionId: string, + code: File | InputFile, + activate: boolean, + entrypoint?: string, + commands?: string, + onProgress?: (progress: UploadProgress) => void, + ): Promise; + createDeployment( + paramsOrFirst: + | { + functionId: string; + code: File | InputFile; + activate: boolean; + entrypoint?: string; + commands?: string; + onProgress?: (progress: UploadProgress) => void; + } + | string, + ...rest: [ + (File | InputFile)?, + boolean?, + string?, + string?, + ((progress: UploadProgress) => void)?, + ] ): Promise { - let params: { functionId: string, code: File | InputFile, activate: boolean, entrypoint?: string, commands?: string }; - let onProgress: ((progress: UploadProgress) => void); - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, code: File | InputFile, activate: boolean, entrypoint?: string, commands?: string }; - onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void); + let params: { + functionId: string; + code: File | InputFile; + activate: boolean; + entrypoint?: string; + commands?: string; + }; + let onProgress: (progress: UploadProgress) => void; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + code: File | InputFile; + activate: boolean; + entrypoint?: string; + commands?: string; + }; + onProgress = paramsOrFirst?.onProgress as ( + progress: UploadProgress, + ) => void; } else { params = { functionId: paramsOrFirst as string, code: rest[0] as File | InputFile, activate: rest[1] as boolean, entrypoint: rest[2] as string, - commands: rest[3] as string + commands: rest[3] as string, }; - onProgress = rest[4] as ((progress: UploadProgress) => void); + onProgress = rest[4] as (progress: UploadProgress) => void; } - + const functionId = params.functionId; const code = params.code; const activate = params.activate; const entrypoint = params.entrypoint; const commands = params.commands; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } if (typeof activate === 'undefined') { - throw new AppwriteException('Missing required parameter: "activate"'); + throw new AppwriteException( + 'Missing required parameter: "activate"', + ); } - - const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', encodeURIComponent(String(functionId))); - const payload: Payload = {}; + const apiPath = '/functions/{functionId}/deployments'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); + const apiPayload: Payload = {}; if (typeof entrypoint !== 'undefined') { - payload['entrypoint'] = entrypoint; + apiPayload['entrypoint'] = entrypoint; } if (typeof commands !== 'undefined') { - payload['commands'] = commands; + apiPayload['commands'] = commands; } if (typeof code !== 'undefined') { - payload['code'] = code; + apiPayload['code'] = code; } if (typeof activate !== 'undefined') { - payload['activate'] = activate; + apiPayload['activate'] = activate; } 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', - } + accept: 'application/json', + }; return this.client.chunkedUpload( 'post', uri, apiHeaders, - payload, - onProgress + apiPayload, + onProgress, ); } @@ -935,7 +1320,11 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - createDuplicateDeployment(params: { functionId: string, deploymentId: string, buildId?: string }): Promise; + createDuplicateDeployment(params: { + functionId: string; + deploymentId: string; + buildId?: string; + }): Promise; /** * Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. * @@ -946,61 +1335,79 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDuplicateDeployment(functionId: string, deploymentId: string, buildId?: string): Promise; createDuplicateDeployment( - paramsOrFirst: { functionId: string, deploymentId: string, buildId?: string } | string, - ...rest: [(string)?, (string)?] + functionId: string, + deploymentId: string, + buildId?: string, + ): Promise; + createDuplicateDeployment( + paramsOrFirst: + | { functionId: string; deploymentId: string; buildId?: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { functionId: string, deploymentId: string, buildId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string, buildId?: string }; + let params: { + functionId: string; + deploymentId: string; + buildId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + deploymentId: string; + buildId?: string; + }; } else { params = { functionId: paramsOrFirst as string, deploymentId: rest[0] as string, - buildId: rest[1] as string + buildId: rest[1] as string, }; } - + const functionId = params.functionId; const deploymentId = params.deploymentId; const buildId = params.buildId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); } - - const apiPath = '/functions/{functionId}/deployments/duplicate'.replace('{functionId}', encodeURIComponent(String(functionId))); - const payload: Payload = {}; + const apiPath = '/functions/{functionId}/deployments/duplicate'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); + const apiPayload: Payload = {}; if (typeof deploymentId !== 'undefined') { - payload['deploymentId'] = deploymentId; + apiPayload['deploymentId'] = deploymentId; } if (typeof buildId !== 'undefined') { - payload['buildId'] = buildId; + apiPayload['buildId'] = buildId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Create a deployment based on a template. - * + * * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/functions/templates) to find the template details. * * @param {string} params.functionId - Function ID. @@ -1013,10 +1420,18 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - createTemplateDeployment(params: { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }): Promise; + createTemplateDeployment(params: { + functionId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + }): Promise; /** * Create a deployment based on a template. - * + * * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/functions/templates) to find the template details. * * @param {string} functionId - Function ID. @@ -1030,15 +1445,60 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTemplateDeployment(functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean): Promise; createTemplateDeployment( - paramsOrFirst: { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (TemplateReferenceType)?, (string)?, (boolean)?] + functionId: string, + repository: string, + owner: string, + rootDirectory: string, + type: TemplateReferenceType, + reference: string, + activate?: boolean, + ): Promise; + createTemplateDeployment( + paramsOrFirst: + | { + functionId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + TemplateReferenceType?, + string?, + boolean?, + ] ): Promise { - let params: { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; + let params: { + functionId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + }; } else { params = { functionId: paramsOrFirst as string, @@ -1047,10 +1507,10 @@ export class Functions { rootDirectory: rest[2] as string, type: rest[3] as TemplateReferenceType, reference: rest[4] as string, - activate: rest[5] as boolean + activate: rest[5] as boolean, }; } - + const functionId = params.functionId; const repository = params.repository; const owner = params.owner; @@ -1058,65 +1518,69 @@ export class Functions { const type = params.type; const reference = params.reference; const activate = params.activate; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof repository === 'undefined') { - throw new AppwriteException('Missing required parameter: "repository"'); + throw new AppwriteException( + 'Missing required parameter: "repository"', + ); } if (typeof owner === 'undefined') { throw new AppwriteException('Missing required parameter: "owner"'); } if (typeof rootDirectory === 'undefined') { - throw new AppwriteException('Missing required parameter: "rootDirectory"'); + throw new AppwriteException( + 'Missing required parameter: "rootDirectory"', + ); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof reference === 'undefined') { - throw new AppwriteException('Missing required parameter: "reference"'); + throw new AppwriteException( + 'Missing required parameter: "reference"', + ); } - - const apiPath = '/functions/{functionId}/deployments/template'.replace('{functionId}', encodeURIComponent(String(functionId))); - const payload: Payload = {}; + const apiPath = '/functions/{functionId}/deployments/template'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); + const apiPayload: Payload = {}; if (typeof repository !== 'undefined') { - payload['repository'] = repository; + apiPayload['repository'] = repository; } if (typeof owner !== 'undefined') { - payload['owner'] = owner; + apiPayload['owner'] = owner; } if (typeof rootDirectory !== 'undefined') { - payload['rootDirectory'] = rootDirectory; + apiPayload['rootDirectory'] = rootDirectory; } if (typeof type !== 'undefined') { - payload['type'] = type; + apiPayload['type'] = type; } if (typeof reference !== 'undefined') { - payload['reference'] = reference; + apiPayload['reference'] = reference; } if (typeof activate !== 'undefined') { - payload['activate'] = activate; + apiPayload['activate'] = activate; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Create a deployment when a function is connected to VCS. - * + * * This endpoint lets you create deployment from a branch, commit, or a tag. * * @param {string} params.functionId - Function ID. @@ -1126,10 +1590,15 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - createVcsDeployment(params: { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean }): Promise; + createVcsDeployment(params: { + functionId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + }): Promise; /** * Create a deployment when a function is connected to VCS. - * + * * This endpoint lets you create deployment from a branch, commit, or a tag. * * @param {string} functionId - Function ID. @@ -1140,64 +1609,90 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVcsDeployment(functionId: string, type: VCSReferenceType, reference: string, activate?: boolean): Promise; createVcsDeployment( - paramsOrFirst: { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean } | string, - ...rest: [(VCSReferenceType)?, (string)?, (boolean)?] + functionId: string, + type: VCSReferenceType, + reference: string, + activate?: boolean, + ): Promise; + createVcsDeployment( + paramsOrFirst: + | { + functionId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + } + | string, + ...rest: [VCSReferenceType?, string?, boolean?] ): Promise { - let params: { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean }; + let params: { + functionId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + }; } else { params = { functionId: paramsOrFirst as string, type: rest[0] as VCSReferenceType, reference: rest[1] as string, - activate: rest[2] as boolean + activate: rest[2] as boolean, }; } - + const functionId = params.functionId; const type = params.type; const reference = params.reference; const activate = params.activate; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof reference === 'undefined') { - throw new AppwriteException('Missing required parameter: "reference"'); + throw new AppwriteException( + 'Missing required parameter: "reference"', + ); } - - const apiPath = '/functions/{functionId}/deployments/vcs'.replace('{functionId}', encodeURIComponent(String(functionId))); - const payload: Payload = {}; + const apiPath = '/functions/{functionId}/deployments/vcs'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); + const apiPayload: Payload = {}; if (typeof type !== 'undefined') { - payload['type'] = type; + apiPayload['type'] = type; } if (typeof reference !== 'undefined') { - payload['reference'] = reference; + apiPayload['reference'] = reference; } if (typeof activate !== 'undefined') { - payload['activate'] = activate; + apiPayload['activate'] = activate; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1208,7 +1703,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - getDeployment(params: { functionId: string, deploymentId: string }): Promise; + getDeployment(params: { + functionId: string; + deploymentId: string; + }): Promise; /** * Get a function deployment by its unique ID. * @@ -1218,47 +1716,59 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getDeployment(functionId: string, deploymentId: string): Promise; getDeployment( - paramsOrFirst: { functionId: string, deploymentId: string } | string, - ...rest: [(string)?] + functionId: string, + deploymentId: string, + ): Promise; + getDeployment( + paramsOrFirst: { functionId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise { - let params: { functionId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + let params: { functionId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + deploymentId: string; + }; } else { params = { functionId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const functionId = params.functionId; const deploymentId = params.deploymentId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = '/functions/{functionId}/deployments/{deploymentId}' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1269,7 +1779,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteDeployment(params: { functionId: string, deploymentId: string }): Promise<{}>; + deleteDeployment(params: { + functionId: string; + deploymentId: string; + }): Promise<{}>; /** * Delete a code deployment by its unique ID. * @@ -1281,45 +1794,54 @@ export class Functions { */ deleteDeployment(functionId: string, deploymentId: string): Promise<{}>; deleteDeployment( - paramsOrFirst: { functionId: string, deploymentId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { functionId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { functionId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + let params: { functionId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + deploymentId: string; + }; } else { params = { functionId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const functionId = params.functionId; const deploymentId = params.deploymentId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = '/functions/{functionId}/deployments/{deploymentId}' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1332,7 +1854,12 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - getDeploymentDownload(params: { functionId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string }): Promise; + getDeploymentDownload(params: { + functionId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + }): Promise; /** * Get a function deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. * @@ -1344,57 +1871,91 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getDeploymentDownload(functionId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string): Promise; getDeploymentDownload( - paramsOrFirst: { functionId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string } | string, - ...rest: [(string)?, (DeploymentDownloadType)?, (string)?] + functionId: string, + deploymentId: string, + type?: DeploymentDownloadType, + token?: string, + ): Promise; + getDeploymentDownload( + paramsOrFirst: + | { + functionId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + } + | string, + ...rest: [string?, DeploymentDownloadType?, string?] ): Promise { - let params: { functionId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string }; + let params: { + functionId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + }; } else { params = { functionId: paramsOrFirst as string, deploymentId: rest[0] as string, type: rest[1] as DeploymentDownloadType, - token: rest[2] as string + token: rest[2] as string, }; } - + const functionId = params.functionId; const deploymentId = params.deploymentId; const type = params.type; const token = params.token; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = + '/functions/{functionId}/deployments/{deploymentId}/download' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); + const apiPayload: Payload = {}; if (typeof type !== 'undefined') { - payload['type'] = type; + apiPayload['type'] = type; } if (typeof token !== 'undefined') { - payload['token'] = token; + apiPayload['token'] = token; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': '*/*', - } + accept: '*/*', + }; return this.client.call( 'get', uri, apiHeaders, - payload, - 'arrayBuffer' + apiPayload, + 'arrayBuffer', ); } @@ -1406,7 +1967,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - updateDeploymentStatus(params: { functionId: string, deploymentId: string }): Promise; + updateDeploymentStatus(params: { + functionId: string; + deploymentId: string; + }): Promise; /** * Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. * @@ -1416,48 +1980,61 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDeploymentStatus(functionId: string, deploymentId: string): Promise; updateDeploymentStatus( - paramsOrFirst: { functionId: string, deploymentId: string } | string, - ...rest: [(string)?] + functionId: string, + deploymentId: string, + ): Promise; + updateDeploymentStatus( + paramsOrFirst: { functionId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise { - let params: { functionId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + let params: { functionId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + deploymentId: string; + }; } else { params = { functionId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const functionId = params.functionId; const deploymentId = params.deploymentId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/functions/{functionId}/deployments/{deploymentId}/status'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = + '/functions/{functionId}/deployments/{deploymentId}/status' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1469,7 +2046,11 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - listExecutions(params: { functionId: string, queries?: string[], total?: boolean }): Promise; + listExecutions(params: { + functionId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all the current user function execution logs. You can use the query params to filter your results. * @@ -1480,52 +2061,64 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listExecutions(functionId: string, queries?: string[], total?: boolean): Promise; listExecutions( - paramsOrFirst: { functionId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + functionId: string, + queries?: string[], + total?: boolean, + ): Promise; + listExecutions( + paramsOrFirst: + | { functionId: string; queries?: string[]; total?: boolean } + | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { functionId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, queries?: string[], total?: boolean }; + let params: { functionId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { functionId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const functionId = params.functionId; const queries = params.queries; const total = params.total; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - - const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', encodeURIComponent(String(functionId))); - const payload: Payload = {}; + const apiPath = '/functions/{functionId}/executions'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1541,7 +2134,15 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - createExecution(params: { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string }): Promise; + createExecution(params: { + functionId: string; + body?: string; + async?: boolean; + xpath?: string; + method?: ExecutionMethod; + headers?: object; + scheduledAt?: string; + }): Promise; /** * Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously. * @@ -1556,15 +2157,60 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string): Promise; createExecution( - paramsOrFirst: { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (ExecutionMethod)?, (object)?, (string)?] + functionId: string, + body?: string, + async?: boolean, + xpath?: string, + method?: ExecutionMethod, + headers?: object, + scheduledAt?: string, + ): Promise; + createExecution( + paramsOrFirst: + | { + functionId: string; + body?: string; + async?: boolean; + xpath?: string; + method?: ExecutionMethod; + headers?: object; + scheduledAt?: string; + } + | string, + ...rest: [ + string?, + boolean?, + string?, + ExecutionMethod?, + object?, + string?, + ] ): Promise { - let params: { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string }; + let params: { + functionId: string; + body?: string; + async?: boolean; + xpath?: string; + method?: ExecutionMethod; + headers?: object; + scheduledAt?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + body?: string; + async?: boolean; + xpath?: string; + method?: ExecutionMethod; + headers?: object; + scheduledAt?: string; + }; } else { params = { functionId: paramsOrFirst as string, @@ -1573,10 +2219,10 @@ export class Functions { xpath: rest[2] as string, method: rest[3] as ExecutionMethod, headers: rest[4] as object, - scheduledAt: rest[5] as string + scheduledAt: rest[5] as string, }; } - + const functionId = params.functionId; const body = params.body; const async = params.async; @@ -1584,45 +2230,43 @@ export class Functions { const method = params.method; const headers = params.headers; const scheduledAt = params.scheduledAt; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - - const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', encodeURIComponent(String(functionId))); - const payload: Payload = {}; + const apiPath = '/functions/{functionId}/executions'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); + const apiPayload: Payload = {}; if (typeof body !== 'undefined') { - payload['body'] = body; + apiPayload['body'] = body; } if (typeof async !== 'undefined') { - payload['async'] = async; + apiPayload['async'] = async; } if (typeof xpath !== 'undefined') { - payload['path'] = xpath; + apiPayload['path'] = xpath; } if (typeof method !== 'undefined') { - payload['method'] = method; + apiPayload['method'] = method; } if (typeof headers !== 'undefined') { - payload['headers'] = headers; + apiPayload['headers'] = headers; } if (typeof scheduledAt !== 'undefined') { - payload['scheduledAt'] = scheduledAt; + apiPayload['scheduledAt'] = scheduledAt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1633,7 +2277,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - getExecution(params: { functionId: string, executionId: string }): Promise; + getExecution(params: { + functionId: string; + executionId: string; + }): Promise; /** * Get a function execution log by its unique ID. * @@ -1643,47 +2290,56 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getExecution(functionId: string, executionId: string): Promise; getExecution( - paramsOrFirst: { functionId: string, executionId: string } | string, - ...rest: [(string)?] + functionId: string, + executionId: string, + ): Promise; + getExecution( + paramsOrFirst: { functionId: string; executionId: string } | string, + ...rest: [string?] ): Promise { - let params: { functionId: string, executionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, executionId: string }; + let params: { functionId: string; executionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + executionId: string; + }; } else { params = { functionId: paramsOrFirst as string, - executionId: rest[0] as string + executionId: rest[0] as string, }; } - + const functionId = params.functionId; const executionId = params.executionId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof executionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "executionId"'); - } - - const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{executionId}', encodeURIComponent(String(executionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "executionId"', + ); + } + const apiPath = '/functions/{functionId}/executions/{executionId}' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace('{executionId}', encodeURIComponent(String(executionId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1694,7 +2350,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteExecution(params: { functionId: string, executionId: string }): Promise<{}>; + deleteExecution(params: { + functionId: string; + executionId: string; + }): Promise<{}>; /** * Delete a function execution by its unique ID. * @@ -1706,45 +2365,51 @@ export class Functions { */ deleteExecution(functionId: string, executionId: string): Promise<{}>; deleteExecution( - paramsOrFirst: { functionId: string, executionId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { functionId: string; executionId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { functionId: string, executionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, executionId: string }; + let params: { functionId: string; executionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + executionId: string; + }; } else { params = { functionId: paramsOrFirst as string, - executionId: rest[0] as string + executionId: rest[0] as string, }; } - + const functionId = params.functionId; const executionId = params.executionId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof executionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "executionId"'); - } - - const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{executionId}', encodeURIComponent(String(executionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "executionId"', + ); + } + const apiPath = '/functions/{functionId}/executions/{executionId}' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace('{executionId}', encodeURIComponent(String(executionId))); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1756,7 +2421,11 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - listVariables(params: { functionId: string, queries?: string[], total?: boolean }): Promise; + listVariables(params: { + functionId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all variables of a specific function. * @@ -1767,52 +2436,64 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listVariables(functionId: string, queries?: string[], total?: boolean): Promise; listVariables( - paramsOrFirst: { functionId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + functionId: string, + queries?: string[], + total?: boolean, + ): Promise; + listVariables( + paramsOrFirst: + | { functionId: string; queries?: string[]; total?: boolean } + | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { functionId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, queries?: string[], total?: boolean }; + let params: { functionId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { functionId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const functionId = params.functionId; const queries = params.queries; const total = params.total; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - - const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', encodeURIComponent(String(functionId))); - const payload: Payload = {}; + const apiPath = '/functions/{functionId}/variables'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1820,55 +2501,94 @@ export class Functions { * * @param {string} params.functionId - Function unique ID. * @param {string} params.variableId - Variable 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.key - Variable key. Max length: 255 chars. + * @param {string} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} */ - createVariable(params: { functionId: string, variableId: string, key: string, value: string, secret?: boolean }): Promise; + createVariable(params: { + functionId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + }): Promise; /** * Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables. * * @param {string} functionId - Function unique ID. * @param {string} variableId - Variable 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} key - Variable key. Max length: 255 chars. + * @param {string} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVariable(functionId: string, variableId: string, key: string, value: string, secret?: boolean): Promise; createVariable( - paramsOrFirst: { functionId: string, variableId: string, key: string, value: string, secret?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?] + functionId: string, + variableId: string, + key: string, + value: string, + secret?: boolean, + ): Promise; + createVariable( + paramsOrFirst: + | { + functionId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + } + | string, + ...rest: [string?, string?, string?, boolean?] ): Promise { - let params: { functionId: string, variableId: string, key: string, value: string, secret?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, variableId: string, key: string, value: string, secret?: boolean }; + let params: { + functionId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + }; } else { params = { functionId: paramsOrFirst as string, variableId: rest[0] as string, key: rest[1] as string, value: rest[2] as string, - secret: rest[3] as boolean + secret: rest[3] as boolean, }; } - + const functionId = params.functionId; const variableId = params.variableId; const key = params.key; const value = params.value; const secret = params.secret; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -1876,35 +2596,32 @@ export class Functions { if (typeof value === 'undefined') { throw new AppwriteException('Missing required parameter: "value"'); } - - const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', encodeURIComponent(String(functionId))); - const payload: Payload = {}; + const apiPath = '/functions/{functionId}/variables'.replace( + '{functionId}', + encodeURIComponent(String(functionId)), + ); + const apiPayload: Payload = {}; if (typeof variableId !== 'undefined') { - payload['variableId'] = variableId; + apiPayload['variableId'] = variableId; } if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof value !== 'undefined') { - payload['value'] = value; + apiPayload['value'] = value; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1915,7 +2632,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - getVariable(params: { functionId: string, variableId: string }): Promise; + getVariable(params: { + functionId: string; + variableId: string; + }): Promise; /** * Get a variable by its unique ID. * @@ -1925,47 +2645,56 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getVariable(functionId: string, variableId: string): Promise; getVariable( - paramsOrFirst: { functionId: string, variableId: string } | string, - ...rest: [(string)?] + functionId: string, + variableId: string, + ): Promise; + getVariable( + paramsOrFirst: { functionId: string; variableId: string } | string, + ...rest: [string?] ): Promise { - let params: { functionId: string, variableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, variableId: string }; + let params: { functionId: string; variableId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + variableId: string; + }; } else { params = { functionId: paramsOrFirst as string, - variableId: rest[0] as string + variableId: rest[0] as string, }; } - + const functionId = params.functionId; const variableId = params.variableId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); - } - - const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{variableId}', encodeURIComponent(String(variableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); + } + const apiPath = '/functions/{functionId}/variables/{variableId}' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace('{variableId}', encodeURIComponent(String(variableId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1973,82 +2702,117 @@ export class Functions { * * @param {string} params.functionId - Function unique ID. * @param {string} params.variableId - Variable unique ID. - * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} */ - updateVariable(params: { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean }): Promise; + updateVariable(params: { + functionId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }): Promise; /** * Update variable by its unique ID. * * @param {string} functionId - Function unique ID. * @param {string} variableId - Variable unique ID. - * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateVariable(functionId: string, variableId: string, key?: string, value?: string, secret?: boolean): Promise; updateVariable( - paramsOrFirst: { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?] + functionId: string, + variableId: string, + key?: string, + value?: string, + secret?: boolean, + ): Promise; + updateVariable( + paramsOrFirst: + | { + functionId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + } + | string, + ...rest: [string?, string?, string?, boolean?] ): Promise { - let params: { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean }; + let params: { + functionId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }; } else { params = { functionId: paramsOrFirst as string, variableId: rest[0] as string, key: rest[1] as string, value: rest[2] as string, - secret: rest[3] as boolean + secret: rest[3] as boolean, }; } - + const functionId = params.functionId; const variableId = params.variableId; const key = params.key; const value = params.value; const secret = params.secret; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); - } - - const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{variableId}', encodeURIComponent(String(variableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); + } + const apiPath = '/functions/{functionId}/variables/{variableId}' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace('{variableId}', encodeURIComponent(String(variableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof value !== 'undefined') { - payload['value'] = value; + apiPayload['value'] = value; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2059,7 +2823,10 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteVariable(params: { functionId: string, variableId: string }): Promise<{}>; + deleteVariable(params: { + functionId: string; + variableId: string; + }): Promise<{}>; /** * Delete a variable by its unique ID. * @@ -2071,44 +2838,50 @@ export class Functions { */ deleteVariable(functionId: string, variableId: string): Promise<{}>; deleteVariable( - paramsOrFirst: { functionId: string, variableId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { functionId: string; variableId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { functionId: string, variableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, variableId: string }; + let params: { functionId: string; variableId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + functionId: string; + variableId: string; + }; } else { params = { functionId: paramsOrFirst as string, - variableId: rest[0] as string + variableId: rest[0] as string, }; } - + const functionId = params.functionId; const variableId = params.variableId; - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); - } - - const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', encodeURIComponent(String(functionId))).replace('{variableId}', encodeURIComponent(String(variableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); + } + const apiPath = '/functions/{functionId}/variables/{variableId}' + .replace('{functionId}', encodeURIComponent(String(functionId))) + .replace('{variableId}', encodeURIComponent(String(variableId))); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } } diff --git a/src/services/graphql.ts b/src/services/graphql.ts index 741f45f9..cc42f534 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -1,7 +1,4 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; -import type { Models } from '../models'; - - +import { AppwriteException, Client, type Payload } from '../client'; export class Graphql { client: Client; @@ -27,29 +24,30 @@ export class Graphql { * @deprecated Use the object parameter style method for a better developer experience. */ query(query: object): Promise<{}>; - query( - paramsOrFirst: { query: object } | object - ): Promise<{}> { + query(paramsOrFirst: { query: object } | object): Promise<{}> { let params: { query: object }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('query' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'query' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { query: object }; } else { params = { - query: paramsOrFirst as object + query: paramsOrFirst as object, }; } - - const query = params.query; + const query = params.query; if (typeof query === 'undefined') { throw new AppwriteException('Missing required parameter: "query"'); } - const apiPath = '/graphql'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof query !== 'undefined') { - payload['query'] = query; + apiPayload['query'] = query; } const uri = new URL(this.client.config.endpoint + apiPath); @@ -57,15 +55,10 @@ export class Graphql { 'X-Appwrite-Project': this.client.config.project, 'x-sdk-graphql': 'true', 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -85,29 +78,30 @@ export class Graphql { * @deprecated Use the object parameter style method for a better developer experience. */ mutation(query: object): Promise<{}>; - mutation( - paramsOrFirst: { query: object } | object - ): Promise<{}> { + mutation(paramsOrFirst: { query: object } | object): Promise<{}> { let params: { query: object }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('query' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'query' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { query: object }; } else { params = { - query: paramsOrFirst as object + query: paramsOrFirst as object, }; } - - const query = params.query; + const query = params.query; if (typeof query === 'undefined') { throw new AppwriteException('Missing required parameter: "query"'); } - const apiPath = '/graphql/mutation'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof query !== 'undefined') { - payload['query'] = query; + apiPayload['query'] = query; } const uri = new URL(this.client.config.endpoint + apiPath); @@ -115,14 +109,9 @@ export class Graphql { 'X-Appwrite-Project': this.client.config.project, 'x-sdk-graphql': 'true', 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } } diff --git a/src/services/locale.ts b/src/services/locale.ts index 56b45d20..85b80390 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -1,8 +1,6 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { Client, type Payload } from '../client'; import type { Models } from '../models'; - - export class Locale { client: Client; @@ -12,29 +10,23 @@ export class Locale { /** * Get the current user location based on IP. Returns an object with user country code, country name, continent name, continent code, ip address and suggested currency. You can use the locale header to get the data in a supported language. - * + * * ([IP Geolocation by DB-IP](https://db-ip.com)) * * @throws {AppwriteException} * @returns {Promise} */ get(): Promise { - const apiPath = '/locale'; - const payload: Payload = {}; + 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, - payload, - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -44,22 +36,16 @@ export class Locale { * @returns {Promise} */ listCodes(): Promise { - const apiPath = '/locale/codes'; - const payload: Payload = {}; + 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, - payload, - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -69,22 +55,16 @@ export class Locale { * @returns {Promise} */ listContinents(): Promise { - const apiPath = '/locale/continents'; - const payload: Payload = {}; + 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, - payload, - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -94,22 +74,16 @@ export class Locale { * @returns {Promise} */ listCountries(): Promise { - const apiPath = '/locale/countries'; - const payload: Payload = {}; + 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, - payload, - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -119,22 +93,16 @@ export class Locale { * @returns {Promise} */ listCountriesEU(): Promise { - const apiPath = '/locale/countries/eu'; - const payload: Payload = {}; + 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, - payload, - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -144,22 +112,16 @@ export class Locale { * @returns {Promise} */ listCountriesPhones(): Promise { - const apiPath = '/locale/countries/phones'; - const payload: Payload = {}; + 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, - payload, - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -169,22 +131,16 @@ export class Locale { * @returns {Promise} */ listCurrencies(): Promise { - const apiPath = '/locale/currencies'; - const payload: Payload = {}; + 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, - payload, - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -194,21 +150,15 @@ export class Locale { * @returns {Promise} */ listLanguages(): Promise { - const apiPath = '/locale/languages'; - const payload: Payload = {}; + 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, - payload, - ); + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); } } diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 95646ccb..0f812313 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -1,10 +1,8 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - import { MessagePriority } from '../enums/message-priority'; import { SmtpEncryption } from '../enums/smtp-encryption'; - export class Messaging { client: Client; @@ -21,7 +19,11 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - listMessages(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listMessages(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all messages from the current Appwrite project. * @@ -32,52 +34,59 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listMessages(queries?: string[], search?: string, total?: boolean): Promise; listMessages( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listMessages( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - - const apiPath = '/messaging/messages'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -98,7 +107,20 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createEmail(params: { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string }): Promise; + createEmail(params: { + messageId: string; + subject: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + cc?: string[]; + bcc?: string[]; + attachments?: string[]; + draft?: boolean; + html?: boolean; + scheduledAt?: string; + }): Promise; /** * Create a new email message. * @@ -118,15 +140,85 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEmail(messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string): Promise; createEmail( - paramsOrFirst: { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (string[])?, (string[])?, (string[])?, (string[])?, (string[])?, (boolean)?, (boolean)?, (string)?] + messageId: string, + subject: string, + content: string, + topics?: string[], + users?: string[], + targets?: string[], + cc?: string[], + bcc?: string[], + attachments?: string[], + draft?: boolean, + html?: boolean, + scheduledAt?: string, + ): Promise; + createEmail( + paramsOrFirst: + | { + messageId: string; + subject: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + cc?: string[]; + bcc?: string[]; + attachments?: string[]; + draft?: boolean; + html?: boolean; + scheduledAt?: string; + } + | string, + ...rest: [ + string?, + string?, + string[]?, + string[]?, + string[]?, + string[]?, + string[]?, + string[]?, + boolean?, + boolean?, + string?, + ] ): Promise { - let params: { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string }; + let params: { + messageId: string; + subject: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + cc?: string[]; + bcc?: string[]; + attachments?: string[]; + draft?: boolean; + html?: boolean; + scheduledAt?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + subject: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + cc?: string[]; + bcc?: string[]; + attachments?: string[]; + draft?: boolean; + html?: boolean; + scheduledAt?: string; + }; } else { params = { messageId: paramsOrFirst as string, @@ -140,10 +232,10 @@ export class Messaging { attachments: rest[7] as string[], draft: rest[8] as boolean, html: rest[9] as boolean, - scheduledAt: rest[10] as string + scheduledAt: rest[10] as string, }; } - + const messageId = params.messageId; const subject = params.subject; const content = params.content; @@ -156,74 +248,73 @@ export class Messaging { const draft = params.draft; const html = params.html; const scheduledAt = params.scheduledAt; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } if (typeof subject === 'undefined') { - throw new AppwriteException('Missing required parameter: "subject"'); + throw new AppwriteException( + 'Missing required parameter: "subject"', + ); } if (typeof content === 'undefined') { - throw new AppwriteException('Missing required parameter: "content"'); + throw new AppwriteException( + 'Missing required parameter: "content"', + ); } - const apiPath = '/messaging/messages/email'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof messageId !== 'undefined') { - payload['messageId'] = messageId; + apiPayload['messageId'] = messageId; } if (typeof subject !== 'undefined') { - payload['subject'] = subject; + apiPayload['subject'] = subject; } if (typeof content !== 'undefined') { - payload['content'] = content; + apiPayload['content'] = content; } if (typeof topics !== 'undefined') { - payload['topics'] = topics; + apiPayload['topics'] = topics; } if (typeof users !== 'undefined') { - payload['users'] = users; + apiPayload['users'] = users; } if (typeof targets !== 'undefined') { - payload['targets'] = targets; + apiPayload['targets'] = targets; } if (typeof cc !== 'undefined') { - payload['cc'] = cc; + apiPayload['cc'] = cc; } if (typeof bcc !== 'undefined') { - payload['bcc'] = bcc; + apiPayload['bcc'] = bcc; } if (typeof attachments !== 'undefined') { - payload['attachments'] = attachments; + apiPayload['attachments'] = attachments; } if (typeof draft !== 'undefined') { - payload['draft'] = draft; + apiPayload['draft'] = draft; } if (typeof html !== 'undefined') { - payload['html'] = html; + apiPayload['html'] = html; } if (typeof scheduledAt !== 'undefined') { - payload['scheduledAt'] = scheduledAt; + apiPayload['scheduledAt'] = scheduledAt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * 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. - * + * * * @param {string} params.messageId - Message ID. * @param {string[]} params.topics - List of Topic IDs. @@ -240,10 +331,23 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateEmail(params: { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] }): Promise; + updateEmail(params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + subject?: string; + content?: string; + draft?: boolean; + html?: boolean; + cc?: string[]; + bcc?: string[]; + scheduledAt?: string; + attachments?: 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. - * + * * * @param {string} messageId - Message ID. * @param {string[]} topics - List of Topic IDs. @@ -261,15 +365,85 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmail(messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[]): Promise; updateEmail( - paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] } | string, - ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (string)?, (boolean)?, (boolean)?, (string[])?, (string[])?, (string)?, (string[])?] + messageId: string, + topics?: string[], + users?: string[], + targets?: string[], + subject?: string, + content?: string, + draft?: boolean, + html?: boolean, + cc?: string[], + bcc?: string[], + scheduledAt?: string, + attachments?: string[], + ): Promise; + updateEmail( + paramsOrFirst: + | { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + subject?: string; + content?: string; + draft?: boolean; + html?: boolean; + cc?: string[]; + bcc?: string[]; + scheduledAt?: string; + attachments?: string[]; + } + | string, + ...rest: [ + string[]?, + string[]?, + string[]?, + string?, + string?, + boolean?, + boolean?, + string[]?, + string[]?, + string?, + string[]?, + ] ): Promise { - let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] }; + let params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + subject?: string; + content?: string; + draft?: boolean; + html?: boolean; + cc?: string[]; + bcc?: string[]; + scheduledAt?: string; + attachments?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + subject?: string; + content?: string; + draft?: boolean; + html?: boolean; + cc?: string[]; + bcc?: string[]; + scheduledAt?: string; + attachments?: string[]; + }; } else { params = { messageId: paramsOrFirst as string, @@ -283,10 +457,10 @@ export class Messaging { cc: rest[7] as string[], bcc: rest[8] as string[], scheduledAt: rest[9] as string, - attachments: rest[10] as string[] + attachments: rest[10] as string[], }; } - + const messageId = params.messageId; const topics = params.topics; const users = params.users; @@ -299,60 +473,58 @@ export class Messaging { const bcc = params.bcc; const scheduledAt = params.scheduledAt; const attachments = params.attachments; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - - const apiPath = '/messaging/messages/email/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId))); - const payload: Payload = {}; + const apiPath = '/messaging/messages/email/{messageId}'.replace( + '{messageId}', + encodeURIComponent(String(messageId)), + ); + const apiPayload: Payload = {}; if (typeof topics !== 'undefined') { - payload['topics'] = topics; + apiPayload['topics'] = topics; } if (typeof users !== 'undefined') { - payload['users'] = users; + apiPayload['users'] = users; } if (typeof targets !== 'undefined') { - payload['targets'] = targets; + apiPayload['targets'] = targets; } if (typeof subject !== 'undefined') { - payload['subject'] = subject; + apiPayload['subject'] = subject; } if (typeof content !== 'undefined') { - payload['content'] = content; + apiPayload['content'] = content; } if (typeof draft !== 'undefined') { - payload['draft'] = draft; + apiPayload['draft'] = draft; } if (typeof html !== 'undefined') { - payload['html'] = html; + apiPayload['html'] = html; } if (typeof cc !== 'undefined') { - payload['cc'] = cc; + apiPayload['cc'] = cc; } if (typeof bcc !== 'undefined') { - payload['bcc'] = bcc; + apiPayload['bcc'] = bcc; } if (typeof scheduledAt !== 'undefined') { - payload['scheduledAt'] = scheduledAt; + apiPayload['scheduledAt'] = scheduledAt; } if (typeof attachments !== 'undefined') { - payload['attachments'] = attachments; + apiPayload['attachments'] = attachments; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -380,7 +552,27 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createPush(params: { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }): Promise; + createPush(params: { + messageId: string; + title?: string; + body?: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + }): Promise; /** * Create a new push notification. * @@ -407,15 +599,120 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPush(messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority): Promise; createPush( - paramsOrFirst: { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority } | string, - ...rest: [(string)?, (string)?, (string[])?, (string[])?, (string[])?, (object)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?, (MessagePriority)?] + messageId: string, + title?: string, + body?: string, + topics?: string[], + users?: string[], + targets?: string[], + data?: object, + action?: string, + image?: string, + icon?: string, + sound?: string, + color?: string, + tag?: string, + badge?: number, + draft?: boolean, + scheduledAt?: string, + contentAvailable?: boolean, + critical?: boolean, + priority?: MessagePriority, + ): Promise; + createPush( + paramsOrFirst: + | { + messageId: string; + title?: string; + body?: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + } + | string, + ...rest: [ + string?, + string?, + string[]?, + string[]?, + string[]?, + object?, + string?, + string?, + string?, + string?, + string?, + string?, + number?, + boolean?, + string?, + boolean?, + boolean?, + MessagePriority?, + ] ): Promise { - let params: { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; + let params: { + messageId: string; + title?: string; + body?: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + title?: string; + body?: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + }; } else { params = { messageId: paramsOrFirst as string, @@ -436,10 +733,10 @@ export class Messaging { scheduledAt: rest[14] as string, contentAvailable: rest[15] as boolean, critical: rest[16] as boolean, - priority: rest[17] as MessagePriority + priority: rest[17] as MessagePriority, }; } - + const messageId = params.messageId; const title = params.title; const body = params.body; @@ -459,89 +756,84 @@ export class Messaging { const contentAvailable = params.contentAvailable; const critical = params.critical; const priority = params.priority; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - const apiPath = '/messaging/messages/push'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof messageId !== 'undefined') { - payload['messageId'] = messageId; + apiPayload['messageId'] = messageId; } if (typeof title !== 'undefined') { - payload['title'] = title; + apiPayload['title'] = title; } if (typeof body !== 'undefined') { - payload['body'] = body; + apiPayload['body'] = body; } if (typeof topics !== 'undefined') { - payload['topics'] = topics; + apiPayload['topics'] = topics; } if (typeof users !== 'undefined') { - payload['users'] = users; + apiPayload['users'] = users; } if (typeof targets !== 'undefined') { - payload['targets'] = targets; + apiPayload['targets'] = targets; } if (typeof data !== 'undefined') { - payload['data'] = data; + apiPayload['data'] = data; } if (typeof action !== 'undefined') { - payload['action'] = action; + apiPayload['action'] = action; } if (typeof image !== 'undefined') { - payload['image'] = image; + apiPayload['image'] = image; } if (typeof icon !== 'undefined') { - payload['icon'] = icon; + apiPayload['icon'] = icon; } if (typeof sound !== 'undefined') { - payload['sound'] = sound; + apiPayload['sound'] = sound; } if (typeof color !== 'undefined') { - payload['color'] = color; + apiPayload['color'] = color; } if (typeof tag !== 'undefined') { - payload['tag'] = tag; + apiPayload['tag'] = tag; } if (typeof badge !== 'undefined') { - payload['badge'] = badge; + apiPayload['badge'] = badge; } if (typeof draft !== 'undefined') { - payload['draft'] = draft; + apiPayload['draft'] = draft; } if (typeof scheduledAt !== 'undefined') { - payload['scheduledAt'] = scheduledAt; + apiPayload['scheduledAt'] = scheduledAt; } if (typeof contentAvailable !== 'undefined') { - payload['contentAvailable'] = contentAvailable; + apiPayload['contentAvailable'] = contentAvailable; } if (typeof critical !== 'undefined') { - payload['critical'] = critical; + apiPayload['critical'] = critical; } if (typeof priority !== 'undefined') { - payload['priority'] = priority; + apiPayload['priority'] = priority; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * 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. - * + * * * @param {string} params.messageId - Message ID. * @param {string[]} params.topics - List of Topic IDs. @@ -565,10 +857,30 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updatePush(params: { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }): Promise; + updatePush(params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + title?: string; + body?: string; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + }): 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. - * + * * * @param {string} messageId - Message ID. * @param {string[]} topics - List of Topic IDs. @@ -593,15 +905,120 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePush(messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority): Promise; updatePush( - paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority } | string, - ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (string)?, (object)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?, (MessagePriority)?] + messageId: string, + topics?: string[], + users?: string[], + targets?: string[], + title?: string, + body?: string, + data?: object, + action?: string, + image?: string, + icon?: string, + sound?: string, + color?: string, + tag?: string, + badge?: number, + draft?: boolean, + scheduledAt?: string, + contentAvailable?: boolean, + critical?: boolean, + priority?: MessagePriority, + ): Promise; + updatePush( + paramsOrFirst: + | { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + title?: string; + body?: string; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + } + | string, + ...rest: [ + string[]?, + string[]?, + string[]?, + string?, + string?, + object?, + string?, + string?, + string?, + string?, + string?, + string?, + number?, + boolean?, + string?, + boolean?, + boolean?, + MessagePriority?, + ] ): Promise { - let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; + let params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + title?: string; + body?: string; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + title?: string; + body?: string; + data?: object; + action?: string; + image?: string; + icon?: string; + sound?: string; + color?: string; + tag?: string; + badge?: number; + draft?: boolean; + scheduledAt?: string; + contentAvailable?: boolean; + critical?: boolean; + priority?: MessagePriority; + }; } else { params = { messageId: paramsOrFirst as string, @@ -622,10 +1039,10 @@ export class Messaging { scheduledAt: rest[14] as string, contentAvailable: rest[15] as boolean, critical: rest[16] as boolean, - priority: rest[17] as MessagePriority + priority: rest[17] as MessagePriority, }; } - + const messageId = params.messageId; const topics = params.topics; const users = params.users; @@ -645,81 +1062,79 @@ export class Messaging { const contentAvailable = params.contentAvailable; const critical = params.critical; const priority = params.priority; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - - const apiPath = '/messaging/messages/push/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId))); - const payload: Payload = {}; + const apiPath = '/messaging/messages/push/{messageId}'.replace( + '{messageId}', + encodeURIComponent(String(messageId)), + ); + const apiPayload: Payload = {}; if (typeof topics !== 'undefined') { - payload['topics'] = topics; + apiPayload['topics'] = topics; } if (typeof users !== 'undefined') { - payload['users'] = users; + apiPayload['users'] = users; } if (typeof targets !== 'undefined') { - payload['targets'] = targets; + apiPayload['targets'] = targets; } if (typeof title !== 'undefined') { - payload['title'] = title; + apiPayload['title'] = title; } if (typeof body !== 'undefined') { - payload['body'] = body; + apiPayload['body'] = body; } if (typeof data !== 'undefined') { - payload['data'] = data; + apiPayload['data'] = data; } if (typeof action !== 'undefined') { - payload['action'] = action; + apiPayload['action'] = action; } if (typeof image !== 'undefined') { - payload['image'] = image; + apiPayload['image'] = image; } if (typeof icon !== 'undefined') { - payload['icon'] = icon; + apiPayload['icon'] = icon; } if (typeof sound !== 'undefined') { - payload['sound'] = sound; + apiPayload['sound'] = sound; } if (typeof color !== 'undefined') { - payload['color'] = color; + apiPayload['color'] = color; } if (typeof tag !== 'undefined') { - payload['tag'] = tag; + apiPayload['tag'] = tag; } if (typeof badge !== 'undefined') { - payload['badge'] = badge; + apiPayload['badge'] = badge; } if (typeof draft !== 'undefined') { - payload['draft'] = draft; + apiPayload['draft'] = draft; } if (typeof scheduledAt !== 'undefined') { - payload['scheduledAt'] = scheduledAt; + apiPayload['scheduledAt'] = scheduledAt; } if (typeof contentAvailable !== 'undefined') { - payload['contentAvailable'] = contentAvailable; + apiPayload['contentAvailable'] = contentAvailable; } if (typeof critical !== 'undefined') { - payload['critical'] = critical; + apiPayload['critical'] = critical; } if (typeof priority !== 'undefined') { - payload['priority'] = priority; + apiPayload['priority'] = priority; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -736,7 +1151,15 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMS` instead. */ - createSms(params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }): Promise; + createSms(params: { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + }): Promise; /** * Create a new SMS message. * @@ -751,15 +1174,53 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSms(messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string): Promise; createSms( - paramsOrFirst: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string } | string, - ...rest: [(string)?, (string[])?, (string[])?, (string[])?, (boolean)?, (string)?] + messageId: string, + content: string, + topics?: string[], + users?: string[], + targets?: string[], + draft?: boolean, + scheduledAt?: string, + ): Promise; + createSms( + paramsOrFirst: + | { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + } + | string, + ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] ): Promise { - let params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; + let params: { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + }; } else { params = { messageId: paramsOrFirst as string, @@ -768,10 +1229,10 @@ export class Messaging { users: rest[2] as string[], targets: rest[3] as string[], draft: rest[4] as boolean, - scheduledAt: rest[5] as string + scheduledAt: rest[5] as string, }; } - + const messageId = params.messageId; const content = params.content; const topics = params.topics; @@ -779,51 +1240,48 @@ export class Messaging { const targets = params.targets; const draft = params.draft; const scheduledAt = params.scheduledAt; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } if (typeof content === 'undefined') { - throw new AppwriteException('Missing required parameter: "content"'); + throw new AppwriteException( + 'Missing required parameter: "content"', + ); } - const apiPath = '/messaging/messages/sms'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof messageId !== 'undefined') { - payload['messageId'] = messageId; + apiPayload['messageId'] = messageId; } if (typeof content !== 'undefined') { - payload['content'] = content; + apiPayload['content'] = content; } if (typeof topics !== 'undefined') { - payload['topics'] = topics; + apiPayload['topics'] = topics; } if (typeof users !== 'undefined') { - payload['users'] = users; + apiPayload['users'] = users; } if (typeof targets !== 'undefined') { - payload['targets'] = targets; + apiPayload['targets'] = targets; } if (typeof draft !== 'undefined') { - payload['draft'] = draft; + apiPayload['draft'] = draft; } if (typeof scheduledAt !== 'undefined') { - payload['scheduledAt'] = scheduledAt; + apiPayload['scheduledAt'] = scheduledAt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -839,7 +1297,15 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createSMS(params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }): Promise; + createSMS(params: { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + }): Promise; /** * Create a new SMS message. * @@ -854,15 +1320,53 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSMS(messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string): Promise; createSMS( - paramsOrFirst: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string } | string, - ...rest: [(string)?, (string[])?, (string[])?, (string[])?, (boolean)?, (string)?] + messageId: string, + content: string, + topics?: string[], + users?: string[], + targets?: string[], + draft?: boolean, + scheduledAt?: string, + ): Promise; + createSMS( + paramsOrFirst: + | { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + } + | string, + ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] ): Promise { - let params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; + let params: { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + content: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + draft?: boolean; + scheduledAt?: string; + }; } else { params = { messageId: paramsOrFirst as string, @@ -871,10 +1375,10 @@ export class Messaging { users: rest[2] as string[], targets: rest[3] as string[], draft: rest[4] as boolean, - scheduledAt: rest[5] as string + scheduledAt: rest[5] as string, }; } - + const messageId = params.messageId; const content = params.content; const topics = params.topics; @@ -882,56 +1386,53 @@ export class Messaging { const targets = params.targets; const draft = params.draft; const scheduledAt = params.scheduledAt; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } if (typeof content === 'undefined') { - throw new AppwriteException('Missing required parameter: "content"'); + throw new AppwriteException( + 'Missing required parameter: "content"', + ); } - const apiPath = '/messaging/messages/sms'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof messageId !== 'undefined') { - payload['messageId'] = messageId; + apiPayload['messageId'] = messageId; } if (typeof content !== 'undefined') { - payload['content'] = content; + apiPayload['content'] = content; } if (typeof topics !== 'undefined') { - payload['topics'] = topics; + apiPayload['topics'] = topics; } if (typeof users !== 'undefined') { - payload['users'] = users; + apiPayload['users'] = users; } if (typeof targets !== 'undefined') { - payload['targets'] = targets; + apiPayload['targets'] = targets; } if (typeof draft !== 'undefined') { - payload['draft'] = draft; + apiPayload['draft'] = draft; } if (typeof scheduledAt !== 'undefined') { - payload['scheduledAt'] = scheduledAt; + apiPayload['scheduledAt'] = scheduledAt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update an SMS 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. - * + * * * @param {string} params.messageId - Message ID. * @param {string[]} params.topics - List of Topic IDs. @@ -944,10 +1445,18 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMS` instead. */ - updateSms(params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }): Promise; + updateSms(params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + }): Promise; /** * Update an SMS 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. - * + * * * @param {string} messageId - Message ID. * @param {string[]} topics - List of Topic IDs. @@ -960,15 +1469,53 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSms(messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string): Promise; updateSms( - paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string } | string, - ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (boolean)?, (string)?] + messageId: string, + topics?: string[], + users?: string[], + targets?: string[], + content?: string, + draft?: boolean, + scheduledAt?: string, + ): Promise; + updateSms( + paramsOrFirst: + | { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + } + | string, + ...rest: [string[]?, string[]?, string[]?, string?, boolean?, string?] ): Promise { - let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; + let params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + }; } else { params = { messageId: paramsOrFirst as string, @@ -977,10 +1524,10 @@ export class Messaging { targets: rest[2] as string[], content: rest[3] as string, draft: rest[4] as boolean, - scheduledAt: rest[5] as string + scheduledAt: rest[5] as string, }; } - + const messageId = params.messageId; const topics = params.topics; const users = params.users; @@ -988,50 +1535,48 @@ export class Messaging { const content = params.content; const draft = params.draft; const scheduledAt = params.scheduledAt; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - - const apiPath = '/messaging/messages/sms/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId))); - const payload: Payload = {}; + const apiPath = '/messaging/messages/sms/{messageId}'.replace( + '{messageId}', + encodeURIComponent(String(messageId)), + ); + const apiPayload: Payload = {}; if (typeof topics !== 'undefined') { - payload['topics'] = topics; + apiPayload['topics'] = topics; } if (typeof users !== 'undefined') { - payload['users'] = users; + apiPayload['users'] = users; } if (typeof targets !== 'undefined') { - payload['targets'] = targets; + apiPayload['targets'] = targets; } if (typeof content !== 'undefined') { - payload['content'] = content; + apiPayload['content'] = content; } if (typeof draft !== 'undefined') { - payload['draft'] = draft; + apiPayload['draft'] = draft; } if (typeof scheduledAt !== 'undefined') { - payload['scheduledAt'] = scheduledAt; + apiPayload['scheduledAt'] = scheduledAt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Update an SMS 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. - * + * * * @param {string} params.messageId - Message ID. * @param {string[]} params.topics - List of Topic IDs. @@ -1043,10 +1588,18 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateSMS(params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }): Promise; + updateSMS(params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + }): Promise; /** * Update an SMS 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. - * + * * * @param {string} messageId - Message ID. * @param {string[]} topics - List of Topic IDs. @@ -1059,15 +1612,53 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSMS(messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string): Promise; updateSMS( - paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string } | string, - ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (boolean)?, (string)?] + messageId: string, + topics?: string[], + users?: string[], + targets?: string[], + content?: string, + draft?: boolean, + scheduledAt?: string, + ): Promise; + updateSMS( + paramsOrFirst: + | { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + } + | string, + ...rest: [string[]?, string[]?, string[]?, string?, boolean?, string?] ): Promise { - let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; + let params: { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + topics?: string[]; + users?: string[]; + targets?: string[]; + content?: string; + draft?: boolean; + scheduledAt?: string; + }; } else { params = { messageId: paramsOrFirst as string, @@ -1076,10 +1667,10 @@ export class Messaging { targets: rest[2] as string[], content: rest[3] as string, draft: rest[4] as boolean, - scheduledAt: rest[5] as string + scheduledAt: rest[5] as string, }; } - + const messageId = params.messageId; const topics = params.topics; const users = params.users; @@ -1087,50 +1678,48 @@ export class Messaging { const content = params.content; const draft = params.draft; const scheduledAt = params.scheduledAt; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - - const apiPath = '/messaging/messages/sms/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId))); - const payload: Payload = {}; + const apiPath = '/messaging/messages/sms/{messageId}'.replace( + '{messageId}', + encodeURIComponent(String(messageId)), + ); + const apiPayload: Payload = {}; if (typeof topics !== 'undefined') { - payload['topics'] = topics; + apiPayload['topics'] = topics; } if (typeof users !== 'undefined') { - payload['users'] = users; + apiPayload['users'] = users; } if (typeof targets !== 'undefined') { - payload['targets'] = targets; + apiPayload['targets'] = targets; } if (typeof content !== 'undefined') { - payload['content'] = content; + apiPayload['content'] = content; } if (typeof draft !== 'undefined') { - payload['draft'] = draft; + apiPayload['draft'] = draft; } if (typeof scheduledAt !== 'undefined') { - payload['scheduledAt'] = scheduledAt; + apiPayload['scheduledAt'] = scheduledAt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Get a message by its unique ID. - * + * * * @param {string} params.messageId - Message ID. * @throws {AppwriteException} @@ -1139,7 +1728,7 @@ export class Messaging { getMessage(params: { messageId: string }): Promise; /** * Get a message by its unique ID. - * + * * * @param {string} messageId - Message ID. * @throws {AppwriteException} @@ -1148,39 +1737,41 @@ export class Messaging { */ getMessage(messageId: string): Promise; getMessage( - paramsOrFirst: { messageId: string } | string + paramsOrFirst: { messageId: string } | string, ): Promise { let params: { messageId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { messageId: string }; } else { params = { - messageId: paramsOrFirst as string + messageId: paramsOrFirst as string, }; } - - const messageId = params.messageId; + const messageId = params.messageId; if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - - const apiPath = '/messaging/messages/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId))); - const payload: Payload = {}; + const apiPath = '/messaging/messages/{messageId}'.replace( + '{messageId}', + encodeURIComponent(String(messageId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1200,40 +1791,40 @@ export class Messaging { * @deprecated Use the object parameter style method for a better developer experience. */ delete(messageId: string): Promise<{}>; - delete( - paramsOrFirst: { messageId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { messageId: string } | string): Promise<{}> { let params: { messageId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { messageId: string }; } else { params = { - messageId: paramsOrFirst as string + messageId: paramsOrFirst as string, }; } - - const messageId = params.messageId; + const messageId = params.messageId; if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - - const apiPath = '/messaging/messages/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId))); - const payload: Payload = {}; + const apiPath = '/messaging/messages/{messageId}'.replace( + '{messageId}', + encodeURIComponent(String(messageId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1245,7 +1836,11 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - listTargets(params: { messageId: string, queries?: string[], total?: boolean }): Promise; + listTargets(params: { + messageId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of the targets associated with a message. * @@ -1256,52 +1851,63 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTargets(messageId: string, queries?: string[], total?: boolean): Promise; listTargets( - paramsOrFirst: { messageId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + messageId: string, + queries?: string[], + total?: boolean, + ): Promise; + listTargets( + paramsOrFirst: + { messageId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { messageId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { messageId: string, queries?: string[], total?: boolean }; + let params: { messageId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + messageId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { messageId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const messageId = params.messageId; const queries = params.queries; const total = params.total; - if (typeof messageId === 'undefined') { - throw new AppwriteException('Missing required parameter: "messageId"'); + throw new AppwriteException( + 'Missing required parameter: "messageId"', + ); } - - const apiPath = '/messaging/messages/{messageId}/targets'.replace('{messageId}', encodeURIComponent(String(messageId))); - const payload: Payload = {}; + const apiPath = '/messaging/messages/{messageId}/targets'.replace( + '{messageId}', + encodeURIComponent(String(messageId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1313,7 +1919,11 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - listProviders(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listProviders(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all providers from the current Appwrite project. * @@ -1324,52 +1934,59 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listProviders(queries?: string[], search?: string, total?: boolean): Promise; listProviders( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listProviders( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - - const apiPath = '/messaging/providers'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1387,7 +2004,16 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createAPNSProvider` instead. */ - createApnsProvider(params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }): Promise; + createApnsProvider(params: { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + }): Promise; /** * Create a new Apple Push Notification service provider. * @@ -1403,15 +2029,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createApnsProvider(providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean): Promise; createApnsProvider( - paramsOrFirst: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (boolean)?] + providerId: string, + name: string, + authKey?: string, + authKeyId?: string, + teamId?: string, + bundleId?: string, + sandbox?: boolean, + enabled?: boolean, + ): Promise; + createApnsProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + boolean?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; + let params: { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -1421,10 +2097,10 @@ export class Messaging { teamId: rest[3] as string, bundleId: rest[4] as string, sandbox: rest[5] as boolean, - enabled: rest[6] as boolean + enabled: rest[6] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const authKey = params.authKey; @@ -1433,54 +2109,49 @@ export class Messaging { const bundleId = params.bundleId; const sandbox = params.sandbox; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/apns'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof authKey !== 'undefined') { - payload['authKey'] = authKey; + apiPayload['authKey'] = authKey; } if (typeof authKeyId !== 'undefined') { - payload['authKeyId'] = authKeyId; + apiPayload['authKeyId'] = authKeyId; } if (typeof teamId !== 'undefined') { - payload['teamId'] = teamId; + apiPayload['teamId'] = teamId; } if (typeof bundleId !== 'undefined') { - payload['bundleId'] = bundleId; + apiPayload['bundleId'] = bundleId; } if (typeof sandbox !== 'undefined') { - payload['sandbox'] = sandbox; + apiPayload['sandbox'] = sandbox; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1497,7 +2168,16 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createAPNSProvider(params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }): Promise; + createAPNSProvider(params: { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + }): Promise; /** * Create a new Apple Push Notification service provider. * @@ -1513,15 +2193,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createAPNSProvider(providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean): Promise; createAPNSProvider( - paramsOrFirst: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (boolean)?] + providerId: string, + name: string, + authKey?: string, + authKeyId?: string, + teamId?: string, + bundleId?: string, + sandbox?: boolean, + enabled?: boolean, + ): Promise; + createAPNSProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + boolean?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; + let params: { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -1531,10 +2261,10 @@ export class Messaging { teamId: rest[3] as string, bundleId: rest[4] as string, sandbox: rest[5] as boolean, - enabled: rest[6] as boolean + enabled: rest[6] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const authKey = params.authKey; @@ -1543,54 +2273,49 @@ export class Messaging { const bundleId = params.bundleId; const sandbox = params.sandbox; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/apns'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof authKey !== 'undefined') { - payload['authKey'] = authKey; + apiPayload['authKey'] = authKey; } if (typeof authKeyId !== 'undefined') { - payload['authKeyId'] = authKeyId; + apiPayload['authKeyId'] = authKeyId; } if (typeof teamId !== 'undefined') { - payload['teamId'] = teamId; + apiPayload['teamId'] = teamId; } if (typeof bundleId !== 'undefined') { - payload['bundleId'] = bundleId; + apiPayload['bundleId'] = bundleId; } if (typeof sandbox !== 'undefined') { - payload['sandbox'] = sandbox; + apiPayload['sandbox'] = sandbox; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1608,7 +2333,16 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateAPNSProvider` instead. */ - updateApnsProvider(params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }): Promise; + updateApnsProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + }): Promise; /** * Update a Apple Push Notification service provider by its unique ID. * @@ -1624,15 +2358,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateApnsProvider(providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean): Promise; updateApnsProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name?: string, + enabled?: boolean, + authKey?: string, + authKeyId?: string, + teamId?: string, + bundleId?: string, + sandbox?: boolean, + ): Promise; + updateApnsProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + } + | string, + ...rest: [ + string?, + boolean?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -1642,10 +2426,10 @@ export class Messaging { authKeyId: rest[3] as string, teamId: rest[4] as string, bundleId: rest[5] as string, - sandbox: rest[6] as boolean + sandbox: rest[6] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; @@ -1654,48 +2438,46 @@ export class Messaging { const teamId = params.teamId; const bundleId = params.bundleId; const sandbox = params.sandbox; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/apns/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/apns/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof authKey !== 'undefined') { - payload['authKey'] = authKey; + apiPayload['authKey'] = authKey; } if (typeof authKeyId !== 'undefined') { - payload['authKeyId'] = authKeyId; + apiPayload['authKeyId'] = authKeyId; } if (typeof teamId !== 'undefined') { - payload['teamId'] = teamId; + apiPayload['teamId'] = teamId; } if (typeof bundleId !== 'undefined') { - payload['bundleId'] = bundleId; + apiPayload['bundleId'] = bundleId; } if (typeof sandbox !== 'undefined') { - payload['sandbox'] = sandbox; + apiPayload['sandbox'] = sandbox; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1712,7 +2494,16 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateAPNSProvider(params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }): Promise; + updateAPNSProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + }): Promise; /** * Update a Apple Push Notification service provider by its unique ID. * @@ -1728,15 +2519,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateAPNSProvider(providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean): Promise; updateAPNSProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name?: string, + enabled?: boolean, + authKey?: string, + authKeyId?: string, + teamId?: string, + bundleId?: string, + sandbox?: boolean, + ): Promise; + updateAPNSProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + } + | string, + ...rest: [ + string?, + boolean?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + authKey?: string; + authKeyId?: string; + teamId?: string; + bundleId?: string; + sandbox?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -1746,10 +2587,10 @@ export class Messaging { authKeyId: rest[3] as string, teamId: rest[4] as string, bundleId: rest[5] as string, - sandbox: rest[6] as boolean + sandbox: rest[6] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; @@ -1758,48 +2599,46 @@ export class Messaging { const teamId = params.teamId; const bundleId = params.bundleId; const sandbox = params.sandbox; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/apns/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/apns/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof authKey !== 'undefined') { - payload['authKey'] = authKey; + apiPayload['authKey'] = authKey; } if (typeof authKeyId !== 'undefined') { - payload['authKeyId'] = authKeyId; + apiPayload['authKeyId'] = authKeyId; } if (typeof teamId !== 'undefined') { - payload['teamId'] = teamId; + apiPayload['teamId'] = teamId; } if (typeof bundleId !== 'undefined') { - payload['bundleId'] = bundleId; + apiPayload['bundleId'] = bundleId; } if (typeof sandbox !== 'undefined') { - payload['sandbox'] = sandbox; + apiPayload['sandbox'] = sandbox; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1813,7 +2652,12 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createFCMProvider` instead. */ - createFcmProvider(params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }): Promise; + createFcmProvider(params: { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + }): Promise; /** * Create a new Firebase Cloud Messaging provider. * @@ -1825,64 +2669,85 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFcmProvider(providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean): Promise; createFcmProvider( - paramsOrFirst: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean } | string, - ...rest: [(string)?, (object)?, (boolean)?] + providerId: string, + name: string, + serviceAccountJSON?: object, + enabled?: boolean, + ): Promise; + createFcmProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + } + | string, + ...rest: [string?, object?, boolean?] ): Promise { - let params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + let params: { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, serviceAccountJSON: rest[1] as object, - enabled: rest[2] as boolean + enabled: rest[2] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const serviceAccountJSON = params.serviceAccountJSON; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/fcm'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof serviceAccountJSON !== 'undefined') { - payload['serviceAccountJSON'] = serviceAccountJSON; + apiPayload['serviceAccountJSON'] = serviceAccountJSON; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1895,7 +2760,12 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createFCMProvider(params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }): Promise; + createFCMProvider(params: { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + }): Promise; /** * Create a new Firebase Cloud Messaging provider. * @@ -1907,64 +2777,85 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFCMProvider(providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean): Promise; createFCMProvider( - paramsOrFirst: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean } | string, - ...rest: [(string)?, (object)?, (boolean)?] + providerId: string, + name: string, + serviceAccountJSON?: object, + enabled?: boolean, + ): Promise; + createFCMProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + } + | string, + ...rest: [string?, object?, boolean?] ): Promise { - let params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + let params: { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + serviceAccountJSON?: object; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, serviceAccountJSON: rest[1] as object, - enabled: rest[2] as boolean + enabled: rest[2] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const serviceAccountJSON = params.serviceAccountJSON; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/fcm'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof serviceAccountJSON !== 'undefined') { - payload['serviceAccountJSON'] = serviceAccountJSON; + apiPayload['serviceAccountJSON'] = serviceAccountJSON; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1978,7 +2869,12 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateFCMProvider` instead. */ - updateFcmProvider(params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }): Promise; + updateFcmProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + }): Promise; /** * Update a Firebase Cloud Messaging provider by its unique ID. * @@ -1990,58 +2886,82 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateFcmProvider(providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object): Promise; updateFcmProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object } | string, - ...rest: [(string)?, (boolean)?, (object)?] + providerId: string, + name?: string, + enabled?: boolean, + serviceAccountJSON?: object, + ): Promise; + updateFcmProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + } + | string, + ...rest: [string?, boolean?, object?] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, - serviceAccountJSON: rest[2] as object + serviceAccountJSON: rest[2] as object, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; const serviceAccountJSON = params.serviceAccountJSON; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/fcm/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/fcm/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof serviceAccountJSON !== 'undefined') { - payload['serviceAccountJSON'] = serviceAccountJSON; + apiPayload['serviceAccountJSON'] = serviceAccountJSON; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2054,7 +2974,12 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateFCMProvider(params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }): Promise; + updateFCMProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + }): Promise; /** * Update a Firebase Cloud Messaging provider by its unique ID. * @@ -2066,58 +2991,82 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateFCMProvider(providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object): Promise; updateFCMProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object } | string, - ...rest: [(string)?, (boolean)?, (object)?] + providerId: string, + name?: string, + enabled?: boolean, + serviceAccountJSON?: object, + ): Promise; + updateFCMProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + } + | string, + ...rest: [string?, boolean?, object?] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + serviceAccountJSON?: object; + }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, - serviceAccountJSON: rest[2] as object + serviceAccountJSON: rest[2] as object, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; const serviceAccountJSON = params.serviceAccountJSON; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/fcm/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/fcm/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof serviceAccountJSON !== 'undefined') { - payload['serviceAccountJSON'] = serviceAccountJSON; + apiPayload['serviceAccountJSON'] = serviceAccountJSON; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2136,7 +3085,18 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createMailgunProvider(params: { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + createMailgunProvider(params: { + providerId: string; + name: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Create a new Mailgun provider. * @@ -2154,15 +3114,75 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMailgunProvider(providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; createMailgunProvider( - paramsOrFirst: { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + apiKey?: string, + domain?: string, + isEuRegion?: boolean, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + createMailgunProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + boolean?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2174,10 +3194,10 @@ export class Messaging { fromEmail: rest[5] as string, replyToName: rest[6] as string, replyToEmail: rest[7] as string, - enabled: rest[8] as boolean + enabled: rest[8] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const apiKey = params.apiKey; @@ -2188,60 +3208,55 @@ export class Messaging { const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/mailgun'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + apiPayload['apiKey'] = apiKey; } if (typeof domain !== 'undefined') { - payload['domain'] = domain; + apiPayload['domain'] = domain; } if (typeof isEuRegion !== 'undefined') { - payload['isEuRegion'] = isEuRegion; + apiPayload['isEuRegion'] = isEuRegion; } if (typeof fromName !== 'undefined') { - payload['fromName'] = fromName; + apiPayload['fromName'] = fromName; } if (typeof fromEmail !== 'undefined') { - payload['fromEmail'] = fromEmail; + apiPayload['fromEmail'] = fromEmail; } if (typeof replyToName !== 'undefined') { - payload['replyToName'] = replyToName; + apiPayload['replyToName'] = replyToName; } if (typeof replyToEmail !== 'undefined') { - payload['replyToEmail'] = replyToEmail; + apiPayload['replyToEmail'] = replyToEmail; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2260,7 +3275,18 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateMailgunProvider(params: { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }): Promise; + updateMailgunProvider(params: { + providerId: string; + name?: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + enabled?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }): Promise; /** * Update a Mailgun provider by its unique ID. * @@ -2278,15 +3304,75 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMailgunProvider(providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise; updateMailgunProvider( - paramsOrFirst: { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?, (boolean)?, (string)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + apiKey?: string, + domain?: string, + isEuRegion?: boolean, + enabled?: boolean, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + ): Promise; + updateMailgunProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + enabled?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + boolean?, + boolean?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + let params: { + providerId: string; + name?: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + enabled?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + apiKey?: string; + domain?: string; + isEuRegion?: boolean; + enabled?: boolean; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2298,10 +3384,10 @@ export class Messaging { fromName: rest[5] as string, fromEmail: rest[6] as string, replyToName: rest[7] as string, - replyToEmail: rest[8] as string + replyToEmail: rest[8] as string, }; } - + const providerId = params.providerId; const name = params.name; const apiKey = params.apiKey; @@ -2312,54 +3398,52 @@ export class Messaging { const fromEmail = params.fromEmail; const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/mailgun/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/mailgun/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + apiPayload['apiKey'] = apiKey; } if (typeof domain !== 'undefined') { - payload['domain'] = domain; + apiPayload['domain'] = domain; } if (typeof isEuRegion !== 'undefined') { - payload['isEuRegion'] = isEuRegion; + apiPayload['isEuRegion'] = isEuRegion; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof fromName !== 'undefined') { - payload['fromName'] = fromName; + apiPayload['fromName'] = fromName; } if (typeof fromEmail !== 'undefined') { - payload['fromEmail'] = fromEmail; + apiPayload['fromEmail'] = fromEmail; } if (typeof replyToName !== 'undefined') { - payload['replyToName'] = replyToName; + apiPayload['replyToName'] = replyToName; } if (typeof replyToEmail !== 'undefined') { - payload['replyToEmail'] = replyToEmail; + apiPayload['replyToEmail'] = replyToEmail; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2374,7 +3458,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createMsg91Provider(params: { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean }): Promise; + createMsg91Provider(params: { + providerId: string; + name: string; + templateId?: string; + senderId?: string; + authKey?: string; + enabled?: boolean; + }): Promise; /** * Create a new MSG91 provider. * @@ -2388,15 +3479,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMsg91Provider(providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise; createMsg91Provider( - paramsOrFirst: { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + templateId?: string, + senderId?: string, + authKey?: string, + enabled?: boolean, + ): Promise; + createMsg91Provider( + paramsOrFirst: + | { + providerId: string; + name: string; + templateId?: string; + senderId?: string; + authKey?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, string?, boolean?] ): Promise { - let params: { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + templateId?: string; + senderId?: string; + authKey?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + templateId?: string; + senderId?: string; + authKey?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2404,58 +3529,53 @@ export class Messaging { templateId: rest[1] as string, senderId: rest[2] as string, authKey: rest[3] as string, - enabled: rest[4] as boolean + enabled: rest[4] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const templateId = params.templateId; const senderId = params.senderId; const authKey = params.authKey; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/msg91'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof templateId !== 'undefined') { - payload['templateId'] = templateId; + apiPayload['templateId'] = templateId; } if (typeof senderId !== 'undefined') { - payload['senderId'] = senderId; + apiPayload['senderId'] = senderId; } if (typeof authKey !== 'undefined') { - payload['authKey'] = authKey; + apiPayload['authKey'] = authKey; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2470,7 +3590,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateMsg91Provider(params: { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string }): Promise; + updateMsg91Provider(params: { + providerId: string; + name?: string; + enabled?: boolean; + templateId?: string; + senderId?: string; + authKey?: string; + }): Promise; /** * Update a MSG91 provider by its unique ID. * @@ -2484,15 +3611,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string): Promise; updateMsg91Provider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + templateId?: string, + senderId?: string, + authKey?: string, + ): Promise; + updateMsg91Provider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + templateId?: string; + senderId?: string; + authKey?: string; + } + | string, + ...rest: [string?, boolean?, string?, string?, string?] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + templateId?: string; + senderId?: string; + authKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + templateId?: string; + senderId?: string; + authKey?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2500,52 +3661,50 @@ export class Messaging { enabled: rest[1] as boolean, templateId: rest[2] as string, senderId: rest[3] as string, - authKey: rest[4] as string + authKey: rest[4] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; const templateId = params.templateId; const senderId = params.senderId; const authKey = params.authKey; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/msg91/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/msg91/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof templateId !== 'undefined') { - payload['templateId'] = templateId; + apiPayload['templateId'] = templateId; } if (typeof senderId !== 'undefined') { - payload['senderId'] = senderId; + apiPayload['senderId'] = senderId; } if (typeof authKey !== 'undefined') { - payload['authKey'] = authKey; + apiPayload['authKey'] = authKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2562,7 +3721,16 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createResendProvider(params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + createResendProvider(params: { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Create a new Resend provider. * @@ -2578,15 +3746,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createResendProvider(providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; createResendProvider( - paramsOrFirst: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + apiKey?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + createResendProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2596,10 +3814,10 @@ export class Messaging { fromEmail: rest[3] as string, replyToName: rest[4] as string, replyToEmail: rest[5] as string, - enabled: rest[6] as boolean + enabled: rest[6] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const apiKey = params.apiKey; @@ -2608,54 +3826,49 @@ export class Messaging { const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/resend'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + apiPayload['apiKey'] = apiKey; } if (typeof fromName !== 'undefined') { - payload['fromName'] = fromName; + apiPayload['fromName'] = fromName; } if (typeof fromEmail !== 'undefined') { - payload['fromEmail'] = fromEmail; + apiPayload['fromEmail'] = fromEmail; } if (typeof replyToName !== 'undefined') { - payload['replyToName'] = replyToName; + apiPayload['replyToName'] = replyToName; } if (typeof replyToEmail !== 'undefined') { - payload['replyToEmail'] = replyToEmail; + apiPayload['replyToEmail'] = replyToEmail; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2672,7 +3885,16 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateResendProvider(params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }): Promise; + updateResendProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }): Promise; /** * Update a Resend provider by its unique ID. * @@ -2688,15 +3910,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateResendProvider(providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise; updateResendProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + apiKey?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + ): Promise; + updateResendProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + } + | string, + ...rest: [ + string?, + boolean?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2706,10 +3978,10 @@ export class Messaging { fromName: rest[3] as string, fromEmail: rest[4] as string, replyToName: rest[5] as string, - replyToEmail: rest[6] as string + replyToEmail: rest[6] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; @@ -2718,48 +3990,46 @@ export class Messaging { const fromEmail = params.fromEmail; const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/resend/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/resend/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + apiPayload['apiKey'] = apiKey; } if (typeof fromName !== 'undefined') { - payload['fromName'] = fromName; + apiPayload['fromName'] = fromName; } if (typeof fromEmail !== 'undefined') { - payload['fromEmail'] = fromEmail; + apiPayload['fromEmail'] = fromEmail; } if (typeof replyToName !== 'undefined') { - payload['replyToName'] = replyToName; + apiPayload['replyToName'] = replyToName; } if (typeof replyToEmail !== 'undefined') { - payload['replyToEmail'] = replyToEmail; + apiPayload['replyToEmail'] = replyToEmail; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2776,7 +4046,16 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createSendgridProvider(params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + createSendgridProvider(params: { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Create a new Sendgrid provider. * @@ -2792,15 +4071,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSendgridProvider(providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; createSendgridProvider( - paramsOrFirst: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + apiKey?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + createSendgridProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2810,10 +4139,10 @@ export class Messaging { fromEmail: rest[3] as string, replyToName: rest[4] as string, replyToEmail: rest[5] as string, - enabled: rest[6] as boolean + enabled: rest[6] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const apiKey = params.apiKey; @@ -2822,54 +4151,49 @@ export class Messaging { const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/sendgrid'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + apiPayload['apiKey'] = apiKey; } if (typeof fromName !== 'undefined') { - payload['fromName'] = fromName; + apiPayload['fromName'] = fromName; } if (typeof fromEmail !== 'undefined') { - payload['fromEmail'] = fromEmail; + apiPayload['fromEmail'] = fromEmail; } if (typeof replyToName !== 'undefined') { - payload['replyToName'] = replyToName; + apiPayload['replyToName'] = replyToName; } if (typeof replyToEmail !== 'undefined') { - payload['replyToEmail'] = replyToEmail; + apiPayload['replyToEmail'] = replyToEmail; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2886,7 +4210,16 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateSendgridProvider(params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }): Promise; + updateSendgridProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }): Promise; /** * Update a Sendgrid provider by its unique ID. * @@ -2902,15 +4235,65 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSendgridProvider(providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise; updateSendgridProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + apiKey?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + ): Promise; + updateSendgridProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + } + | string, + ...rest: [ + string?, + boolean?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -2920,10 +4303,10 @@ export class Messaging { fromName: rest[3] as string, fromEmail: rest[4] as string, replyToName: rest[5] as string, - replyToEmail: rest[6] as string + replyToEmail: rest[6] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; @@ -2932,48 +4315,46 @@ export class Messaging { const fromEmail = params.fromEmail; const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/sendgrid/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/sendgrid/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + apiPayload['apiKey'] = apiKey; } if (typeof fromName !== 'undefined') { - payload['fromName'] = fromName; + apiPayload['fromName'] = fromName; } if (typeof fromEmail !== 'undefined') { - payload['fromEmail'] = fromEmail; + apiPayload['fromEmail'] = fromEmail; } if (typeof replyToName !== 'undefined') { - payload['replyToName'] = replyToName; + apiPayload['replyToName'] = replyToName; } if (typeof replyToEmail !== 'undefined') { - payload['replyToEmail'] = replyToEmail; + apiPayload['replyToEmail'] = replyToEmail; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2992,7 +4373,18 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createSesProvider(params: { providerId: string, name: string, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + createSesProvider(params: { + providerId: string; + name: string; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Create a new Amazon SES provider. * @@ -3010,15 +4402,75 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSesProvider(providerId: string, name: string, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; createSesProvider( - paramsOrFirst: { providerId: string, name: string, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + accessKey?: string, + secretKey?: string, + region?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + createSesProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3030,10 +4482,10 @@ export class Messaging { fromEmail: rest[5] as string, replyToName: rest[6] as string, replyToEmail: rest[7] as string, - enabled: rest[8] as boolean + enabled: rest[8] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const accessKey = params.accessKey; @@ -3044,60 +4496,55 @@ export class Messaging { const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/ses'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof accessKey !== 'undefined') { - payload['accessKey'] = accessKey; + apiPayload['accessKey'] = accessKey; } if (typeof secretKey !== 'undefined') { - payload['secretKey'] = secretKey; + apiPayload['secretKey'] = secretKey; } if (typeof region !== 'undefined') { - payload['region'] = region; + apiPayload['region'] = region; } if (typeof fromName !== 'undefined') { - payload['fromName'] = fromName; + apiPayload['fromName'] = fromName; } if (typeof fromEmail !== 'undefined') { - payload['fromEmail'] = fromEmail; + apiPayload['fromEmail'] = fromEmail; } if (typeof replyToName !== 'undefined') { - payload['replyToName'] = replyToName; + apiPayload['replyToName'] = replyToName; } if (typeof replyToEmail !== 'undefined') { - payload['replyToEmail'] = replyToEmail; + apiPayload['replyToEmail'] = replyToEmail; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3116,7 +4563,18 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateSesProvider(params: { providerId: string, name?: string, enabled?: boolean, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }): Promise; + updateSesProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }): Promise; /** * Update an Amazon SES provider by its unique ID. * @@ -3134,15 +4592,75 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSesProvider(providerId: string, name?: string, enabled?: boolean, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise; updateSesProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + accessKey?: string, + secretKey?: string, + region?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + ): Promise; + updateSesProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + } + | string, + ...rest: [ + string?, + boolean?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, accessKey?: string, secretKey?: string, region?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + accessKey?: string; + secretKey?: string; + region?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3154,10 +4672,10 @@ export class Messaging { fromName: rest[5] as string, fromEmail: rest[6] as string, replyToName: rest[7] as string, - replyToEmail: rest[8] as string + replyToEmail: rest[8] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; @@ -3168,54 +4686,52 @@ export class Messaging { const fromEmail = params.fromEmail; const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/ses/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/ses/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof accessKey !== 'undefined') { - payload['accessKey'] = accessKey; + apiPayload['accessKey'] = accessKey; } if (typeof secretKey !== 'undefined') { - payload['secretKey'] = secretKey; + apiPayload['secretKey'] = secretKey; } if (typeof region !== 'undefined') { - payload['region'] = region; + apiPayload['region'] = region; } if (typeof fromName !== 'undefined') { - payload['fromName'] = fromName; + apiPayload['fromName'] = fromName; } if (typeof fromEmail !== 'undefined') { - payload['fromEmail'] = fromEmail; + apiPayload['fromEmail'] = fromEmail; } if (typeof replyToName !== 'undefined') { - payload['replyToName'] = replyToName; + apiPayload['replyToName'] = replyToName; } if (typeof replyToEmail !== 'undefined') { - payload['replyToEmail'] = replyToEmail; + apiPayload['replyToEmail'] = replyToEmail; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3239,7 +4755,22 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMTPProvider` instead. */ - createSmtpProvider(params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + createSmtpProvider(params: { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Create a new SMTP provider. * @@ -3261,15 +4792,95 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSmtpProvider(providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; createSmtpProvider( - paramsOrFirst: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + host: string, + port?: number, + username?: string, + password?: string, + encryption?: SmtpEncryption, + autoTLS?: boolean, + mailer?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + createSmtpProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + string?, + string?, + SmtpEncryption?, + boolean?, + string?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3285,10 +4896,10 @@ export class Messaging { fromEmail: rest[9] as string, replyToName: rest[10] as string, replyToEmail: rest[11] as string, - enabled: rest[12] as boolean + enabled: rest[12] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const host = params.host; @@ -3303,9 +4914,10 @@ export class Messaging { const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -3313,65 +4925,59 @@ export class Messaging { if (typeof host === 'undefined') { throw new AppwriteException('Missing required parameter: "host"'); } - const apiPath = '/messaging/providers/smtp'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof host !== 'undefined') { - payload['host'] = host; + apiPayload['host'] = host; } if (typeof port !== 'undefined') { - payload['port'] = port; + apiPayload['port'] = port; } if (typeof username !== 'undefined') { - payload['username'] = username; + apiPayload['username'] = username; } if (typeof password !== 'undefined') { - payload['password'] = password; + apiPayload['password'] = password; } if (typeof encryption !== 'undefined') { - payload['encryption'] = encryption; + apiPayload['encryption'] = encryption; } if (typeof autoTLS !== 'undefined') { - payload['autoTLS'] = autoTLS; + apiPayload['autoTLS'] = autoTLS; } if (typeof mailer !== 'undefined') { - payload['mailer'] = mailer; + apiPayload['mailer'] = mailer; } if (typeof fromName !== 'undefined') { - payload['fromName'] = fromName; + apiPayload['fromName'] = fromName; } if (typeof fromEmail !== 'undefined') { - payload['fromEmail'] = fromEmail; + apiPayload['fromEmail'] = fromEmail; } if (typeof replyToName !== 'undefined') { - payload['replyToName'] = replyToName; + apiPayload['replyToName'] = replyToName; } if (typeof replyToEmail !== 'undefined') { - payload['replyToEmail'] = replyToEmail; + apiPayload['replyToEmail'] = replyToEmail; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3394,7 +5000,22 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createSMTPProvider(params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + createSMTPProvider(params: { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Create a new SMTP provider. * @@ -3416,15 +5037,95 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSMTPProvider(providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; createSMTPProvider( - paramsOrFirst: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + host: string, + port?: number, + username?: string, + password?: string, + encryption?: SmtpEncryption, + autoTLS?: boolean, + mailer?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + createSMTPProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + string?, + string?, + SmtpEncryption?, + boolean?, + string?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + host: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3440,10 +5141,10 @@ export class Messaging { fromEmail: rest[9] as string, replyToName: rest[10] as string, replyToEmail: rest[11] as string, - enabled: rest[12] as boolean + enabled: rest[12] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const host = params.host; @@ -3458,9 +5159,10 @@ export class Messaging { const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -3468,65 +5170,59 @@ export class Messaging { if (typeof host === 'undefined') { throw new AppwriteException('Missing required parameter: "host"'); } - const apiPath = '/messaging/providers/smtp'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof host !== 'undefined') { - payload['host'] = host; + apiPayload['host'] = host; } if (typeof port !== 'undefined') { - payload['port'] = port; + apiPayload['port'] = port; } if (typeof username !== 'undefined') { - payload['username'] = username; + apiPayload['username'] = username; } if (typeof password !== 'undefined') { - payload['password'] = password; + apiPayload['password'] = password; } if (typeof encryption !== 'undefined') { - payload['encryption'] = encryption; + apiPayload['encryption'] = encryption; } if (typeof autoTLS !== 'undefined') { - payload['autoTLS'] = autoTLS; + apiPayload['autoTLS'] = autoTLS; } if (typeof mailer !== 'undefined') { - payload['mailer'] = mailer; + apiPayload['mailer'] = mailer; } if (typeof fromName !== 'undefined') { - payload['fromName'] = fromName; + apiPayload['fromName'] = fromName; } if (typeof fromEmail !== 'undefined') { - payload['fromEmail'] = fromEmail; + apiPayload['fromEmail'] = fromEmail; } if (typeof replyToName !== 'undefined') { - payload['replyToName'] = replyToName; + apiPayload['replyToName'] = replyToName; } if (typeof replyToEmail !== 'undefined') { - payload['replyToEmail'] = replyToEmail; + apiPayload['replyToEmail'] = replyToEmail; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3550,7 +5246,22 @@ export class Messaging { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMTPProvider` instead. */ - updateSmtpProvider(params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + updateSmtpProvider(params: { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Update a SMTP provider by its unique ID. * @@ -3572,15 +5283,95 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSmtpProvider(providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; updateSmtpProvider( - paramsOrFirst: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name?: string, + host?: string, + port?: number, + username?: string, + password?: string, + encryption?: SmtpEncryption, + autoTLS?: boolean, + mailer?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + updateSmtpProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + string?, + string?, + SmtpEncryption?, + boolean?, + string?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3596,10 +5387,10 @@ export class Messaging { fromEmail: rest[9] as string, replyToName: rest[10] as string, replyToEmail: rest[11] as string, - enabled: rest[12] as boolean + enabled: rest[12] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const host = params.host; @@ -3614,66 +5405,64 @@ export class Messaging { const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/smtp/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/smtp/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof host !== 'undefined') { - payload['host'] = host; + apiPayload['host'] = host; } if (typeof port !== 'undefined') { - payload['port'] = port; + apiPayload['port'] = port; } if (typeof username !== 'undefined') { - payload['username'] = username; + apiPayload['username'] = username; } if (typeof password !== 'undefined') { - payload['password'] = password; + apiPayload['password'] = password; } if (typeof encryption !== 'undefined') { - payload['encryption'] = encryption; + apiPayload['encryption'] = encryption; } if (typeof autoTLS !== 'undefined') { - payload['autoTLS'] = autoTLS; + apiPayload['autoTLS'] = autoTLS; } if (typeof mailer !== 'undefined') { - payload['mailer'] = mailer; + apiPayload['mailer'] = mailer; } if (typeof fromName !== 'undefined') { - payload['fromName'] = fromName; + apiPayload['fromName'] = fromName; } if (typeof fromEmail !== 'undefined') { - payload['fromEmail'] = fromEmail; + apiPayload['fromEmail'] = fromEmail; } if (typeof replyToName !== 'undefined') { - payload['replyToName'] = replyToName; + apiPayload['replyToName'] = replyToName; } if (typeof replyToEmail !== 'undefined') { - payload['replyToEmail'] = replyToEmail; + apiPayload['replyToEmail'] = replyToEmail; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3696,7 +5485,22 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateSMTPProvider(params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise; + updateSMTPProvider(params: { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }): Promise; /** * Update a SMTP provider by its unique ID. * @@ -3718,15 +5522,95 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSMTPProvider(providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise; updateSMTPProvider( - paramsOrFirst: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name?: string, + host?: string, + port?: number, + username?: string, + password?: string, + encryption?: SmtpEncryption, + autoTLS?: boolean, + mailer?: string, + fromName?: string, + fromEmail?: string, + replyToName?: string, + replyToEmail?: string, + enabled?: boolean, + ): Promise; + updateSMTPProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + string?, + string?, + SmtpEncryption?, + boolean?, + string?, + string?, + string?, + string?, + string?, + boolean?, + ] ): Promise { - let params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + host?: string; + port?: number; + username?: string; + password?: string; + encryption?: SmtpEncryption; + autoTLS?: boolean; + mailer?: string; + fromName?: string; + fromEmail?: string; + replyToName?: string; + replyToEmail?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3742,10 +5626,10 @@ export class Messaging { fromEmail: rest[9] as string, replyToName: rest[10] as string, replyToEmail: rest[11] as string, - enabled: rest[12] as boolean + enabled: rest[12] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const host = params.host; @@ -3760,66 +5644,64 @@ export class Messaging { const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/smtp/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/smtp/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof host !== 'undefined') { - payload['host'] = host; + apiPayload['host'] = host; } if (typeof port !== 'undefined') { - payload['port'] = port; + apiPayload['port'] = port; } if (typeof username !== 'undefined') { - payload['username'] = username; + apiPayload['username'] = username; } if (typeof password !== 'undefined') { - payload['password'] = password; + apiPayload['password'] = password; } if (typeof encryption !== 'undefined') { - payload['encryption'] = encryption; + apiPayload['encryption'] = encryption; } if (typeof autoTLS !== 'undefined') { - payload['autoTLS'] = autoTLS; + apiPayload['autoTLS'] = autoTLS; } if (typeof mailer !== 'undefined') { - payload['mailer'] = mailer; + apiPayload['mailer'] = mailer; } if (typeof fromName !== 'undefined') { - payload['fromName'] = fromName; + apiPayload['fromName'] = fromName; } if (typeof fromEmail !== 'undefined') { - payload['fromEmail'] = fromEmail; + apiPayload['fromEmail'] = fromEmail; } if (typeof replyToName !== 'undefined') { - payload['replyToName'] = replyToName; + apiPayload['replyToName'] = replyToName; } if (typeof replyToEmail !== 'undefined') { - payload['replyToEmail'] = replyToEmail; + apiPayload['replyToEmail'] = replyToEmail; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3834,7 +5716,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createTelesignProvider(params: { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean }): Promise; + createTelesignProvider(params: { + providerId: string; + name: string; + from?: string; + customerId?: string; + apiKey?: string; + enabled?: boolean; + }): Promise; /** * Create a new Telesign provider. * @@ -3848,15 +5737,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTelesignProvider(providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean): Promise; createTelesignProvider( - paramsOrFirst: { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + from?: string, + customerId?: string, + apiKey?: string, + enabled?: boolean, + ): Promise; + createTelesignProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + from?: string; + customerId?: string; + apiKey?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, string?, boolean?] ): Promise { - let params: { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + from?: string; + customerId?: string; + apiKey?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + from?: string; + customerId?: string; + apiKey?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3864,58 +5787,53 @@ export class Messaging { from: rest[1] as string, customerId: rest[2] as string, apiKey: rest[3] as string, - enabled: rest[4] as boolean + enabled: rest[4] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const from = params.from; const customerId = params.customerId; const apiKey = params.apiKey; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/telesign'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof from !== 'undefined') { - payload['from'] = from; + apiPayload['from'] = from; } if (typeof customerId !== 'undefined') { - payload['customerId'] = customerId; + apiPayload['customerId'] = customerId; } if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + apiPayload['apiKey'] = apiKey; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3930,7 +5848,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateTelesignProvider(params: { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string }): Promise; + updateTelesignProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + customerId?: string; + apiKey?: string; + from?: string; + }): Promise; /** * Update a Telesign provider by its unique ID. * @@ -3944,15 +5869,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTelesignProvider(providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string): Promise; updateTelesignProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + customerId?: string, + apiKey?: string, + from?: string, + ): Promise; + updateTelesignProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + customerId?: string; + apiKey?: string; + from?: string; + } + | string, + ...rest: [string?, boolean?, string?, string?, string?] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + customerId?: string; + apiKey?: string; + from?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + customerId?: string; + apiKey?: string; + from?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -3960,52 +5919,50 @@ export class Messaging { enabled: rest[1] as boolean, customerId: rest[2] as string, apiKey: rest[3] as string, - from: rest[4] as string + from: rest[4] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; const customerId = params.customerId; const apiKey = params.apiKey; const from = params.from; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/telesign/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/telesign/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof customerId !== 'undefined') { - payload['customerId'] = customerId; + apiPayload['customerId'] = customerId; } if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + apiPayload['apiKey'] = apiKey; } if (typeof from !== 'undefined') { - payload['from'] = from; + apiPayload['from'] = from; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4020,7 +5977,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createTextmagicProvider(params: { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean }): Promise; + createTextmagicProvider(params: { + providerId: string; + name: string; + from?: string; + username?: string; + apiKey?: string; + enabled?: boolean; + }): Promise; /** * Create a new Textmagic provider. * @@ -4034,15 +5998,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTextmagicProvider(providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean): Promise; createTextmagicProvider( - paramsOrFirst: { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + from?: string, + username?: string, + apiKey?: string, + enabled?: boolean, + ): Promise; + createTextmagicProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + from?: string; + username?: string; + apiKey?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, string?, boolean?] ): Promise { - let params: { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + from?: string; + username?: string; + apiKey?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + from?: string; + username?: string; + apiKey?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -4050,58 +6048,53 @@ export class Messaging { from: rest[1] as string, username: rest[2] as string, apiKey: rest[3] as string, - enabled: rest[4] as boolean + enabled: rest[4] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const from = params.from; const username = params.username; const apiKey = params.apiKey; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/textmagic'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof from !== 'undefined') { - payload['from'] = from; + apiPayload['from'] = from; } if (typeof username !== 'undefined') { - payload['username'] = username; + apiPayload['username'] = username; } if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + apiPayload['apiKey'] = apiKey; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4116,7 +6109,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateTextmagicProvider(params: { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string }): Promise; + updateTextmagicProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + username?: string; + apiKey?: string; + from?: string; + }): Promise; /** * Update a Textmagic provider by its unique ID. * @@ -4130,15 +6130,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTextmagicProvider(providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string): Promise; updateTextmagicProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + username?: string, + apiKey?: string, + from?: string, + ): Promise; + updateTextmagicProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + username?: string; + apiKey?: string; + from?: string; + } + | string, + ...rest: [string?, boolean?, string?, string?, string?] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + username?: string; + apiKey?: string; + from?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + username?: string; + apiKey?: string; + from?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -4146,52 +6180,50 @@ export class Messaging { enabled: rest[1] as boolean, username: rest[2] as string, apiKey: rest[3] as string, - from: rest[4] as string + from: rest[4] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; const username = params.username; const apiKey = params.apiKey; const from = params.from; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/textmagic/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/textmagic/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof username !== 'undefined') { - payload['username'] = username; + apiPayload['username'] = username; } if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + apiPayload['apiKey'] = apiKey; } if (typeof from !== 'undefined') { - payload['from'] = from; + apiPayload['from'] = from; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4206,7 +6238,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createTwilioProvider(params: { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean }): Promise; + createTwilioProvider(params: { + providerId: string; + name: string; + from?: string; + accountSid?: string; + authToken?: string; + enabled?: boolean; + }): Promise; /** * Create a new Twilio provider. * @@ -4220,15 +6259,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTwilioProvider(providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean): Promise; createTwilioProvider( - paramsOrFirst: { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + from?: string, + accountSid?: string, + authToken?: string, + enabled?: boolean, + ): Promise; + createTwilioProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + from?: string; + accountSid?: string; + authToken?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, string?, boolean?] ): Promise { - let params: { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + from?: string; + accountSid?: string; + authToken?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + from?: string; + accountSid?: string; + authToken?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -4236,58 +6309,53 @@ export class Messaging { from: rest[1] as string, accountSid: rest[2] as string, authToken: rest[3] as string, - enabled: rest[4] as boolean + enabled: rest[4] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const from = params.from; const accountSid = params.accountSid; const authToken = params.authToken; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/twilio'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof from !== 'undefined') { - payload['from'] = from; + apiPayload['from'] = from; } if (typeof accountSid !== 'undefined') { - payload['accountSid'] = accountSid; + apiPayload['accountSid'] = accountSid; } if (typeof authToken !== 'undefined') { - payload['authToken'] = authToken; + apiPayload['authToken'] = authToken; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4302,7 +6370,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateTwilioProvider(params: { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string }): Promise; + updateTwilioProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + accountSid?: string; + authToken?: string; + from?: string; + }): Promise; /** * Update a Twilio provider by its unique ID. * @@ -4316,15 +6391,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTwilioProvider(providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string): Promise; updateTwilioProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + accountSid?: string, + authToken?: string, + from?: string, + ): Promise; + updateTwilioProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + accountSid?: string; + authToken?: string; + from?: string; + } + | string, + ...rest: [string?, boolean?, string?, string?, string?] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + accountSid?: string; + authToken?: string; + from?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + accountSid?: string; + authToken?: string; + from?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -4332,52 +6441,50 @@ export class Messaging { enabled: rest[1] as boolean, accountSid: rest[2] as string, authToken: rest[3] as string, - from: rest[4] as string + from: rest[4] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; const accountSid = params.accountSid; const authToken = params.authToken; const from = params.from; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/twilio/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/twilio/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof accountSid !== 'undefined') { - payload['accountSid'] = accountSid; + apiPayload['accountSid'] = accountSid; } if (typeof authToken !== 'undefined') { - payload['authToken'] = authToken; + apiPayload['authToken'] = authToken; } if (typeof from !== 'undefined') { - payload['from'] = from; + apiPayload['from'] = from; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4392,7 +6499,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createVonageProvider(params: { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean }): Promise; + createVonageProvider(params: { + providerId: string; + name: string; + from?: string; + apiKey?: string; + apiSecret?: string; + enabled?: boolean; + }): Promise; /** * Create a new Vonage provider. * @@ -4406,15 +6520,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVonageProvider(providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean): Promise; createVonageProvider( - paramsOrFirst: { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + providerId: string, + name: string, + from?: string, + apiKey?: string, + apiSecret?: string, + enabled?: boolean, + ): Promise; + createVonageProvider( + paramsOrFirst: + | { + providerId: string; + name: string; + from?: string; + apiKey?: string; + apiSecret?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, string?, boolean?] ): Promise { - let params: { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean }; + let params: { + providerId: string; + name: string; + from?: string; + apiKey?: string; + apiSecret?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name: string; + from?: string; + apiKey?: string; + apiSecret?: string; + enabled?: boolean; + }; } else { params = { providerId: paramsOrFirst as string, @@ -4422,58 +6570,53 @@ export class Messaging { from: rest[1] as string, apiKey: rest[2] as string, apiSecret: rest[3] as string, - enabled: rest[4] as boolean + enabled: rest[4] as boolean, }; } - + const providerId = params.providerId; const name = params.name; const from = params.from; const apiKey = params.apiKey; const apiSecret = params.apiSecret; const enabled = params.enabled; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/providers/vonage'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof from !== 'undefined') { - payload['from'] = from; + apiPayload['from'] = from; } if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + apiPayload['apiKey'] = apiKey; } if (typeof apiSecret !== 'undefined') { - payload['apiSecret'] = apiSecret; + apiPayload['apiSecret'] = apiSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4488,7 +6631,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateVonageProvider(params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string }): Promise; + updateVonageProvider(params: { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + apiSecret?: string; + from?: string; + }): Promise; /** * Update a Vonage provider by its unique ID. * @@ -4502,15 +6652,49 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateVonageProvider(providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string): Promise; updateVonageProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + providerId: string, + name?: string, + enabled?: boolean, + apiKey?: string, + apiSecret?: string, + from?: string, + ): Promise; + updateVonageProvider( + paramsOrFirst: + | { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + apiSecret?: string; + from?: string; + } + | string, + ...rest: [string?, boolean?, string?, string?, string?] ): Promise { - let params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string }; + let params: { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + apiSecret?: string; + from?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + providerId: string; + name?: string; + enabled?: boolean; + apiKey?: string; + apiSecret?: string; + from?: string; + }; } else { params = { providerId: paramsOrFirst as string, @@ -4518,57 +6702,55 @@ export class Messaging { enabled: rest[1] as boolean, apiKey: rest[2] as string, apiSecret: rest[3] as string, - from: rest[4] as string + from: rest[4] as string, }; } - + const providerId = params.providerId; const name = params.name; const enabled = params.enabled; const apiKey = params.apiKey; const apiSecret = params.apiSecret; const from = params.from; - if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/vonage/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/vonage/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + apiPayload['apiKey'] = apiKey; } if (typeof apiSecret !== 'undefined') { - payload['apiSecret'] = apiSecret; + apiPayload['apiSecret'] = apiSecret; } if (typeof from !== 'undefined') { - payload['from'] = from; + apiPayload['from'] = from; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Get a provider by its unique ID. - * + * * * @param {string} params.providerId - Provider ID. * @throws {AppwriteException} @@ -4577,7 +6759,7 @@ export class Messaging { getProvider(params: { providerId: string }): Promise; /** * Get a provider by its unique ID. - * + * * * @param {string} providerId - Provider ID. * @throws {AppwriteException} @@ -4586,39 +6768,41 @@ export class Messaging { */ getProvider(providerId: string): Promise; getProvider( - paramsOrFirst: { providerId: string } | string + paramsOrFirst: { providerId: string } | string, ): Promise { let params: { providerId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { providerId: string }; } else { params = { - providerId: paramsOrFirst as string + providerId: paramsOrFirst as string, }; } - - const providerId = params.providerId; + const providerId = params.providerId; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4639,39 +6823,41 @@ export class Messaging { */ deleteProvider(providerId: string): Promise<{}>; deleteProvider( - paramsOrFirst: { providerId: string } | string + paramsOrFirst: { providerId: string } | string, ): Promise<{}> { let params: { providerId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { providerId: string }; } else { params = { - providerId: paramsOrFirst as string + providerId: paramsOrFirst as string, }; } - - const providerId = params.providerId; + const providerId = params.providerId; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/messaging/providers/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/messaging/providers/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -4683,7 +6869,11 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - listTopics(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listTopics(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all topics from the current Appwrite project. * @@ -4694,52 +6884,59 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTopics(queries?: string[], search?: string, total?: boolean): Promise; listTopics( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listTopics( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - - const apiPath = '/messaging/topics'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4751,7 +6948,11 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createTopic(params: { topicId: string, name: string, subscribe?: string[] }): Promise; + createTopic(params: { + topicId: string; + name: string; + subscribe?: string[]; + }): Promise; /** * Create a new topic. * @@ -4762,64 +6963,72 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTopic(topicId: string, name: string, subscribe?: string[]): Promise; createTopic( - paramsOrFirst: { topicId: string, name: string, subscribe?: string[] } | string, - ...rest: [(string)?, (string[])?] + topicId: string, + name: string, + subscribe?: string[], + ): Promise; + createTopic( + paramsOrFirst: + { topicId: string; name: string; subscribe?: string[] } | string, + ...rest: [string?, string[]?] ): Promise { - let params: { topicId: string, name: string, subscribe?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { topicId: string, name: string, subscribe?: string[] }; + let params: { topicId: string; name: string; subscribe?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + topicId: string; + name: string; + subscribe?: string[]; + }; } else { params = { topicId: paramsOrFirst as string, name: rest[0] as string, - subscribe: rest[1] as string[] + subscribe: rest[1] as string[], }; } - + const topicId = params.topicId; const name = params.name; const subscribe = params.subscribe; - if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/messaging/topics'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof topicId !== 'undefined') { - payload['topicId'] = topicId; + apiPayload['topicId'] = topicId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof subscribe !== 'undefined') { - payload['subscribe'] = subscribe; + apiPayload['subscribe'] = subscribe; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Get a topic by its unique ID. - * + * * * @param {string} params.topicId - Topic ID. * @throws {AppwriteException} @@ -4828,7 +7037,7 @@ export class Messaging { getTopic(params: { topicId: string }): Promise; /** * Get a topic by its unique ID. - * + * * * @param {string} topicId - Topic ID. * @throws {AppwriteException} @@ -4837,44 +7046,46 @@ export class Messaging { */ getTopic(topicId: string): Promise; getTopic( - paramsOrFirst: { topicId: string } | string + paramsOrFirst: { topicId: string } | string, ): Promise { let params: { topicId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { topicId: string }; } else { params = { - topicId: paramsOrFirst as string + topicId: paramsOrFirst as string, }; } - - const topicId = params.topicId; + const topicId = params.topicId; if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); } - - const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', encodeURIComponent(String(topicId))); - const payload: Payload = {}; + const apiPath = '/messaging/topics/{topicId}'.replace( + '{topicId}', + encodeURIComponent(String(topicId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Update a topic by its unique ID. - * + * * * @param {string} params.topicId - Topic ID. * @param {string} params.name - Topic Name. @@ -4882,10 +7093,14 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - updateTopic(params: { topicId: string, name?: string, subscribe?: string[] }): Promise; + updateTopic(params: { + topicId: string; + name?: string; + subscribe?: string[]; + }): Promise; /** * Update a topic by its unique ID. - * + * * * @param {string} topicId - Topic ID. * @param {string} name - Topic Name. @@ -4894,53 +7109,64 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTopic(topicId: string, name?: string, subscribe?: string[]): Promise; updateTopic( - paramsOrFirst: { topicId: string, name?: string, subscribe?: string[] } | string, - ...rest: [(string)?, (string[])?] + topicId: string, + name?: string, + subscribe?: string[], + ): Promise; + updateTopic( + paramsOrFirst: + { topicId: string; name?: string; subscribe?: string[] } | string, + ...rest: [string?, string[]?] ): Promise { - let params: { topicId: string, name?: string, subscribe?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { topicId: string, name?: string, subscribe?: string[] }; + let params: { topicId: string; name?: string; subscribe?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + topicId: string; + name?: string; + subscribe?: string[]; + }; } else { params = { topicId: paramsOrFirst as string, name: rest[0] as string, - subscribe: rest[1] as string[] + subscribe: rest[1] as string[], }; } - + const topicId = params.topicId; const name = params.name; const subscribe = params.subscribe; - if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); } - - const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', encodeURIComponent(String(topicId))); - const payload: Payload = {}; + const apiPath = '/messaging/topics/{topicId}'.replace( + '{topicId}', + encodeURIComponent(String(topicId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof subscribe !== 'undefined') { - payload['subscribe'] = subscribe; + apiPayload['subscribe'] = subscribe; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4960,40 +7186,40 @@ export class Messaging { * @deprecated Use the object parameter style method for a better developer experience. */ deleteTopic(topicId: string): Promise<{}>; - deleteTopic( - paramsOrFirst: { topicId: string } | string - ): Promise<{}> { + deleteTopic(paramsOrFirst: { topicId: string } | string): Promise<{}> { let params: { topicId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { topicId: string }; } else { params = { - topicId: paramsOrFirst as string + topicId: paramsOrFirst as string, }; } - - const topicId = params.topicId; + const topicId = params.topicId; if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); } - - const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', encodeURIComponent(String(topicId))); - const payload: Payload = {}; + const apiPath = '/messaging/topics/{topicId}'.replace( + '{topicId}', + encodeURIComponent(String(topicId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -5006,7 +7232,12 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - listSubscribers(params: { topicId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listSubscribers(params: { + topicId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all subscribers from the current Appwrite project. * @@ -5018,57 +7249,81 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listSubscribers(topicId: string, queries?: string[], search?: string, total?: boolean): Promise; listSubscribers( - paramsOrFirst: { topicId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + topicId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listSubscribers( + paramsOrFirst: + | { + topicId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { topicId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { topicId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + topicId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + topicId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { topicId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const topicId = params.topicId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); } - - const apiPath = '/messaging/topics/{topicId}/subscribers'.replace('{topicId}', encodeURIComponent(String(topicId))); - const payload: Payload = {}; + const apiPath = '/messaging/topics/{topicId}/subscribers'.replace( + '{topicId}', + encodeURIComponent(String(topicId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -5080,7 +7335,11 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise} */ - createSubscriber(params: { topicId: string, subscriberId: string, targetId: string }): Promise; + createSubscriber(params: { + topicId: string; + subscriberId: string; + targetId: string; + }): Promise; /** * Create a new subscriber. * @@ -5091,74 +7350,93 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSubscriber(topicId: string, subscriberId: string, targetId: string): Promise; createSubscriber( - paramsOrFirst: { topicId: string, subscriberId: string, targetId: string } | string, - ...rest: [(string)?, (string)?] + topicId: string, + subscriberId: string, + targetId: string, + ): Promise; + createSubscriber( + paramsOrFirst: + | { topicId: string; subscriberId: string; targetId: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { topicId: string, subscriberId: string, targetId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { topicId: string, subscriberId: string, targetId: string }; + let params: { topicId: string; subscriberId: string; targetId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + topicId: string; + subscriberId: string; + targetId: string; + }; } else { params = { topicId: paramsOrFirst as string, subscriberId: rest[0] as string, - targetId: rest[1] as string + targetId: rest[1] as string, }; } - + const topicId = params.topicId; const subscriberId = params.subscriberId; const targetId = params.targetId; - if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); } if (typeof subscriberId === 'undefined') { - throw new AppwriteException('Missing required parameter: "subscriberId"'); + throw new AppwriteException( + 'Missing required parameter: "subscriberId"', + ); } if (typeof targetId === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetId"'); + throw new AppwriteException( + 'Missing required parameter: "targetId"', + ); } - - const apiPath = '/messaging/topics/{topicId}/subscribers'.replace('{topicId}', encodeURIComponent(String(topicId))); - const payload: Payload = {}; + const apiPath = '/messaging/topics/{topicId}/subscribers'.replace( + '{topicId}', + encodeURIComponent(String(topicId)), + ); + const apiPayload: Payload = {}; if (typeof subscriberId !== 'undefined') { - payload['subscriberId'] = subscriberId; + apiPayload['subscriberId'] = subscriberId; } if (typeof targetId !== 'undefined') { - payload['targetId'] = targetId; + apiPayload['targetId'] = targetId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Get a subscriber by its unique ID. - * + * * * @param {string} params.topicId - Topic ID. The topic ID subscribed to. * @param {string} params.subscriberId - Subscriber ID. * @throws {AppwriteException} * @returns {Promise} */ - getSubscriber(params: { topicId: string, subscriberId: string }): Promise; + getSubscriber(params: { + topicId: string; + subscriberId: string; + }): Promise; /** * Get a subscriber by its unique ID. - * + * * * @param {string} topicId - Topic ID. The topic ID subscribed to. * @param {string} subscriberId - Subscriber ID. @@ -5166,47 +7444,59 @@ export class Messaging { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getSubscriber(topicId: string, subscriberId: string): Promise; getSubscriber( - paramsOrFirst: { topicId: string, subscriberId: string } | string, - ...rest: [(string)?] + topicId: string, + subscriberId: string, + ): Promise; + getSubscriber( + paramsOrFirst: { topicId: string; subscriberId: string } | string, + ...rest: [string?] ): Promise { - let params: { topicId: string, subscriberId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { topicId: string, subscriberId: string }; + let params: { topicId: string; subscriberId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + topicId: string; + subscriberId: string; + }; } else { params = { topicId: paramsOrFirst as string, - subscriberId: rest[0] as string + subscriberId: rest[0] as string, }; } - + const topicId = params.topicId; const subscriberId = params.subscriberId; - if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); } if (typeof subscriberId === 'undefined') { - throw new AppwriteException('Missing required parameter: "subscriberId"'); - } - - const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replace('{topicId}', encodeURIComponent(String(topicId))).replace('{subscriberId}', encodeURIComponent(String(subscriberId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "subscriberId"', + ); + } + const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .replace('{topicId}', encodeURIComponent(String(topicId))) + .replace( + '{subscriberId}', + encodeURIComponent(String(subscriberId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -5217,7 +7507,10 @@ export class Messaging { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteSubscriber(params: { topicId: string, subscriberId: string }): Promise<{}>; + deleteSubscriber(params: { + topicId: string; + subscriberId: string; + }): Promise<{}>; /** * Delete a subscriber by its unique ID. * @@ -5229,44 +7522,53 @@ export class Messaging { */ deleteSubscriber(topicId: string, subscriberId: string): Promise<{}>; deleteSubscriber( - paramsOrFirst: { topicId: string, subscriberId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { topicId: string; subscriberId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { topicId: string, subscriberId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { topicId: string, subscriberId: string }; + let params: { topicId: string; subscriberId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + topicId: string; + subscriberId: string; + }; } else { params = { topicId: paramsOrFirst as string, - subscriberId: rest[0] as string + subscriberId: rest[0] as string, }; } - + const topicId = params.topicId; const subscriberId = params.subscriberId; - if (typeof topicId === 'undefined') { - throw new AppwriteException('Missing required parameter: "topicId"'); + throw new AppwriteException( + 'Missing required parameter: "topicId"', + ); } if (typeof subscriberId === 'undefined') { - throw new AppwriteException('Missing required parameter: "subscriberId"'); - } - - const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replace('{topicId}', encodeURIComponent(String(topicId))).replace('{subscriberId}', encodeURIComponent(String(subscriberId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "subscriberId"', + ); + } + const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .replace('{topicId}', encodeURIComponent(String(topicId))) + .replace( + '{subscriberId}', + encodeURIComponent(String(subscriberId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } } diff --git a/src/services/mongo.ts b/src/services/mongo.ts new file mode 100644 index 00000000..ad151b21 --- /dev/null +++ b/src/services/mongo.ts @@ -0,0 +1,2926 @@ +import { AppwriteException, Client, type Payload } from '../client'; +import type { Models } from '../models'; + +export class Mongo { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List all dedicated databases. Results support pagination. + * + * @param {string[]} params.queries - Array of query strings. + * @throws {AppwriteException} + * @returns {Promise} + */ + list(params?: { + queries?: string[]; + }): Promise; + /** + * List all dedicated databases. Results support pagination. + * + * @param {string[]} queries - Array of query strings. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(queries?: string[]): Promise; + list( + paramsOrFirst?: { queries?: string[] } | string[], + ): Promise { + let params: { queries?: string[] }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[], + }; + } + + const queries = params.queries; + const apiPath = '/mongo'; + 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 dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. + * + * @param {string} params.databaseId - Database 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 - Database display name. Max length: 128 chars. + * @param {string} params.version - Database engine version. Defaults to latest for selected engine. + * @param {string} params.specification - Specification identifier. Drives the allocated CPU, memory, storage, storage class, and connection ceiling. + * @param {number} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds. + * @param {string[]} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number} params.idleTimeoutMinutes - Minutes of inactivity before container scales to zero. + * @param {boolean} params.pitr - Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. + * @param {number} params.pitrRetentionDays - Number of days to retain PITR data. + * @param {boolean} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @throws {AppwriteException} + * @returns {Promise} + */ + create(params: { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }): Promise; + /** + * Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. + * + * @param {string} databaseId - Database 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 - Database display name. Max length: 128 chars. + * @param {string} version - Database engine version. Defaults to latest for selected engine. + * @param {string} specification - Specification identifier. Drives the allocated CPU, memory, storage, storage class, and connection ceiling. + * @param {number} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number} networkIdleTimeoutSeconds - Connection idle timeout in seconds. + * @param {string[]} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number} idleTimeoutMinutes - Minutes of inactivity before container scales to zero. + * @param {boolean} pitr - Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. + * @param {number} pitrRetentionDays - Number of days to retain PITR data. + * @param {boolean} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create( + databaseId: string, + name: string, + version?: string, + specification?: string, + replicas?: number, + syncMode?: string, + networkIdleTimeoutSeconds?: number, + networkIPAllowlist?: string[], + idleTimeoutMinutes?: number, + pitr?: boolean, + pitrRetentionDays?: number, + storageAutoscaling?: boolean, + storageAutoscalingThresholdPercent?: number, + storageAutoscalingMaxGb?: number, + ): Promise; + create( + paramsOrFirst: + | { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + string?, + number?, + string[]?, + number?, + boolean?, + number?, + boolean?, + number?, + number?, + ] + ): Promise { + let params: { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + version: rest[1] as string, + specification: rest[2] as string, + replicas: rest[3] as number, + syncMode: rest[4] as string, + networkIdleTimeoutSeconds: rest[5] as number, + networkIPAllowlist: rest[6] as string[], + idleTimeoutMinutes: rest[7] as number, + pitr: rest[8] as boolean, + pitrRetentionDays: rest[9] as number, + storageAutoscaling: rest[10] as boolean, + storageAutoscalingThresholdPercent: rest[11] as number, + storageAutoscalingMaxGb: rest[12] as number, + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const version = params.version; + const specification = params.specification; + const replicas = params.replicas; + const syncMode = params.syncMode; + const networkIdleTimeoutSeconds = params.networkIdleTimeoutSeconds; + const networkIPAllowlist = params.networkIPAllowlist; + const idleTimeoutMinutes = params.idleTimeoutMinutes; + const pitr = params.pitr; + const pitrRetentionDays = params.pitrRetentionDays; + const storageAutoscaling = params.storageAutoscaling; + const storageAutoscalingThresholdPercent = + params.storageAutoscalingThresholdPercent; + const storageAutoscalingMaxGb = params.storageAutoscalingMaxGb; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/mongo'; + const apiPayload: Payload = {}; + if (typeof databaseId !== 'undefined') { + apiPayload['databaseId'] = databaseId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof version !== 'undefined') { + apiPayload['version'] = version; + } + if (typeof specification !== 'undefined') { + apiPayload['specification'] = specification; + } + if (typeof replicas !== 'undefined') { + apiPayload['replicas'] = replicas; + } + if (typeof syncMode !== 'undefined') { + apiPayload['syncMode'] = syncMode; + } + if (typeof networkIdleTimeoutSeconds !== 'undefined') { + apiPayload['networkIdleTimeoutSeconds'] = networkIdleTimeoutSeconds; + } + if (typeof networkIPAllowlist !== 'undefined') { + apiPayload['networkIPAllowlist'] = networkIPAllowlist; + } + if (typeof idleTimeoutMinutes !== 'undefined') { + apiPayload['idleTimeoutMinutes'] = idleTimeoutMinutes; + } + if (typeof pitr !== 'undefined') { + apiPayload['pitr'] = pitr; + } + if (typeof pitrRetentionDays !== 'undefined') { + apiPayload['pitrRetentionDays'] = pitrRetentionDays; + } + if (typeof storageAutoscaling !== 'undefined') { + apiPayload['storageAutoscaling'] = storageAutoscaling; + } + if (typeof storageAutoscalingThresholdPercent !== 'undefined') { + apiPayload['storageAutoscalingThresholdPercent'] = + storageAutoscalingThresholdPercent; + } + if (typeof storageAutoscalingMaxGb !== 'undefined') { + apiPayload['storageAutoscalingMaxGb'] = storageAutoscalingMaxGb; + } + 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 the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + listSpecifications(): Promise { + const apiPath = '/mongo/specifications'; + 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); + } + + /** + * Get a dedicated database by its unique ID. Returns the database configuration and current status. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + get(params: { databaseId: string }): Promise; + /** + * Get a dedicated database by its unique ID. Returns the database configuration and current status. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(databaseId: string): Promise; + get( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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 dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.name - Database display name. + * @param {string} params.status - Database status. Allowed values: ready, paused, inactive. Set to "paused" to pause, "ready" to resume (also recovers a failed database whose infrastructure is healthy), or "inactive" to spin down a shared-pool database. + * @param {string} params.specification - Specification. Changes cpu, memory, storage, connection ceiling, and node pool based on specification config. Resource changes are applied via rolling cutover with zero downtime. + * @param {number} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[]} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[]} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). + * @throws {AppwriteException} + * @returns {Promise} + */ + update(params: { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }): Promise; + /** + * Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. + * + * @param {string} databaseId - Database ID. + * @param {string} name - Database display name. + * @param {string} status - Database status. Allowed values: ready, paused, inactive. Set to "paused" to pause, "ready" to resume (also recovers a failed database whose infrastructure is healthy), or "inactive" to spin down a shared-pool database. + * @param {string} specification - Specification. Changes cpu, memory, storage, connection ceiling, and node pool based on specification config. Resource changes are applied via rolling cutover with zero downtime. + * @param {number} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[]} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number} pitrRetentionDays - Days to retain PITR data. + * @param {boolean} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[]} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update( + databaseId: string, + name?: string, + status?: string, + specification?: string, + replicas?: number, + syncMode?: string, + networkIdleTimeoutSeconds?: number, + networkIPAllowlist?: string[], + idleTimeoutMinutes?: number, + pitr?: boolean, + pitrRetentionDays?: number, + storageAutoscaling?: boolean, + storageAutoscalingThresholdPercent?: number, + storageAutoscalingMaxGb?: number, + metricsTraceSampleRate?: number, + metricsSlowQueryLogThresholdMs?: number, + sqlApiEnabled?: boolean, + sqlApiAllowedStatements?: string[], + sqlApiMaxRows?: number, + sqlApiMaxBytes?: number, + sqlApiTimeoutSeconds?: number, + ): Promise; + update( + paramsOrFirst: + | { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + string?, + number?, + string[]?, + number?, + boolean?, + number?, + boolean?, + number?, + number?, + number?, + number?, + boolean?, + string[]?, + number?, + number?, + number?, + ] + ): Promise { + let params: { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + status: rest[1] as string, + specification: rest[2] as string, + replicas: rest[3] as number, + syncMode: rest[4] as string, + networkIdleTimeoutSeconds: rest[5] as number, + networkIPAllowlist: rest[6] as string[], + idleTimeoutMinutes: rest[7] as number, + pitr: rest[8] as boolean, + pitrRetentionDays: rest[9] as number, + storageAutoscaling: rest[10] as boolean, + storageAutoscalingThresholdPercent: rest[11] as number, + storageAutoscalingMaxGb: rest[12] as number, + metricsTraceSampleRate: rest[13] as number, + metricsSlowQueryLogThresholdMs: rest[14] as number, + sqlApiEnabled: rest[15] as boolean, + sqlApiAllowedStatements: rest[16] as string[], + sqlApiMaxRows: rest[17] as number, + sqlApiMaxBytes: rest[18] as number, + sqlApiTimeoutSeconds: rest[19] as number, + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const status = params.status; + const specification = params.specification; + const replicas = params.replicas; + const syncMode = params.syncMode; + const networkIdleTimeoutSeconds = params.networkIdleTimeoutSeconds; + const networkIPAllowlist = params.networkIPAllowlist; + const idleTimeoutMinutes = params.idleTimeoutMinutes; + const pitr = params.pitr; + const pitrRetentionDays = params.pitrRetentionDays; + const storageAutoscaling = params.storageAutoscaling; + const storageAutoscalingThresholdPercent = + params.storageAutoscalingThresholdPercent; + const storageAutoscalingMaxGb = params.storageAutoscalingMaxGb; + const metricsTraceSampleRate = params.metricsTraceSampleRate; + const metricsSlowQueryLogThresholdMs = + params.metricsSlowQueryLogThresholdMs; + const sqlApiEnabled = params.sqlApiEnabled; + const sqlApiAllowedStatements = params.sqlApiAllowedStatements; + const sqlApiMaxRows = params.sqlApiMaxRows; + const sqlApiMaxBytes = params.sqlApiMaxBytes; + const sqlApiTimeoutSeconds = params.sqlApiTimeoutSeconds; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof status !== 'undefined') { + apiPayload['status'] = status; + } + if (typeof specification !== 'undefined') { + apiPayload['specification'] = specification; + } + if (typeof replicas !== 'undefined') { + apiPayload['replicas'] = replicas; + } + if (typeof syncMode !== 'undefined') { + apiPayload['syncMode'] = syncMode; + } + if (typeof networkIdleTimeoutSeconds !== 'undefined') { + apiPayload['networkIdleTimeoutSeconds'] = networkIdleTimeoutSeconds; + } + if (typeof networkIPAllowlist !== 'undefined') { + apiPayload['networkIPAllowlist'] = networkIPAllowlist; + } + if (typeof idleTimeoutMinutes !== 'undefined') { + apiPayload['idleTimeoutMinutes'] = idleTimeoutMinutes; + } + if (typeof pitr !== 'undefined') { + apiPayload['pitr'] = pitr; + } + if (typeof pitrRetentionDays !== 'undefined') { + apiPayload['pitrRetentionDays'] = pitrRetentionDays; + } + if (typeof storageAutoscaling !== 'undefined') { + apiPayload['storageAutoscaling'] = storageAutoscaling; + } + if (typeof storageAutoscalingThresholdPercent !== 'undefined') { + apiPayload['storageAutoscalingThresholdPercent'] = + storageAutoscalingThresholdPercent; + } + if (typeof storageAutoscalingMaxGb !== 'undefined') { + apiPayload['storageAutoscalingMaxGb'] = storageAutoscalingMaxGb; + } + if (typeof metricsTraceSampleRate !== 'undefined') { + apiPayload['metricsTraceSampleRate'] = metricsTraceSampleRate; + } + if (typeof metricsSlowQueryLogThresholdMs !== 'undefined') { + apiPayload['metricsSlowQueryLogThresholdMs'] = + metricsSlowQueryLogThresholdMs; + } + if (typeof sqlApiEnabled !== 'undefined') { + apiPayload['sqlApiEnabled'] = sqlApiEnabled; + } + if (typeof sqlApiAllowedStatements !== 'undefined') { + apiPayload['sqlApiAllowedStatements'] = sqlApiAllowedStatements; + } + if (typeof sqlApiMaxRows !== 'undefined') { + apiPayload['sqlApiMaxRows'] = sqlApiMaxRows; + } + if (typeof sqlApiMaxBytes !== 'undefined') { + apiPayload['sqlApiMaxBytes'] = sqlApiMaxBytes; + } + if (typeof sqlApiTimeoutSeconds !== 'undefined') { + apiPayload['sqlApiTimeoutSeconds'] = sqlApiTimeoutSeconds; + } + 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 a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { databaseId: string }): Promise<{}>; + /** + * Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(databaseId: string): Promise<{}>; + delete(paramsOrFirst: { databaseId: string } | string): Promise<{}> { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * List all backups for a dedicated database. Results can be filtered by status and type. + * + * @param {string} params.databaseId - Database 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: status, type, databaseId + * @throws {AppwriteException} + * @returns {Promise} + */ + listBackups(params: { + databaseId: string; + queries?: string[]; + }): Promise; + /** + * List all backups for a dedicated database. Results can be filtered by status and type. + * + * @param {string} databaseId - Database 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: status, type, databaseId + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listBackups( + databaseId: string, + queries?: string[], + ): Promise; + listBackups( + paramsOrFirst: { databaseId: string; queries?: string[] } | string, + ...rest: [string[]?] + ): Promise { + let params: { databaseId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + queries: rest[0] as string[], + }; + } + + const databaseId = params.databaseId; + const queries = params.queries; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}/backups'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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 manual backup of a dedicated database. The backup will be created asynchronously and its status can be checked via the get backup endpoint. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.type - Backup type: full or incremental. + * @throws {AppwriteException} + * @returns {Promise} + */ + createBackup(params: { + databaseId: string; + type?: string; + }): Promise; + /** + * Create a manual backup of a dedicated database. The backup will be created asynchronously and its status can be checked via the get backup endpoint. + * + * @param {string} databaseId - Database ID. + * @param {string} type - Backup type: full or incremental. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBackup( + databaseId: string, + type?: string, + ): Promise; + createBackup( + paramsOrFirst: { databaseId: string; type?: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; type?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + type?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + type: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const type = params.type; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}/backups'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof type !== 'undefined') { + apiPayload['type'] = type; + } + 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 scheduled backup policies for a dedicated database. + * + * @param {string} params.databaseId - Database ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. + * @throws {AppwriteException} + * @returns {Promise} + */ + listBackupPolicies(params: { + databaseId: string; + queries?: string[]; + }): Promise; + /** + * List scheduled backup policies for a dedicated database. + * + * @param {string} databaseId - Database ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listBackupPolicies( + databaseId: string, + queries?: string[], + ): Promise; + listBackupPolicies( + paramsOrFirst: { databaseId: string; queries?: string[] } | string, + ...rest: [string[]?] + ): Promise { + let params: { databaseId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + queries: rest[0] as string[], + }; + } + + const databaseId = params.databaseId; + const queries = params.queries; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}/backups/policies'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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 scheduled backup policy for a dedicated database. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.policyId - Policy 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 - Policy name. Max length: 128 chars. + * @param {string} params.schedule - Schedule CRON syntax. + * @param {number} params.retention - Days to keep backups before deletion. + * @param {string} params.type - Backup type: full or incremental. + * @param {boolean} params.enabled - Is policy enabled? When disabled, no backups will be taken. + * @throws {AppwriteException} + * @returns {Promise} + */ + createBackupPolicy(params: { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }): Promise; + /** + * Create a scheduled backup policy for a dedicated database. + * + * @param {string} databaseId - Database ID. + * @param {string} policyId - Policy 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 - Policy name. Max length: 128 chars. + * @param {string} schedule - Schedule CRON syntax. + * @param {number} retention - Days to keep backups before deletion. + * @param {string} type - Backup type: full or incremental. + * @param {boolean} enabled - Is policy enabled? When disabled, no backups will be taken. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBackupPolicy( + databaseId: string, + policyId: string, + name: string, + schedule: string, + retention: number, + type?: string, + enabled?: boolean, + ): Promise; + createBackupPolicy( + paramsOrFirst: + | { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, number?, string?, boolean?] + ): Promise { + let params: { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + policyId: rest[0] as string, + name: rest[1] as string, + schedule: rest[2] as string, + retention: rest[3] as number, + type: rest[4] as string, + enabled: rest[5] as boolean, + }; + } + + const databaseId = params.databaseId; + const policyId = params.policyId; + const name = params.name; + const schedule = params.schedule; + const retention = params.retention; + const type = params.type; + const enabled = params.enabled; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof policyId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof schedule === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "schedule"', + ); + } + if (typeof retention === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "retention"', + ); + } + const apiPath = '/mongo/{databaseId}/backups/policies'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof policyId !== 'undefined') { + apiPayload['policyId'] = policyId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof schedule !== 'undefined') { + apiPayload['schedule'] = schedule; + } + if (typeof retention !== 'undefined') { + apiPayload['retention'] = retention; + } + if (typeof type !== 'undefined') { + apiPayload['type'] = type; + } + 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('post', uri, apiHeaders, apiPayload); + } + + /** + * Get a scheduled backup policy for a dedicated database. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.policyId - Policy ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getBackupPolicy(params: { + databaseId: string; + policyId: string; + }): Promise; + /** + * Get a scheduled backup policy for a dedicated database. + * + * @param {string} databaseId - Database ID. + * @param {string} policyId - Policy ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getBackupPolicy( + databaseId: string, + policyId: string, + ): Promise; + getBackupPolicy( + paramsOrFirst: { databaseId: string; policyId: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; policyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + policyId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const policyId = params.policyId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof policyId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); + } + const apiPath = '/mongo/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); + 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 scheduled backup policy for a dedicated database. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.policyId - Policy ID. + * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string} params.schedule - Schedule CRON syntax. + * @param {number} params.retention - Days to keep backups before deletion. + * @param {boolean} params.enabled - Is policy enabled? When disabled, no backups will be taken. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateBackupPolicy(params: { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }): Promise; + /** + * Update a scheduled backup policy for a dedicated database. + * + * @param {string} databaseId - Database ID. + * @param {string} policyId - Policy ID. + * @param {string} name - Policy name. Max length: 128 chars. + * @param {string} schedule - Schedule CRON syntax. + * @param {number} retention - Days to keep backups before deletion. + * @param {boolean} enabled - Is policy enabled? When disabled, no backups will be taken. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBackupPolicy( + databaseId: string, + policyId: string, + name?: string, + schedule?: string, + retention?: number, + enabled?: boolean, + ): Promise; + updateBackupPolicy( + paramsOrFirst: + | { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, number?, boolean?] + ): Promise { + let params: { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + policyId: rest[0] as string, + name: rest[1] as string, + schedule: rest[2] as string, + retention: rest[3] as number, + enabled: rest[4] as boolean, + }; + } + + const databaseId = params.databaseId; + const policyId = params.policyId; + const name = params.name; + const schedule = params.schedule; + const retention = params.retention; + const enabled = params.enabled; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof policyId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); + } + const apiPath = '/mongo/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof schedule !== 'undefined') { + apiPayload['schedule'] = schedule; + } + if (typeof retention !== 'undefined') { + apiPayload['retention'] = retention; + } + 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); + } + + /** + * Delete a scheduled backup policy for a dedicated database. Backups already taken by the policy are kept until their retention expires. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.policyId - Policy ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteBackupPolicy(params: { + databaseId: string; + policyId: string; + }): Promise<{}>; + /** + * Delete a scheduled backup policy for a dedicated database. Backups already taken by the policy are kept until their retention expires. + * + * @param {string} databaseId - Database ID. + * @param {string} policyId - Policy ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteBackupPolicy(databaseId: string, policyId: string): Promise<{}>; + deleteBackupPolicy( + paramsOrFirst: { databaseId: string; policyId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { databaseId: string; policyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + policyId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const policyId = params.policyId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof policyId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); + } + const apiPath = '/mongo/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); + 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); + } + + /** + * Configure off-cluster backup storage for a dedicated database. Supports S3, GCS, and Azure Blob Storage destinations. Backups will be stored to the configured destination in addition to on-cluster storage. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.provider - Storage provider for off-cluster backups. Allowed values: s3 (Amazon S3 or S3-compatible), gcs (Google Cloud Storage), azure (Azure Blob Storage). + * @param {string} params.bucket - Storage bucket or container name. + * @param {string} params.accessKey - Access key or client ID for authentication. + * @param {string} params.secretKey - Secret key or service account JSON for authentication. + * @param {string} params.region - Storage region. + * @param {string} params.prefix - Object key prefix for backups. + * @param {string} params.endpoint - Custom endpoint for S3-compatible storage (e.g. MinIO). + * @throws {AppwriteException} + * @returns {Promise} + */ + updateBackupStorage(params: { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }): Promise; + /** + * Configure off-cluster backup storage for a dedicated database. Supports S3, GCS, and Azure Blob Storage destinations. Backups will be stored to the configured destination in addition to on-cluster storage. + * + * @param {string} databaseId - Database ID. + * @param {string} provider - Storage provider for off-cluster backups. Allowed values: s3 (Amazon S3 or S3-compatible), gcs (Google Cloud Storage), azure (Azure Blob Storage). + * @param {string} bucket - Storage bucket or container name. + * @param {string} accessKey - Access key or client ID for authentication. + * @param {string} secretKey - Secret key or service account JSON for authentication. + * @param {string} region - Storage region. + * @param {string} prefix - Object key prefix for backups. + * @param {string} endpoint - Custom endpoint for S3-compatible storage (e.g. MinIO). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBackupStorage( + databaseId: string, + provider: string, + bucket: string, + accessKey: string, + secretKey: string, + region?: string, + prefix?: string, + endpoint?: string, + ): Promise; + updateBackupStorage( + paramsOrFirst: + | { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + } + | string, + ...rest: [string?, string?, string?, string?, string?, string?, string?] + ): Promise { + let params: { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + provider: rest[0] as string, + bucket: rest[1] as string, + accessKey: rest[2] as string, + secretKey: rest[3] as string, + region: rest[4] as string, + prefix: rest[5] as string, + endpoint: rest[6] as string, + }; + } + + const databaseId = params.databaseId; + const provider = params.provider; + const bucket = params.bucket; + const accessKey = params.accessKey; + const secretKey = params.secretKey; + const region = params.region; + const prefix = params.prefix; + const endpoint = params.endpoint; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof provider === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "provider"', + ); + } + if (typeof bucket === 'undefined') { + throw new AppwriteException('Missing required parameter: "bucket"'); + } + if (typeof accessKey === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "accessKey"', + ); + } + if (typeof secretKey === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "secretKey"', + ); + } + const apiPath = '/mongo/{databaseId}/backups/storage'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof provider !== 'undefined') { + apiPayload['provider'] = provider; + } + if (typeof bucket !== 'undefined') { + apiPayload['bucket'] = bucket; + } + if (typeof region !== 'undefined') { + apiPayload['region'] = region; + } + if (typeof prefix !== 'undefined') { + apiPayload['prefix'] = prefix; + } + if (typeof endpoint !== 'undefined') { + apiPayload['endpoint'] = endpoint; + } + if (typeof accessKey !== 'undefined') { + apiPayload['accessKey'] = accessKey; + } + if (typeof secretKey !== 'undefined') { + apiPayload['secretKey'] = secretKey; + } + 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 details of a specific database backup including its status, size, and timestamps. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.backupId - Backup ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getBackup(params: { + databaseId: string; + backupId: string; + }): Promise; + /** + * Get details of a specific database backup including its status, size, and timestamps. + * + * @param {string} databaseId - Database ID. + * @param {string} backupId - Backup ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getBackup( + databaseId: string, + backupId: string, + ): Promise; + getBackup( + paramsOrFirst: { databaseId: string; backupId: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; backupId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + backupId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + backupId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const backupId = params.backupId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof backupId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "backupId"', + ); + } + const apiPath = '/mongo/{databaseId}/backups/{backupId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{backupId}', encodeURIComponent(String(backupId))); + 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 database backup. This will permanently remove the backup from storage and cannot be undone. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.backupId - Backup ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteBackup(params: { databaseId: string; backupId: string }): Promise<{}>; + /** + * Delete a database backup. This will permanently remove the backup from storage and cannot be undone. + * + * @param {string} databaseId - Database ID. + * @param {string} backupId - Backup ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteBackup(databaseId: string, backupId: string): Promise<{}>; + deleteBackup( + paramsOrFirst: { databaseId: string; backupId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { databaseId: string; backupId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + backupId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + backupId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const backupId = params.backupId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof backupId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "backupId"', + ); + } + const apiPath = '/mongo/{databaseId}/backups/{backupId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{backupId}', encodeURIComponent(String(backupId))); + 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); + } + + /** + * List all ephemeral branches for a dedicated database. Returns branch metadata including ID, name, namespace, and expiration time. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + listBranches(params: { + databaseId: string; + }): Promise; + /** + * List all ephemeral branches for a dedicated database. Returns branch metadata including ID, name, namespace, and expiration time. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listBranches( + databaseId: string, + ): Promise; + listBranches( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}/branches'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.branchId - Branch 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 {number} params.ttl - Time-to-live in seconds before the branch expires. Min 300 (5 min), max 604800 (7 days). Default: 86400 (24h). + * @throws {AppwriteException} + * @returns {Promise} + */ + createBranch(params: { + databaseId: string; + branchId?: string; + ttl?: number; + }): Promise; + /** + * Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. + * + * @param {string} databaseId - Database ID. + * @param {string} branchId - Branch 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 {number} ttl - Time-to-live in seconds before the branch expires. Min 300 (5 min), max 604800 (7 days). Default: 86400 (24h). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBranch( + databaseId: string, + branchId?: string, + ttl?: number, + ): Promise; + createBranch( + paramsOrFirst: + { databaseId: string; branchId?: string; ttl?: number } | string, + ...rest: [string?, number?] + ): Promise { + let params: { databaseId: string; branchId?: string; ttl?: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + branchId?: string; + ttl?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + branchId: rest[0] as string, + ttl: rest[1] as number, + }; + } + + const databaseId = params.databaseId; + const branchId = params.branchId; + const ttl = params.ttl; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}/branches'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof branchId !== 'undefined') { + apiPayload['branchId'] = branchId; + } + 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); + } + + /** + * Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.branchId - Branch ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteBranch(params: { + databaseId: string; + branchId: string; + }): Promise; + /** + * Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. + * + * @param {string} databaseId - Database ID. + * @param {string} branchId - Branch ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteBranch( + databaseId: string, + branchId: string, + ): Promise; + deleteBranch( + paramsOrFirst: { databaseId: string; branchId: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; branchId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + branchId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + branchId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const branchId = params.branchId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof branchId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "branchId"', + ); + } + const apiPath = '/mongo/{databaseId}/branches/{branchId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{branchId}', encodeURIComponent(String(branchId))); + 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); + } + + /** + * Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateCredentials(params: { + databaseId: string; + }): Promise; + /** + * Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateCredentials(databaseId: string): Promise; + updateCredentials( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}/credentials'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. + * @throws {AppwriteException} + * @returns {Promise} + */ + createFailover(params: { + databaseId: string; + targetReplicaId?: string; + }): Promise; + /** + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. + * + * @param {string} databaseId - Database ID. + * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFailover( + databaseId: string, + targetReplicaId?: string, + ): Promise; + createFailover( + paramsOrFirst: + { databaseId: string; targetReplicaId?: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; targetReplicaId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetReplicaId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + targetReplicaId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const targetReplicaId = params.targetReplicaId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}/failovers'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof targetReplicaId !== 'undefined') { + apiPayload['targetReplicaId'] = targetReplicaId; + } + 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 the maintenance window for a dedicated database. Maintenance operations like minor version upgrades will be performed during this window. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.day - Day of the week for the maintenance window. Allowed values: sun, mon, tue, wed, thu, fri, sat. + * @param {number} params.hourUtc - Hour in UTC (0-23) for maintenance window start. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateMaintenance(params: { + databaseId: string; + day: string; + hourUtc: number; + }): Promise; + /** + * Update the maintenance window for a dedicated database. Maintenance operations like minor version upgrades will be performed during this window. + * + * @param {string} databaseId - Database ID. + * @param {string} day - Day of the week for the maintenance window. Allowed values: sun, mon, tue, wed, thu, fri, sat. + * @param {number} hourUtc - Hour in UTC (0-23) for maintenance window start. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMaintenance( + databaseId: string, + day: string, + hourUtc: number, + ): Promise; + updateMaintenance( + paramsOrFirst: + { databaseId: string; day: string; hourUtc: number } | string, + ...rest: [string?, number?] + ): Promise { + let params: { databaseId: string; day: string; hourUtc: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + day: string; + hourUtc: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + day: rest[0] as string, + hourUtc: rest[1] as number, + }; + } + + const databaseId = params.databaseId; + const day = params.day; + const hourUtc = params.hourUtc; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof day === 'undefined') { + throw new AppwriteException('Missing required parameter: "day"'); + } + if (typeof hourUtc === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "hourUtc"', + ); + } + const apiPath = '/mongo/{databaseId}/maintenance'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof day !== 'undefined') { + apiPayload['day'] = day; + } + if (typeof hourUtc !== 'undefined') { + apiPayload['hourUtc'] = hourUtc; + } + 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); + } + + /** + * Migrate a database between shared and dedicated types. Shared to dedicated provisions an always-on dedicated instance; dedicated to shared converts to a serverless instance that scales to zero when idle. Data is copied to the target with a brief read-only window during cutover. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.targetType - Target database type to migrate to. Allowed values: shared (serverless, scales to zero when idle), dedicated (always-on with persistent resources). + * @param {string} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. + * @throws {AppwriteException} + * @returns {Promise} + */ + createMigration(params: { + databaseId: string; + targetType: string; + specification?: string; + }): Promise; + /** + * Migrate a database between shared and dedicated types. Shared to dedicated provisions an always-on dedicated instance; dedicated to shared converts to a serverless instance that scales to zero when idle. Data is copied to the target with a brief read-only window during cutover. + * + * @param {string} databaseId - Database ID. + * @param {string} targetType - Target database type to migrate to. Allowed values: shared (serverless, scales to zero when idle), dedicated (always-on with persistent resources). + * @param {string} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMigration( + databaseId: string, + targetType: string, + specification?: string, + ): Promise; + createMigration( + paramsOrFirst: + | { databaseId: string; targetType: string; specification?: string } + | string, + ...rest: [string?, string?] + ): Promise { + let params: { + databaseId: string; + targetType: string; + specification?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetType: string; + specification?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + targetType: rest[0] as string, + specification: rest[1] as string, + }; + } + + const databaseId = params.databaseId; + const targetType = params.targetType; + const specification = params.specification; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof targetType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "targetType"', + ); + } + const apiPath = '/mongo/{databaseId}/migrations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof targetType !== 'undefined') { + apiPayload['targetType'] = targetType; + } + if (typeof specification !== 'undefined') { + apiPayload['specification'] = specification; + } + 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 the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.status - Filter by operation status. + * @param {number} params.limit - Maximum number of operations to return. + * @param {number} params.offset - Number of operations to skip. + * @throws {AppwriteException} + * @returns {Promise} + */ + listOperations(params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }): Promise; + /** + * List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. + * + * @param {string} databaseId - Database ID. + * @param {string} status - Filter by operation status. + * @param {number} limit - Maximum number of operations to return. + * @param {number} offset - Number of operations to skip. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listOperations( + databaseId: string, + status?: string, + limit?: number, + offset?: number, + ): Promise; + listOperations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, number?, number?] + ): Promise { + let params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + status: rest[0] as string, + limit: rest[1] as number, + offset: rest[2] as number, + }; + } + + const databaseId = params.databaseId; + const status = params.status; + const limit = params.limit; + const offset = params.offset; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}/operations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof status !== 'undefined') { + apiPayload['status'] = status; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof offset !== 'undefined') { + apiPayload['offset'] = offset; + } + 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 available point-in-time recovery windows for a dedicated database. Returns the earliest and latest recovery points. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPitr(params: { + databaseId: string; + }): Promise; + /** + * Get available point-in-time recovery windows for a dedicated database. Returns the earliest and latest recovery points. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPitr(databaseId: string): Promise; + getPitr( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}/pitr'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getReplicas(params: { + databaseId: string; + }): Promise; + /** + * Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getReplicas(databaseId: string): Promise; + getReplicas( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}/replicas'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * List all restorations for a dedicated database. Results can be filtered by status and type. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.status - Filter by restoration status. + * @param {string} params.type - Filter by restoration type. + * @param {number} params.limit - Maximum number of restorations to return. + * @param {number} params.offset - Number of restorations to skip. + * @throws {AppwriteException} + * @returns {Promise} + */ + listRestorations(params: { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }): Promise; + /** + * List all restorations for a dedicated database. Results can be filtered by status and type. + * + * @param {string} databaseId - Database ID. + * @param {string} status - Filter by restoration status. + * @param {string} type - Filter by restoration type. + * @param {number} limit - Maximum number of restorations to return. + * @param {number} offset - Number of restorations to skip. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRestorations( + databaseId: string, + status?: string, + type?: string, + limit?: number, + offset?: number, + ): Promise; + listRestorations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, string?, number?, number?] + ): Promise { + let params: { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + status: rest[0] as string, + type: rest[1] as string, + limit: rest[2] as number, + offset: rest[3] as number, + }; + } + + const databaseId = params.databaseId; + const status = params.status; + const type = params.type; + const limit = params.limit; + const offset = params.offset; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}/restorations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof status !== 'undefined') { + apiPayload['status'] = status; + } + if (typeof type !== 'undefined') { + apiPayload['type'] = type; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof offset !== 'undefined') { + apiPayload['offset'] = offset; + } + 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); + } + + /** + * Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.type - Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. + * @param {string} params.backupId - Backup ID to restore from (required for backup type). + * @param {string} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string} params.targetTime - Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRestoration(params: { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }): Promise; + /** + * Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + * + * @param {string} databaseId - Database ID. + * @param {string} type - Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. + * @param {string} backupId - Backup ID to restore from (required for backup type). + * @param {string} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string} targetTime - Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRestoration( + databaseId: string, + type?: string, + backupId?: string, + targetDatabaseId?: string, + targetTime?: string, + ): Promise; + createRestoration( + paramsOrFirst: + | { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + } + | string, + ...rest: [string?, string?, string?, string?] + ): Promise { + let params: { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + type: rest[0] as string, + backupId: rest[1] as string, + targetDatabaseId: rest[2] as string, + targetTime: rest[3] as string, + }; + } + + const databaseId = params.databaseId; + const type = params.type; + const backupId = params.backupId; + const targetDatabaseId = params.targetDatabaseId; + const targetTime = params.targetTime; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}/restorations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof type !== 'undefined') { + apiPayload['type'] = type; + } + if (typeof backupId !== 'undefined') { + apiPayload['backupId'] = backupId; + } + if (typeof targetDatabaseId !== 'undefined') { + apiPayload['targetDatabaseId'] = targetDatabaseId; + } + if (typeof targetTime !== 'undefined') { + apiPayload['targetTime'] = targetTime; + } + 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 details of a specific database restoration including its status, type, and timestamps. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getRestoration(params: { + databaseId: string; + restorationId: string; + }): Promise; + /** + * Get details of a specific database restoration including its status, type, and timestamps. + * + * @param {string} databaseId - Database ID. + * @param {string} restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRestoration( + databaseId: string, + restorationId: string, + ): Promise; + getRestoration( + paramsOrFirst: { databaseId: string; restorationId: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; restorationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + restorationId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + restorationId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const restorationId = params.restorationId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof restorationId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); + } + const apiPath = '/mongo/{databaseId}/restorations/{restorationId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{restorationId}', + encodeURIComponent(String(restorationId)), + ); + 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); + } + + /** + * Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getStatus(params: { databaseId: string }): Promise; + /** + * Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getStatus(databaseId: string): Promise; + getStatus( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mongo/{databaseId}/status'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.targetVersion - Target engine version to upgrade to. + * @throws {AppwriteException} + * @returns {Promise} + */ + createUpgrade(params: { + databaseId: string; + targetVersion: string; + }): Promise; + /** + * Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. + * + * @param {string} databaseId - Database ID. + * @param {string} targetVersion - Target engine version to upgrade to. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createUpgrade( + databaseId: string, + targetVersion: string, + ): Promise; + createUpgrade( + paramsOrFirst: { databaseId: string; targetVersion: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; targetVersion: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetVersion: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + targetVersion: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const targetVersion = params.targetVersion; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof targetVersion === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "targetVersion"', + ); + } + const apiPath = '/mongo/{databaseId}/upgrades'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof targetVersion !== 'undefined') { + apiPayload['targetVersion'] = targetVersion; + } + 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); + } +} diff --git a/src/services/mysql.ts b/src/services/mysql.ts new file mode 100644 index 00000000..95b850ea --- /dev/null +++ b/src/services/mysql.ts @@ -0,0 +1,3265 @@ +import { AppwriteException, Client, type Payload } from '../client'; +import type { Models } from '../models'; + +export class Mysql { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List all dedicated databases. Results support pagination. + * + * @param {string[]} params.queries - Array of query strings. + * @throws {AppwriteException} + * @returns {Promise} + */ + list(params?: { + queries?: string[]; + }): Promise; + /** + * List all dedicated databases. Results support pagination. + * + * @param {string[]} queries - Array of query strings. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(queries?: string[]): Promise; + list( + paramsOrFirst?: { queries?: string[] } | string[], + ): Promise { + let params: { queries?: string[] }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[], + }; + } + + const queries = params.queries; + const apiPath = '/mysql'; + 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 dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. + * + * @param {string} params.databaseId - Database 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 - Database display name. Max length: 128 chars. + * @param {string} params.version - Database engine version. Defaults to latest for selected engine. + * @param {string} params.specification - Specification identifier. Drives the allocated CPU, memory, storage, storage class, and connection ceiling. + * @param {number} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds. + * @param {string[]} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number} params.idleTimeoutMinutes - Minutes of inactivity before container scales to zero. + * @param {boolean} params.pitr - Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. + * @param {number} params.pitrRetentionDays - Number of days to retain PITR data. + * @param {boolean} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @throws {AppwriteException} + * @returns {Promise} + */ + create(params: { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }): Promise; + /** + * Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. + * + * @param {string} databaseId - Database 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 - Database display name. Max length: 128 chars. + * @param {string} version - Database engine version. Defaults to latest for selected engine. + * @param {string} specification - Specification identifier. Drives the allocated CPU, memory, storage, storage class, and connection ceiling. + * @param {number} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number} networkIdleTimeoutSeconds - Connection idle timeout in seconds. + * @param {string[]} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number} idleTimeoutMinutes - Minutes of inactivity before container scales to zero. + * @param {boolean} pitr - Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. + * @param {number} pitrRetentionDays - Number of days to retain PITR data. + * @param {boolean} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create( + databaseId: string, + name: string, + version?: string, + specification?: string, + replicas?: number, + syncMode?: string, + networkIdleTimeoutSeconds?: number, + networkIPAllowlist?: string[], + idleTimeoutMinutes?: number, + pitr?: boolean, + pitrRetentionDays?: number, + storageAutoscaling?: boolean, + storageAutoscalingThresholdPercent?: number, + storageAutoscalingMaxGb?: number, + ): Promise; + create( + paramsOrFirst: + | { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + string?, + number?, + string[]?, + number?, + boolean?, + number?, + boolean?, + number?, + number?, + ] + ): Promise { + let params: { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + version: rest[1] as string, + specification: rest[2] as string, + replicas: rest[3] as number, + syncMode: rest[4] as string, + networkIdleTimeoutSeconds: rest[5] as number, + networkIPAllowlist: rest[6] as string[], + idleTimeoutMinutes: rest[7] as number, + pitr: rest[8] as boolean, + pitrRetentionDays: rest[9] as number, + storageAutoscaling: rest[10] as boolean, + storageAutoscalingThresholdPercent: rest[11] as number, + storageAutoscalingMaxGb: rest[12] as number, + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const version = params.version; + const specification = params.specification; + const replicas = params.replicas; + const syncMode = params.syncMode; + const networkIdleTimeoutSeconds = params.networkIdleTimeoutSeconds; + const networkIPAllowlist = params.networkIPAllowlist; + const idleTimeoutMinutes = params.idleTimeoutMinutes; + const pitr = params.pitr; + const pitrRetentionDays = params.pitrRetentionDays; + const storageAutoscaling = params.storageAutoscaling; + const storageAutoscalingThresholdPercent = + params.storageAutoscalingThresholdPercent; + const storageAutoscalingMaxGb = params.storageAutoscalingMaxGb; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/mysql'; + const apiPayload: Payload = {}; + if (typeof databaseId !== 'undefined') { + apiPayload['databaseId'] = databaseId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof version !== 'undefined') { + apiPayload['version'] = version; + } + if (typeof specification !== 'undefined') { + apiPayload['specification'] = specification; + } + if (typeof replicas !== 'undefined') { + apiPayload['replicas'] = replicas; + } + if (typeof syncMode !== 'undefined') { + apiPayload['syncMode'] = syncMode; + } + if (typeof networkIdleTimeoutSeconds !== 'undefined') { + apiPayload['networkIdleTimeoutSeconds'] = networkIdleTimeoutSeconds; + } + if (typeof networkIPAllowlist !== 'undefined') { + apiPayload['networkIPAllowlist'] = networkIPAllowlist; + } + if (typeof idleTimeoutMinutes !== 'undefined') { + apiPayload['idleTimeoutMinutes'] = idleTimeoutMinutes; + } + if (typeof pitr !== 'undefined') { + apiPayload['pitr'] = pitr; + } + if (typeof pitrRetentionDays !== 'undefined') { + apiPayload['pitrRetentionDays'] = pitrRetentionDays; + } + if (typeof storageAutoscaling !== 'undefined') { + apiPayload['storageAutoscaling'] = storageAutoscaling; + } + if (typeof storageAutoscalingThresholdPercent !== 'undefined') { + apiPayload['storageAutoscalingThresholdPercent'] = + storageAutoscalingThresholdPercent; + } + if (typeof storageAutoscalingMaxGb !== 'undefined') { + apiPayload['storageAutoscalingMaxGb'] = storageAutoscalingMaxGb; + } + 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 the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + listSpecifications(): Promise { + const apiPath = '/mysql/specifications'; + 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); + } + + /** + * Get a dedicated database by its unique ID. Returns the database configuration and current status. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + get(params: { databaseId: string }): Promise; + /** + * Get a dedicated database by its unique ID. Returns the database configuration and current status. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(databaseId: string): Promise; + get( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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 dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.name - Database display name. + * @param {string} params.status - Database status. Allowed values: ready, paused, inactive. Set to "paused" to pause, "ready" to resume (also recovers a failed database whose infrastructure is healthy), or "inactive" to spin down a shared-pool database. + * @param {string} params.specification - Specification. Changes cpu, memory, storage, connection ceiling, and node pool based on specification config. Resource changes are applied via rolling cutover with zero downtime. + * @param {number} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[]} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[]} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). + * @throws {AppwriteException} + * @returns {Promise} + */ + update(params: { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }): Promise; + /** + * Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. + * + * @param {string} databaseId - Database ID. + * @param {string} name - Database display name. + * @param {string} status - Database status. Allowed values: ready, paused, inactive. Set to "paused" to pause, "ready" to resume (also recovers a failed database whose infrastructure is healthy), or "inactive" to spin down a shared-pool database. + * @param {string} specification - Specification. Changes cpu, memory, storage, connection ceiling, and node pool based on specification config. Resource changes are applied via rolling cutover with zero downtime. + * @param {number} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[]} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number} pitrRetentionDays - Days to retain PITR data. + * @param {boolean} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[]} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update( + databaseId: string, + name?: string, + status?: string, + specification?: string, + replicas?: number, + syncMode?: string, + networkIdleTimeoutSeconds?: number, + networkIPAllowlist?: string[], + idleTimeoutMinutes?: number, + pitr?: boolean, + pitrRetentionDays?: number, + storageAutoscaling?: boolean, + storageAutoscalingThresholdPercent?: number, + storageAutoscalingMaxGb?: number, + metricsTraceSampleRate?: number, + metricsSlowQueryLogThresholdMs?: number, + sqlApiEnabled?: boolean, + sqlApiAllowedStatements?: string[], + sqlApiMaxRows?: number, + sqlApiMaxBytes?: number, + sqlApiTimeoutSeconds?: number, + ): Promise; + update( + paramsOrFirst: + | { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + string?, + number?, + string[]?, + number?, + boolean?, + number?, + boolean?, + number?, + number?, + number?, + number?, + boolean?, + string[]?, + number?, + number?, + number?, + ] + ): Promise { + let params: { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + status: rest[1] as string, + specification: rest[2] as string, + replicas: rest[3] as number, + syncMode: rest[4] as string, + networkIdleTimeoutSeconds: rest[5] as number, + networkIPAllowlist: rest[6] as string[], + idleTimeoutMinutes: rest[7] as number, + pitr: rest[8] as boolean, + pitrRetentionDays: rest[9] as number, + storageAutoscaling: rest[10] as boolean, + storageAutoscalingThresholdPercent: rest[11] as number, + storageAutoscalingMaxGb: rest[12] as number, + metricsTraceSampleRate: rest[13] as number, + metricsSlowQueryLogThresholdMs: rest[14] as number, + sqlApiEnabled: rest[15] as boolean, + sqlApiAllowedStatements: rest[16] as string[], + sqlApiMaxRows: rest[17] as number, + sqlApiMaxBytes: rest[18] as number, + sqlApiTimeoutSeconds: rest[19] as number, + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const status = params.status; + const specification = params.specification; + const replicas = params.replicas; + const syncMode = params.syncMode; + const networkIdleTimeoutSeconds = params.networkIdleTimeoutSeconds; + const networkIPAllowlist = params.networkIPAllowlist; + const idleTimeoutMinutes = params.idleTimeoutMinutes; + const pitr = params.pitr; + const pitrRetentionDays = params.pitrRetentionDays; + const storageAutoscaling = params.storageAutoscaling; + const storageAutoscalingThresholdPercent = + params.storageAutoscalingThresholdPercent; + const storageAutoscalingMaxGb = params.storageAutoscalingMaxGb; + const metricsTraceSampleRate = params.metricsTraceSampleRate; + const metricsSlowQueryLogThresholdMs = + params.metricsSlowQueryLogThresholdMs; + const sqlApiEnabled = params.sqlApiEnabled; + const sqlApiAllowedStatements = params.sqlApiAllowedStatements; + const sqlApiMaxRows = params.sqlApiMaxRows; + const sqlApiMaxBytes = params.sqlApiMaxBytes; + const sqlApiTimeoutSeconds = params.sqlApiTimeoutSeconds; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof status !== 'undefined') { + apiPayload['status'] = status; + } + if (typeof specification !== 'undefined') { + apiPayload['specification'] = specification; + } + if (typeof replicas !== 'undefined') { + apiPayload['replicas'] = replicas; + } + if (typeof syncMode !== 'undefined') { + apiPayload['syncMode'] = syncMode; + } + if (typeof networkIdleTimeoutSeconds !== 'undefined') { + apiPayload['networkIdleTimeoutSeconds'] = networkIdleTimeoutSeconds; + } + if (typeof networkIPAllowlist !== 'undefined') { + apiPayload['networkIPAllowlist'] = networkIPAllowlist; + } + if (typeof idleTimeoutMinutes !== 'undefined') { + apiPayload['idleTimeoutMinutes'] = idleTimeoutMinutes; + } + if (typeof pitr !== 'undefined') { + apiPayload['pitr'] = pitr; + } + if (typeof pitrRetentionDays !== 'undefined') { + apiPayload['pitrRetentionDays'] = pitrRetentionDays; + } + if (typeof storageAutoscaling !== 'undefined') { + apiPayload['storageAutoscaling'] = storageAutoscaling; + } + if (typeof storageAutoscalingThresholdPercent !== 'undefined') { + apiPayload['storageAutoscalingThresholdPercent'] = + storageAutoscalingThresholdPercent; + } + if (typeof storageAutoscalingMaxGb !== 'undefined') { + apiPayload['storageAutoscalingMaxGb'] = storageAutoscalingMaxGb; + } + if (typeof metricsTraceSampleRate !== 'undefined') { + apiPayload['metricsTraceSampleRate'] = metricsTraceSampleRate; + } + if (typeof metricsSlowQueryLogThresholdMs !== 'undefined') { + apiPayload['metricsSlowQueryLogThresholdMs'] = + metricsSlowQueryLogThresholdMs; + } + if (typeof sqlApiEnabled !== 'undefined') { + apiPayload['sqlApiEnabled'] = sqlApiEnabled; + } + if (typeof sqlApiAllowedStatements !== 'undefined') { + apiPayload['sqlApiAllowedStatements'] = sqlApiAllowedStatements; + } + if (typeof sqlApiMaxRows !== 'undefined') { + apiPayload['sqlApiMaxRows'] = sqlApiMaxRows; + } + if (typeof sqlApiMaxBytes !== 'undefined') { + apiPayload['sqlApiMaxBytes'] = sqlApiMaxBytes; + } + if (typeof sqlApiTimeoutSeconds !== 'undefined') { + apiPayload['sqlApiTimeoutSeconds'] = sqlApiTimeoutSeconds; + } + 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 a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { databaseId: string }): Promise<{}>; + /** + * Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(databaseId: string): Promise<{}>; + delete(paramsOrFirst: { databaseId: string } | string): Promise<{}> { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * List all backups for a dedicated database. Results can be filtered by status and type. + * + * @param {string} params.databaseId - Database 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: status, type, databaseId + * @throws {AppwriteException} + * @returns {Promise} + */ + listBackups(params: { + databaseId: string; + queries?: string[]; + }): Promise; + /** + * List all backups for a dedicated database. Results can be filtered by status and type. + * + * @param {string} databaseId - Database 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: status, type, databaseId + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listBackups( + databaseId: string, + queries?: string[], + ): Promise; + listBackups( + paramsOrFirst: { databaseId: string; queries?: string[] } | string, + ...rest: [string[]?] + ): Promise { + let params: { databaseId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + queries: rest[0] as string[], + }; + } + + const databaseId = params.databaseId; + const queries = params.queries; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}/backups'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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 manual backup of a dedicated database. The backup will be created asynchronously and its status can be checked via the get backup endpoint. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.type - Backup type: full or incremental. + * @throws {AppwriteException} + * @returns {Promise} + */ + createBackup(params: { + databaseId: string; + type?: string; + }): Promise; + /** + * Create a manual backup of a dedicated database. The backup will be created asynchronously and its status can be checked via the get backup endpoint. + * + * @param {string} databaseId - Database ID. + * @param {string} type - Backup type: full or incremental. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBackup( + databaseId: string, + type?: string, + ): Promise; + createBackup( + paramsOrFirst: { databaseId: string; type?: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; type?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + type?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + type: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const type = params.type; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}/backups'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof type !== 'undefined') { + apiPayload['type'] = type; + } + 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 scheduled backup policies for a dedicated database. + * + * @param {string} params.databaseId - Database ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. + * @throws {AppwriteException} + * @returns {Promise} + */ + listBackupPolicies(params: { + databaseId: string; + queries?: string[]; + }): Promise; + /** + * List scheduled backup policies for a dedicated database. + * + * @param {string} databaseId - Database ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listBackupPolicies( + databaseId: string, + queries?: string[], + ): Promise; + listBackupPolicies( + paramsOrFirst: { databaseId: string; queries?: string[] } | string, + ...rest: [string[]?] + ): Promise { + let params: { databaseId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + queries: rest[0] as string[], + }; + } + + const databaseId = params.databaseId; + const queries = params.queries; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}/backups/policies'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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 scheduled backup policy for a dedicated database. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.policyId - Policy 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 - Policy name. Max length: 128 chars. + * @param {string} params.schedule - Schedule CRON syntax. + * @param {number} params.retention - Days to keep backups before deletion. + * @param {string} params.type - Backup type: full or incremental. + * @param {boolean} params.enabled - Is policy enabled? When disabled, no backups will be taken. + * @throws {AppwriteException} + * @returns {Promise} + */ + createBackupPolicy(params: { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }): Promise; + /** + * Create a scheduled backup policy for a dedicated database. + * + * @param {string} databaseId - Database ID. + * @param {string} policyId - Policy 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 - Policy name. Max length: 128 chars. + * @param {string} schedule - Schedule CRON syntax. + * @param {number} retention - Days to keep backups before deletion. + * @param {string} type - Backup type: full or incremental. + * @param {boolean} enabled - Is policy enabled? When disabled, no backups will be taken. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBackupPolicy( + databaseId: string, + policyId: string, + name: string, + schedule: string, + retention: number, + type?: string, + enabled?: boolean, + ): Promise; + createBackupPolicy( + paramsOrFirst: + | { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, number?, string?, boolean?] + ): Promise { + let params: { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + policyId: rest[0] as string, + name: rest[1] as string, + schedule: rest[2] as string, + retention: rest[3] as number, + type: rest[4] as string, + enabled: rest[5] as boolean, + }; + } + + const databaseId = params.databaseId; + const policyId = params.policyId; + const name = params.name; + const schedule = params.schedule; + const retention = params.retention; + const type = params.type; + const enabled = params.enabled; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof policyId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof schedule === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "schedule"', + ); + } + if (typeof retention === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "retention"', + ); + } + const apiPath = '/mysql/{databaseId}/backups/policies'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof policyId !== 'undefined') { + apiPayload['policyId'] = policyId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof schedule !== 'undefined') { + apiPayload['schedule'] = schedule; + } + if (typeof retention !== 'undefined') { + apiPayload['retention'] = retention; + } + if (typeof type !== 'undefined') { + apiPayload['type'] = type; + } + 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('post', uri, apiHeaders, apiPayload); + } + + /** + * Get a scheduled backup policy for a dedicated database. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.policyId - Policy ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getBackupPolicy(params: { + databaseId: string; + policyId: string; + }): Promise; + /** + * Get a scheduled backup policy for a dedicated database. + * + * @param {string} databaseId - Database ID. + * @param {string} policyId - Policy ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getBackupPolicy( + databaseId: string, + policyId: string, + ): Promise; + getBackupPolicy( + paramsOrFirst: { databaseId: string; policyId: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; policyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + policyId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const policyId = params.policyId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof policyId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); + } + const apiPath = '/mysql/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); + 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 scheduled backup policy for a dedicated database. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.policyId - Policy ID. + * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string} params.schedule - Schedule CRON syntax. + * @param {number} params.retention - Days to keep backups before deletion. + * @param {boolean} params.enabled - Is policy enabled? When disabled, no backups will be taken. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateBackupPolicy(params: { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }): Promise; + /** + * Update a scheduled backup policy for a dedicated database. + * + * @param {string} databaseId - Database ID. + * @param {string} policyId - Policy ID. + * @param {string} name - Policy name. Max length: 128 chars. + * @param {string} schedule - Schedule CRON syntax. + * @param {number} retention - Days to keep backups before deletion. + * @param {boolean} enabled - Is policy enabled? When disabled, no backups will be taken. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBackupPolicy( + databaseId: string, + policyId: string, + name?: string, + schedule?: string, + retention?: number, + enabled?: boolean, + ): Promise; + updateBackupPolicy( + paramsOrFirst: + | { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, number?, boolean?] + ): Promise { + let params: { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + policyId: rest[0] as string, + name: rest[1] as string, + schedule: rest[2] as string, + retention: rest[3] as number, + enabled: rest[4] as boolean, + }; + } + + const databaseId = params.databaseId; + const policyId = params.policyId; + const name = params.name; + const schedule = params.schedule; + const retention = params.retention; + const enabled = params.enabled; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof policyId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); + } + const apiPath = '/mysql/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof schedule !== 'undefined') { + apiPayload['schedule'] = schedule; + } + if (typeof retention !== 'undefined') { + apiPayload['retention'] = retention; + } + 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); + } + + /** + * Delete a scheduled backup policy for a dedicated database. Backups already taken by the policy are kept until their retention expires. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.policyId - Policy ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteBackupPolicy(params: { + databaseId: string; + policyId: string; + }): Promise<{}>; + /** + * Delete a scheduled backup policy for a dedicated database. Backups already taken by the policy are kept until their retention expires. + * + * @param {string} databaseId - Database ID. + * @param {string} policyId - Policy ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteBackupPolicy(databaseId: string, policyId: string): Promise<{}>; + deleteBackupPolicy( + paramsOrFirst: { databaseId: string; policyId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { databaseId: string; policyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + policyId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const policyId = params.policyId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof policyId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); + } + const apiPath = '/mysql/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); + 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); + } + + /** + * Configure off-cluster backup storage for a dedicated database. Supports S3, GCS, and Azure Blob Storage destinations. Backups will be stored to the configured destination in addition to on-cluster storage. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.provider - Storage provider for off-cluster backups. Allowed values: s3 (Amazon S3 or S3-compatible), gcs (Google Cloud Storage), azure (Azure Blob Storage). + * @param {string} params.bucket - Storage bucket or container name. + * @param {string} params.accessKey - Access key or client ID for authentication. + * @param {string} params.secretKey - Secret key or service account JSON for authentication. + * @param {string} params.region - Storage region. + * @param {string} params.prefix - Object key prefix for backups. + * @param {string} params.endpoint - Custom endpoint for S3-compatible storage (e.g. MinIO). + * @throws {AppwriteException} + * @returns {Promise} + */ + updateBackupStorage(params: { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }): Promise; + /** + * Configure off-cluster backup storage for a dedicated database. Supports S3, GCS, and Azure Blob Storage destinations. Backups will be stored to the configured destination in addition to on-cluster storage. + * + * @param {string} databaseId - Database ID. + * @param {string} provider - Storage provider for off-cluster backups. Allowed values: s3 (Amazon S3 or S3-compatible), gcs (Google Cloud Storage), azure (Azure Blob Storage). + * @param {string} bucket - Storage bucket or container name. + * @param {string} accessKey - Access key or client ID for authentication. + * @param {string} secretKey - Secret key or service account JSON for authentication. + * @param {string} region - Storage region. + * @param {string} prefix - Object key prefix for backups. + * @param {string} endpoint - Custom endpoint for S3-compatible storage (e.g. MinIO). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBackupStorage( + databaseId: string, + provider: string, + bucket: string, + accessKey: string, + secretKey: string, + region?: string, + prefix?: string, + endpoint?: string, + ): Promise; + updateBackupStorage( + paramsOrFirst: + | { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + } + | string, + ...rest: [string?, string?, string?, string?, string?, string?, string?] + ): Promise { + let params: { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + provider: rest[0] as string, + bucket: rest[1] as string, + accessKey: rest[2] as string, + secretKey: rest[3] as string, + region: rest[4] as string, + prefix: rest[5] as string, + endpoint: rest[6] as string, + }; + } + + const databaseId = params.databaseId; + const provider = params.provider; + const bucket = params.bucket; + const accessKey = params.accessKey; + const secretKey = params.secretKey; + const region = params.region; + const prefix = params.prefix; + const endpoint = params.endpoint; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof provider === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "provider"', + ); + } + if (typeof bucket === 'undefined') { + throw new AppwriteException('Missing required parameter: "bucket"'); + } + if (typeof accessKey === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "accessKey"', + ); + } + if (typeof secretKey === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "secretKey"', + ); + } + const apiPath = '/mysql/{databaseId}/backups/storage'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof provider !== 'undefined') { + apiPayload['provider'] = provider; + } + if (typeof bucket !== 'undefined') { + apiPayload['bucket'] = bucket; + } + if (typeof region !== 'undefined') { + apiPayload['region'] = region; + } + if (typeof prefix !== 'undefined') { + apiPayload['prefix'] = prefix; + } + if (typeof endpoint !== 'undefined') { + apiPayload['endpoint'] = endpoint; + } + if (typeof accessKey !== 'undefined') { + apiPayload['accessKey'] = accessKey; + } + if (typeof secretKey !== 'undefined') { + apiPayload['secretKey'] = secretKey; + } + 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 details of a specific database backup including its status, size, and timestamps. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.backupId - Backup ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getBackup(params: { + databaseId: string; + backupId: string; + }): Promise; + /** + * Get details of a specific database backup including its status, size, and timestamps. + * + * @param {string} databaseId - Database ID. + * @param {string} backupId - Backup ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getBackup( + databaseId: string, + backupId: string, + ): Promise; + getBackup( + paramsOrFirst: { databaseId: string; backupId: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; backupId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + backupId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + backupId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const backupId = params.backupId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof backupId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "backupId"', + ); + } + const apiPath = '/mysql/{databaseId}/backups/{backupId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{backupId}', encodeURIComponent(String(backupId))); + 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 database backup. This will permanently remove the backup from storage and cannot be undone. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.backupId - Backup ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteBackup(params: { databaseId: string; backupId: string }): Promise<{}>; + /** + * Delete a database backup. This will permanently remove the backup from storage and cannot be undone. + * + * @param {string} databaseId - Database ID. + * @param {string} backupId - Backup ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteBackup(databaseId: string, backupId: string): Promise<{}>; + deleteBackup( + paramsOrFirst: { databaseId: string; backupId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { databaseId: string; backupId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + backupId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + backupId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const backupId = params.backupId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof backupId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "backupId"', + ); + } + const apiPath = '/mysql/{databaseId}/backups/{backupId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{backupId}', encodeURIComponent(String(backupId))); + 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); + } + + /** + * List all ephemeral branches for a dedicated database. Returns branch metadata including ID, name, namespace, and expiration time. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + listBranches(params: { + databaseId: string; + }): Promise; + /** + * List all ephemeral branches for a dedicated database. Returns branch metadata including ID, name, namespace, and expiration time. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listBranches( + databaseId: string, + ): Promise; + listBranches( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}/branches'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.branchId - Branch 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 {number} params.ttl - Time-to-live in seconds before the branch expires. Min 300 (5 min), max 604800 (7 days). Default: 86400 (24h). + * @throws {AppwriteException} + * @returns {Promise} + */ + createBranch(params: { + databaseId: string; + branchId?: string; + ttl?: number; + }): Promise; + /** + * Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. + * + * @param {string} databaseId - Database ID. + * @param {string} branchId - Branch 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 {number} ttl - Time-to-live in seconds before the branch expires. Min 300 (5 min), max 604800 (7 days). Default: 86400 (24h). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBranch( + databaseId: string, + branchId?: string, + ttl?: number, + ): Promise; + createBranch( + paramsOrFirst: + { databaseId: string; branchId?: string; ttl?: number } | string, + ...rest: [string?, number?] + ): Promise { + let params: { databaseId: string; branchId?: string; ttl?: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + branchId?: string; + ttl?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + branchId: rest[0] as string, + ttl: rest[1] as number, + }; + } + + const databaseId = params.databaseId; + const branchId = params.branchId; + const ttl = params.ttl; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}/branches'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof branchId !== 'undefined') { + apiPayload['branchId'] = branchId; + } + 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); + } + + /** + * Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.branchId - Branch ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteBranch(params: { + databaseId: string; + branchId: string; + }): Promise; + /** + * Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. + * + * @param {string} databaseId - Database ID. + * @param {string} branchId - Branch ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteBranch( + databaseId: string, + branchId: string, + ): Promise; + deleteBranch( + paramsOrFirst: { databaseId: string; branchId: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; branchId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + branchId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + branchId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const branchId = params.branchId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof branchId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "branchId"', + ); + } + const apiPath = '/mysql/{databaseId}/branches/{branchId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{branchId}', encodeURIComponent(String(branchId))); + 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); + } + + /** + * Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateCredentials(params: { + databaseId: string; + }): Promise; + /** + * Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateCredentials(databaseId: string): Promise; + updateCredentials( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}/credentials'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.sql - SQL statement to execute. Exactly one statement per request. + * @param {object} params.bindings - Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. + * @param {number} params.timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. + * @throws {AppwriteException} + * @returns {Promise} + */ + createExecution(params: { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + }): Promise; + /** + * Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. + * + * @param {string} databaseId - Database ID. + * @param {string} sql - SQL statement to execute. Exactly one statement per request. + * @param {object} bindings - Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. + * @param {number} timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createExecution( + databaseId: string, + sql: string, + bindings?: object, + timeoutSeconds?: number, + ): Promise; + createExecution( + paramsOrFirst: + | { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + } + | string, + ...rest: [string?, object?, number?] + ): Promise { + let params: { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + sql: rest[0] as string, + bindings: rest[1] as object, + timeoutSeconds: rest[2] as number, + }; + } + + const databaseId = params.databaseId; + const sql = params.sql; + const bindings = params.bindings; + const timeoutSeconds = params.timeoutSeconds; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof sql === 'undefined') { + throw new AppwriteException('Missing required parameter: "sql"'); + } + const apiPath = '/mysql/{databaseId}/executions'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof sql !== 'undefined') { + apiPayload['sql'] = sql; + } + if (typeof bindings !== 'undefined') { + apiPayload['bindings'] = bindings; + } + if (typeof timeoutSeconds !== 'undefined') { + apiPayload['timeoutSeconds'] = timeoutSeconds; + } + 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); + } + + /** + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. + * @throws {AppwriteException} + * @returns {Promise} + */ + createFailover(params: { + databaseId: string; + targetReplicaId?: string; + }): Promise; + /** + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. + * + * @param {string} databaseId - Database ID. + * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFailover( + databaseId: string, + targetReplicaId?: string, + ): Promise; + createFailover( + paramsOrFirst: + { databaseId: string; targetReplicaId?: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; targetReplicaId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetReplicaId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + targetReplicaId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const targetReplicaId = params.targetReplicaId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}/failovers'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof targetReplicaId !== 'undefined') { + apiPayload['targetReplicaId'] = targetReplicaId; + } + 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 the maintenance window for a dedicated database. Maintenance operations like minor version upgrades will be performed during this window. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.day - Day of the week for the maintenance window. Allowed values: sun, mon, tue, wed, thu, fri, sat. + * @param {number} params.hourUtc - Hour in UTC (0-23) for maintenance window start. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateMaintenance(params: { + databaseId: string; + day: string; + hourUtc: number; + }): Promise; + /** + * Update the maintenance window for a dedicated database. Maintenance operations like minor version upgrades will be performed during this window. + * + * @param {string} databaseId - Database ID. + * @param {string} day - Day of the week for the maintenance window. Allowed values: sun, mon, tue, wed, thu, fri, sat. + * @param {number} hourUtc - Hour in UTC (0-23) for maintenance window start. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMaintenance( + databaseId: string, + day: string, + hourUtc: number, + ): Promise; + updateMaintenance( + paramsOrFirst: + { databaseId: string; day: string; hourUtc: number } | string, + ...rest: [string?, number?] + ): Promise { + let params: { databaseId: string; day: string; hourUtc: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + day: string; + hourUtc: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + day: rest[0] as string, + hourUtc: rest[1] as number, + }; + } + + const databaseId = params.databaseId; + const day = params.day; + const hourUtc = params.hourUtc; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof day === 'undefined') { + throw new AppwriteException('Missing required parameter: "day"'); + } + if (typeof hourUtc === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "hourUtc"', + ); + } + const apiPath = '/mysql/{databaseId}/maintenance'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof day !== 'undefined') { + apiPayload['day'] = day; + } + if (typeof hourUtc !== 'undefined') { + apiPayload['hourUtc'] = hourUtc; + } + 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); + } + + /** + * Migrate a database between shared and dedicated types. Shared to dedicated provisions an always-on dedicated instance; dedicated to shared converts to a serverless instance that scales to zero when idle. Data is copied to the target with a brief read-only window during cutover. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.targetType - Target database type to migrate to. Allowed values: shared (serverless, scales to zero when idle), dedicated (always-on with persistent resources). + * @param {string} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. + * @throws {AppwriteException} + * @returns {Promise} + */ + createMigration(params: { + databaseId: string; + targetType: string; + specification?: string; + }): Promise; + /** + * Migrate a database between shared and dedicated types. Shared to dedicated provisions an always-on dedicated instance; dedicated to shared converts to a serverless instance that scales to zero when idle. Data is copied to the target with a brief read-only window during cutover. + * + * @param {string} databaseId - Database ID. + * @param {string} targetType - Target database type to migrate to. Allowed values: shared (serverless, scales to zero when idle), dedicated (always-on with persistent resources). + * @param {string} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMigration( + databaseId: string, + targetType: string, + specification?: string, + ): Promise; + createMigration( + paramsOrFirst: + | { databaseId: string; targetType: string; specification?: string } + | string, + ...rest: [string?, string?] + ): Promise { + let params: { + databaseId: string; + targetType: string; + specification?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetType: string; + specification?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + targetType: rest[0] as string, + specification: rest[1] as string, + }; + } + + const databaseId = params.databaseId; + const targetType = params.targetType; + const specification = params.specification; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof targetType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "targetType"', + ); + } + const apiPath = '/mysql/{databaseId}/migrations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof targetType !== 'undefined') { + apiPayload['targetType'] = targetType; + } + if (typeof specification !== 'undefined') { + apiPayload['specification'] = specification; + } + 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 the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.status - Filter by operation status. + * @param {number} params.limit - Maximum number of operations to return. + * @param {number} params.offset - Number of operations to skip. + * @throws {AppwriteException} + * @returns {Promise} + */ + listOperations(params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }): Promise; + /** + * List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. + * + * @param {string} databaseId - Database ID. + * @param {string} status - Filter by operation status. + * @param {number} limit - Maximum number of operations to return. + * @param {number} offset - Number of operations to skip. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listOperations( + databaseId: string, + status?: string, + limit?: number, + offset?: number, + ): Promise; + listOperations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, number?, number?] + ): Promise { + let params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + status: rest[0] as string, + limit: rest[1] as number, + offset: rest[2] as number, + }; + } + + const databaseId = params.databaseId; + const status = params.status; + const limit = params.limit; + const offset = params.offset; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}/operations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof status !== 'undefined') { + apiPayload['status'] = status; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof offset !== 'undefined') { + apiPayload['offset'] = offset; + } + 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 available point-in-time recovery windows for a dedicated database. Returns the earliest and latest recovery points. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPitr(params: { + databaseId: string; + }): Promise; + /** + * Get available point-in-time recovery windows for a dedicated database. Returns the earliest and latest recovery points. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPitr(databaseId: string): Promise; + getPitr( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}/pitr'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * Get the connection pooler configuration for a dedicated database. Returns pooler mode, max connections, and pool size settings. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPooler(params: { + databaseId: string; + }): Promise; + /** + * Get the connection pooler configuration for a dedicated database. Returns pooler mode, max connections, and pool size settings. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPooler(databaseId: string): Promise; + getPooler( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}/pooler'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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 connection pooler configuration for a dedicated database. Configure pool mode, max connections, and pool sizes. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.mode - Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. + * @param {number} params.maxConnections - Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. + * @param {number} params.defaultPoolSize - Default pool size per user. + * @param {boolean} params.readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + * @param {string} params.poolerCpuRequest - Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). + * @param {string} params.poolerCpuLimit - Pooler sidecar CPU limit override (Kubernetes quantity, e.g. "500m" or "1"). Leave null for the proportional default (10% of DB CPU, floor 200m). Changing this field rolls the database pod. + * @param {string} params.poolerMemoryRequest - Pooler sidecar memory request override (Kubernetes quantity, e.g. "128Mi" or "1Gi"). Leave null for the proportional default (7.5% of DB memory, floor 64Mi). + * @param {string} params.poolerMemoryLimit - Pooler sidecar memory limit override (Kubernetes quantity, e.g. "256Mi" or "1Gi"). Leave null for the proportional default (15% of DB memory, floor 128Mi). Changing this field rolls the database pod. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePooler(params: { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + }): Promise; + /** + * Update the connection pooler configuration for a dedicated database. Configure pool mode, max connections, and pool sizes. + * + * @param {string} databaseId - Database ID. + * @param {string} mode - Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. + * @param {number} maxConnections - Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. + * @param {number} defaultPoolSize - Default pool size per user. + * @param {boolean} readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + * @param {string} poolerCpuRequest - Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). + * @param {string} poolerCpuLimit - Pooler sidecar CPU limit override (Kubernetes quantity, e.g. "500m" or "1"). Leave null for the proportional default (10% of DB CPU, floor 200m). Changing this field rolls the database pod. + * @param {string} poolerMemoryRequest - Pooler sidecar memory request override (Kubernetes quantity, e.g. "128Mi" or "1Gi"). Leave null for the proportional default (7.5% of DB memory, floor 64Mi). + * @param {string} poolerMemoryLimit - Pooler sidecar memory limit override (Kubernetes quantity, e.g. "256Mi" or "1Gi"). Leave null for the proportional default (15% of DB memory, floor 128Mi). Changing this field rolls the database pod. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePooler( + databaseId: string, + mode?: string, + maxConnections?: number, + defaultPoolSize?: number, + readWriteSplitting?: boolean, + poolerCpuRequest?: string, + poolerCpuLimit?: string, + poolerMemoryRequest?: string, + poolerMemoryLimit?: string, + ): Promise; + updatePooler( + paramsOrFirst: + | { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + } + | string, + ...rest: [ + string?, + number?, + number?, + boolean?, + string?, + string?, + string?, + string?, + ] + ): Promise { + let params: { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + mode: rest[0] as string, + maxConnections: rest[1] as number, + defaultPoolSize: rest[2] as number, + readWriteSplitting: rest[3] as boolean, + poolerCpuRequest: rest[4] as string, + poolerCpuLimit: rest[5] as string, + poolerMemoryRequest: rest[6] as string, + poolerMemoryLimit: rest[7] as string, + }; + } + + const databaseId = params.databaseId; + const mode = params.mode; + const maxConnections = params.maxConnections; + const defaultPoolSize = params.defaultPoolSize; + const readWriteSplitting = params.readWriteSplitting; + const poolerCpuRequest = params.poolerCpuRequest; + const poolerCpuLimit = params.poolerCpuLimit; + const poolerMemoryRequest = params.poolerMemoryRequest; + const poolerMemoryLimit = params.poolerMemoryLimit; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}/pooler'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof mode !== 'undefined') { + apiPayload['mode'] = mode; + } + if (typeof maxConnections !== 'undefined') { + apiPayload['maxConnections'] = maxConnections; + } + if (typeof defaultPoolSize !== 'undefined') { + apiPayload['defaultPoolSize'] = defaultPoolSize; + } + if (typeof readWriteSplitting !== 'undefined') { + apiPayload['readWriteSplitting'] = readWriteSplitting; + } + if (typeof poolerCpuRequest !== 'undefined') { + apiPayload['poolerCpuRequest'] = poolerCpuRequest; + } + if (typeof poolerCpuLimit !== 'undefined') { + apiPayload['poolerCpuLimit'] = poolerCpuLimit; + } + if (typeof poolerMemoryRequest !== 'undefined') { + apiPayload['poolerMemoryRequest'] = poolerMemoryRequest; + } + if (typeof poolerMemoryLimit !== 'undefined') { + apiPayload['poolerMemoryLimit'] = poolerMemoryLimit; + } + 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 high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getReplicas(params: { + databaseId: string; + }): Promise; + /** + * Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getReplicas(databaseId: string): Promise; + getReplicas( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}/replicas'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * List all restorations for a dedicated database. Results can be filtered by status and type. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.status - Filter by restoration status. + * @param {string} params.type - Filter by restoration type. + * @param {number} params.limit - Maximum number of restorations to return. + * @param {number} params.offset - Number of restorations to skip. + * @throws {AppwriteException} + * @returns {Promise} + */ + listRestorations(params: { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }): Promise; + /** + * List all restorations for a dedicated database. Results can be filtered by status and type. + * + * @param {string} databaseId - Database ID. + * @param {string} status - Filter by restoration status. + * @param {string} type - Filter by restoration type. + * @param {number} limit - Maximum number of restorations to return. + * @param {number} offset - Number of restorations to skip. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRestorations( + databaseId: string, + status?: string, + type?: string, + limit?: number, + offset?: number, + ): Promise; + listRestorations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, string?, number?, number?] + ): Promise { + let params: { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + status: rest[0] as string, + type: rest[1] as string, + limit: rest[2] as number, + offset: rest[3] as number, + }; + } + + const databaseId = params.databaseId; + const status = params.status; + const type = params.type; + const limit = params.limit; + const offset = params.offset; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}/restorations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof status !== 'undefined') { + apiPayload['status'] = status; + } + if (typeof type !== 'undefined') { + apiPayload['type'] = type; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof offset !== 'undefined') { + apiPayload['offset'] = offset; + } + 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); + } + + /** + * Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.type - Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. + * @param {string} params.backupId - Backup ID to restore from (required for backup type). + * @param {string} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string} params.targetTime - Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRestoration(params: { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }): Promise; + /** + * Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + * + * @param {string} databaseId - Database ID. + * @param {string} type - Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. + * @param {string} backupId - Backup ID to restore from (required for backup type). + * @param {string} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string} targetTime - Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRestoration( + databaseId: string, + type?: string, + backupId?: string, + targetDatabaseId?: string, + targetTime?: string, + ): Promise; + createRestoration( + paramsOrFirst: + | { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + } + | string, + ...rest: [string?, string?, string?, string?] + ): Promise { + let params: { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + type: rest[0] as string, + backupId: rest[1] as string, + targetDatabaseId: rest[2] as string, + targetTime: rest[3] as string, + }; + } + + const databaseId = params.databaseId; + const type = params.type; + const backupId = params.backupId; + const targetDatabaseId = params.targetDatabaseId; + const targetTime = params.targetTime; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}/restorations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof type !== 'undefined') { + apiPayload['type'] = type; + } + if (typeof backupId !== 'undefined') { + apiPayload['backupId'] = backupId; + } + if (typeof targetDatabaseId !== 'undefined') { + apiPayload['targetDatabaseId'] = targetDatabaseId; + } + if (typeof targetTime !== 'undefined') { + apiPayload['targetTime'] = targetTime; + } + 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 details of a specific database restoration including its status, type, and timestamps. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getRestoration(params: { + databaseId: string; + restorationId: string; + }): Promise; + /** + * Get details of a specific database restoration including its status, type, and timestamps. + * + * @param {string} databaseId - Database ID. + * @param {string} restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRestoration( + databaseId: string, + restorationId: string, + ): Promise; + getRestoration( + paramsOrFirst: { databaseId: string; restorationId: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; restorationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + restorationId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + restorationId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const restorationId = params.restorationId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof restorationId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); + } + const apiPath = '/mysql/{databaseId}/restorations/{restorationId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{restorationId}', + encodeURIComponent(String(restorationId)), + ); + 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); + } + + /** + * Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getStatus(params: { databaseId: string }): Promise; + /** + * Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getStatus(databaseId: string): Promise; + getStatus( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/mysql/{databaseId}/status'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.targetVersion - Target engine version to upgrade to. + * @throws {AppwriteException} + * @returns {Promise} + */ + createUpgrade(params: { + databaseId: string; + targetVersion: string; + }): Promise; + /** + * Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. + * + * @param {string} databaseId - Database ID. + * @param {string} targetVersion - Target engine version to upgrade to. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createUpgrade( + databaseId: string, + targetVersion: string, + ): Promise; + createUpgrade( + paramsOrFirst: { databaseId: string; targetVersion: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; targetVersion: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetVersion: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + targetVersion: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const targetVersion = params.targetVersion; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof targetVersion === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "targetVersion"', + ); + } + const apiPath = '/mysql/{databaseId}/upgrades'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof targetVersion !== 'undefined') { + apiPayload['targetVersion'] = targetVersion; + } + 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); + } +} diff --git a/src/services/oauth-2.ts b/src/services/oauth-2.ts index 4458be3b..b05acbdb 100644 --- a/src/services/oauth-2.ts +++ b/src/services/oauth-2.ts @@ -1,8 +1,6 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - - export class Oauth2 { client: Client; @@ -19,7 +17,11 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - approve(params: { grantId: string, authorizationDetails?: string, scope?: string }): Promise; + approve(params: { + grantId: string; + authorizationDetails?: string; + scope?: string; + }): Promise; /** * Approve an OAuth2 grant after the user gives consent. Returns the `redirectUrl` the end user should be sent to. The consent screen may optionally pass enriched `authorization_details` to record the concrete resources the user selected. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. * @@ -30,55 +32,71 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - approve(grantId: string, authorizationDetails?: string, scope?: string): Promise; approve( - paramsOrFirst: { grantId: string, authorizationDetails?: string, scope?: string } | string, - ...rest: [(string)?, (string)?] + grantId: string, + authorizationDetails?: string, + scope?: string, + ): Promise; + approve( + paramsOrFirst: + | { grantId: string; authorizationDetails?: string; scope?: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { grantId: string, authorizationDetails?: string, scope?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { grantId: string, authorizationDetails?: string, scope?: string }; + let params: { + grantId: string; + authorizationDetails?: string; + scope?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + grantId: string; + authorizationDetails?: string; + scope?: string; + }; } else { params = { grantId: paramsOrFirst as string, authorizationDetails: rest[0] as string, - scope: rest[1] as string + scope: rest[1] as string, }; } - + const grantId = params.grantId; const authorizationDetails = params.authorizationDetails; const scope = params.scope; - if (typeof grantId === 'undefined') { - throw new AppwriteException('Missing required parameter: "grantId"'); + throw new AppwriteException( + 'Missing required parameter: "grantId"', + ); } - - const apiPath = '/oauth2/{project_id}/approve'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); - const payload: Payload = {}; + const apiPath = '/oauth2/{project_id}/approve'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); + const apiPayload: Payload = {}; if (typeof grantId !== 'undefined') { - payload['grant_id'] = grantId; + apiPayload['grant_id'] = grantId; } if (typeof authorizationDetails !== 'undefined') { - payload['authorization_details'] = authorizationDetails; + apiPayload['authorization_details'] = authorizationDetails; } if (typeof scope !== 'undefined') { - payload['scope'] = scope; + apiPayload['scope'] = scope; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -101,7 +119,22 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - authorize(params?: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }): Promise; + authorize(params?: { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + }): Promise; /** * Begin the OAuth2 authorization flow. When called without a session, the user is redirected to the consent screen without grant ID. When called with a session, the redirect URL includes param for grant ID. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. * @@ -123,15 +156,96 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - authorize(clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string): Promise; authorize( - paramsOrFirst?: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (string)?, (string)?] + clientId?: string, + redirectUri?: string, + responseType?: string, + scope?: string, + state?: string, + nonce?: string, + codeChallenge?: string, + codeChallengeMethod?: string, + prompt?: string, + maxAge?: number, + authorizationDetails?: string, + resource?: string, + audience?: string, + requestUri?: string, + ): Promise; + authorize( + paramsOrFirst?: + | { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + number?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }; + let params: { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + }; } else { params = { clientId: paramsOrFirst as string, @@ -147,10 +261,10 @@ export class Oauth2 { authorizationDetails: rest[9] as string, resource: rest[10] as string, audience: rest[11] as string, - requestUri: rest[12] as string + requestUri: rest[12] as string, }; } - + const clientId = params.clientId; const redirectUri = params.redirectUri; const responseType = params.responseType; @@ -165,64 +279,60 @@ export class Oauth2 { const resource = params.resource; const audience = params.audience; const requestUri = params.requestUri; - - - const apiPath = '/oauth2/{project_id}/authorize'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); - const payload: Payload = {}; + const apiPath = '/oauth2/{project_id}/authorize'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['client_id'] = clientId; + apiPayload['client_id'] = clientId; } if (typeof redirectUri !== 'undefined') { - payload['redirect_uri'] = redirectUri; + apiPayload['redirect_uri'] = redirectUri; } if (typeof responseType !== 'undefined') { - payload['response_type'] = responseType; + apiPayload['response_type'] = responseType; } if (typeof scope !== 'undefined') { - payload['scope'] = scope; + apiPayload['scope'] = scope; } if (typeof state !== 'undefined') { - payload['state'] = state; + apiPayload['state'] = state; } if (typeof nonce !== 'undefined') { - payload['nonce'] = nonce; + apiPayload['nonce'] = nonce; } if (typeof codeChallenge !== 'undefined') { - payload['code_challenge'] = codeChallenge; + apiPayload['code_challenge'] = codeChallenge; } if (typeof codeChallengeMethod !== 'undefined') { - payload['code_challenge_method'] = codeChallengeMethod; + apiPayload['code_challenge_method'] = codeChallengeMethod; } if (typeof prompt !== 'undefined') { - payload['prompt'] = prompt; + apiPayload['prompt'] = prompt; } if (typeof maxAge !== 'undefined') { - payload['max_age'] = maxAge; + apiPayload['max_age'] = maxAge; } if (typeof authorizationDetails !== 'undefined') { - payload['authorization_details'] = authorizationDetails; + apiPayload['authorization_details'] = authorizationDetails; } if (typeof resource !== 'undefined') { - payload['resource'] = resource; + apiPayload['resource'] = resource; } if (typeof audience !== 'undefined') { - payload['audience'] = audience; + apiPayload['audience'] = audience; } if (typeof requestUri !== 'undefined') { - payload['request_uri'] = requestUri; + apiPayload['request_uri'] = requestUri; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -245,7 +355,22 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - authorizePost(params?: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }): Promise; + authorizePost(params?: { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + }): Promise; /** * Begin the OAuth2 authorization flow. When called without a session, the user is redirected to the consent screen without grant ID. When called with a session, the redirect URL includes param for grant ID. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. * @@ -267,15 +392,96 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - authorizePost(clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string): Promise; authorizePost( - paramsOrFirst?: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (string)?, (string)?] + clientId?: string, + redirectUri?: string, + responseType?: string, + scope?: string, + state?: string, + nonce?: string, + codeChallenge?: string, + codeChallengeMethod?: string, + prompt?: string, + maxAge?: number, + authorizationDetails?: string, + resource?: string, + audience?: string, + requestUri?: string, + ): Promise; + authorizePost( + paramsOrFirst?: + | { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + number?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }; + let params: { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + redirectUri?: string; + responseType?: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + requestUri?: string; + }; } else { params = { clientId: paramsOrFirst as string, @@ -291,10 +497,10 @@ export class Oauth2 { authorizationDetails: rest[9] as string, resource: rest[10] as string, audience: rest[11] as string, - requestUri: rest[12] as string + requestUri: rest[12] as string, }; } - + const clientId = params.clientId; const redirectUri = params.redirectUri; const responseType = params.responseType; @@ -309,65 +515,61 @@ export class Oauth2 { const resource = params.resource; const audience = params.audience; const requestUri = params.requestUri; - - - const apiPath = '/oauth2/{project_id}/authorize'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); - const payload: Payload = {}; + const apiPath = '/oauth2/{project_id}/authorize'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['client_id'] = clientId; + apiPayload['client_id'] = clientId; } if (typeof redirectUri !== 'undefined') { - payload['redirect_uri'] = redirectUri; + apiPayload['redirect_uri'] = redirectUri; } if (typeof responseType !== 'undefined') { - payload['response_type'] = responseType; + apiPayload['response_type'] = responseType; } if (typeof scope !== 'undefined') { - payload['scope'] = scope; + apiPayload['scope'] = scope; } if (typeof state !== 'undefined') { - payload['state'] = state; + apiPayload['state'] = state; } if (typeof nonce !== 'undefined') { - payload['nonce'] = nonce; + apiPayload['nonce'] = nonce; } if (typeof codeChallenge !== 'undefined') { - payload['code_challenge'] = codeChallenge; + apiPayload['code_challenge'] = codeChallenge; } if (typeof codeChallengeMethod !== 'undefined') { - payload['code_challenge_method'] = codeChallengeMethod; + apiPayload['code_challenge_method'] = codeChallengeMethod; } if (typeof prompt !== 'undefined') { - payload['prompt'] = prompt; + apiPayload['prompt'] = prompt; } if (typeof maxAge !== 'undefined') { - payload['max_age'] = maxAge; + apiPayload['max_age'] = maxAge; } if (typeof authorizationDetails !== 'undefined') { - payload['authorization_details'] = authorizationDetails; + apiPayload['authorization_details'] = authorizationDetails; } if (typeof resource !== 'undefined') { - payload['resource'] = resource; + apiPayload['resource'] = resource; } if (typeof audience !== 'undefined') { - payload['audience'] = audience; + apiPayload['audience'] = audience; } if (typeof requestUri !== 'undefined') { - payload['request_uri'] = requestUri; + apiPayload['request_uri'] = requestUri; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -381,7 +583,13 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - createDeviceAuthorization(params?: { clientId?: string, scope?: string, authorizationDetails?: string, resource?: string, audience?: string }): Promise; + createDeviceAuthorization(params?: { + clientId?: string; + scope?: string; + authorizationDetails?: string; + resource?: string; + audience?: string; + }): Promise; /** * Start the OAuth2 Device Authorization Grant. Returns the device code, user code, verification URL, expiration, and polling interval. * @@ -394,62 +602,89 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDeviceAuthorization(clientId?: string, scope?: string, authorizationDetails?: string, resource?: string, audience?: string): Promise; createDeviceAuthorization( - paramsOrFirst?: { clientId?: string, scope?: string, authorizationDetails?: string, resource?: string, audience?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?] + clientId?: string, + scope?: string, + authorizationDetails?: string, + resource?: string, + audience?: string, + ): Promise; + createDeviceAuthorization( + paramsOrFirst?: + | { + clientId?: string; + scope?: string; + authorizationDetails?: string; + resource?: string; + audience?: string; + } + | string, + ...rest: [string?, string?, string?, string?] ): Promise { - let params: { clientId?: string, scope?: string, authorizationDetails?: string, resource?: string, audience?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, scope?: string, authorizationDetails?: string, resource?: string, audience?: string }; + let params: { + clientId?: string; + scope?: string; + authorizationDetails?: string; + resource?: string; + audience?: string; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + scope?: string; + authorizationDetails?: string; + resource?: string; + audience?: string; + }; } else { params = { clientId: paramsOrFirst as string, scope: rest[0] as string, authorizationDetails: rest[1] as string, resource: rest[2] as string, - audience: rest[3] as string + audience: rest[3] as string, }; } - + const clientId = params.clientId; const scope = params.scope; const authorizationDetails = params.authorizationDetails; const resource = params.resource; const audience = params.audience; - - - const apiPath = '/oauth2/{project_id}/device_authorization'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); - const payload: Payload = {}; + const apiPath = '/oauth2/{project_id}/device_authorization'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['client_id'] = clientId; + apiPayload['client_id'] = clientId; } if (typeof scope !== 'undefined') { - payload['scope'] = scope; + apiPayload['scope'] = scope; } if (typeof authorizationDetails !== 'undefined') { - payload['authorization_details'] = authorizationDetails; + apiPayload['authorization_details'] = authorizationDetails; } if (typeof resource !== 'undefined') { - payload['resource'] = resource; + apiPayload['resource'] = resource; } if (typeof audience !== 'undefined') { - payload['audience'] = audience; + apiPayload['audience'] = audience; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -470,42 +705,44 @@ export class Oauth2 { */ createGrant(userCode: string): Promise; createGrant( - paramsOrFirst: { userCode: string } | string + paramsOrFirst: { userCode: string } | string, ): Promise { let params: { userCode: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userCode: string }; } else { params = { - userCode: paramsOrFirst as string + userCode: paramsOrFirst as string, }; } - - const userCode = params.userCode; + const userCode = params.userCode; if (typeof userCode === 'undefined') { - throw new AppwriteException('Missing required parameter: "userCode"'); + throw new AppwriteException( + 'Missing required parameter: "userCode"', + ); } - - const apiPath = '/oauth2/{project_id}/grants'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); - const payload: Payload = {}; + const apiPath = '/oauth2/{project_id}/grants'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); + const apiPayload: Payload = {}; if (typeof userCode !== 'undefined') { - payload['user_code'] = userCode; + apiPayload['user_code'] = userCode; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -526,38 +763,42 @@ export class Oauth2 { */ getGrant(grantId: string): Promise; getGrant( - paramsOrFirst: { grantId: string } | string + paramsOrFirst: { grantId: string } | string, ): Promise { let params: { grantId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { grantId: string }; } else { params = { - grantId: paramsOrFirst as string + grantId: paramsOrFirst as string, }; } - - const grantId = params.grantId; + const grantId = params.grantId; if (typeof grantId === 'undefined') { - throw new AppwriteException('Missing required parameter: "grantId"'); - } - - const apiPath = '/oauth2/{project_id}/grants/{grant_id}'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))).replace('{grant_id}', encodeURIComponent(String(grantId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "grantId"', + ); + } + const apiPath = '/oauth2/{project_id}/grants/{grant_id}' + .replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ) + .replace('{grant_id}', encodeURIComponent(String(grantId))); + const apiPayload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -569,7 +810,11 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - listOrganizations(params?: { limit?: number, offset?: number, search?: string }): Promise; + listOrganizations(params?: { + limit?: number; + offset?: number; + search?: string; + }): Promise; /** * 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. * @@ -580,51 +825,61 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listOrganizations(limit?: number, offset?: number, search?: string): Promise; listOrganizations( - paramsOrFirst?: { limit?: number, offset?: number, search?: string } | number, - ...rest: [(number)?, (string)?] + limit?: number, + offset?: number, + search?: string, + ): Promise; + listOrganizations( + paramsOrFirst?: + { limit?: number; offset?: number; search?: string } | number, + ...rest: [number?, string?] ): Promise { - let params: { limit?: number, offset?: number, search?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { limit?: number, offset?: number, search?: string }; + let params: { limit?: number; offset?: number; search?: string }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + limit?: number; + offset?: number; + search?: string; + }; } else { params = { limit: paramsOrFirst as number, offset: rest[0] as number, - search: rest[1] as string + search: rest[1] as string, }; } - + const limit = params.limit; const offset = params.offset; const search = params.search; - - - const apiPath = '/oauth2/{project_id}/organizations'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); - const payload: Payload = {}; + const apiPath = '/oauth2/{project_id}/organizations'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); + const apiPayload: Payload = {}; if (typeof limit !== 'undefined') { - payload['limit'] = limit; + apiPayload['limit'] = limit; } if (typeof offset !== 'undefined') { - payload['offset'] = offset; + apiPayload['offset'] = offset; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -646,7 +901,21 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - createPAR(params: { clientId: string, redirectUri: string, responseType: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string }): Promise; + createPAR(params: { + clientId: string; + redirectUri: string; + responseType: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + }): Promise; /** * Store an OAuth2 authorization request server-side and receive a short-lived request_uri handle for the authorize endpoint. * @@ -667,15 +936,90 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPAR(clientId: string, redirectUri: string, responseType: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string): Promise; createPAR( - paramsOrFirst: { clientId: string, redirectUri: string, responseType: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (string)?] + clientId: string, + redirectUri: string, + responseType: string, + scope?: string, + state?: string, + nonce?: string, + codeChallenge?: string, + codeChallengeMethod?: string, + prompt?: string, + maxAge?: number, + authorizationDetails?: string, + resource?: string, + audience?: string, + ): Promise; + createPAR( + paramsOrFirst: + | { + clientId: string; + redirectUri: string; + responseType: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + number?, + string?, + string?, + string?, + ] ): Promise { - let params: { clientId: string, redirectUri: string, responseType: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId: string, redirectUri: string, responseType: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string }; + let params: { + clientId: string; + redirectUri: string; + responseType: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + clientId: string; + redirectUri: string; + responseType: string; + scope?: string; + state?: string; + nonce?: string; + codeChallenge?: string; + codeChallengeMethod?: string; + prompt?: string; + maxAge?: number; + authorizationDetails?: string; + resource?: string; + audience?: string; + }; } else { params = { clientId: paramsOrFirst as string, @@ -690,10 +1034,10 @@ export class Oauth2 { maxAge: rest[8] as number, authorizationDetails: rest[9] as string, resource: rest[10] as string, - audience: rest[11] as string + audience: rest[11] as string, }; } - + const clientId = params.clientId; const redirectUri = params.redirectUri; const responseType = params.responseType; @@ -707,71 +1051,73 @@ export class Oauth2 { const authorizationDetails = params.authorizationDetails; const resource = params.resource; const audience = params.audience; - if (typeof clientId === 'undefined') { - throw new AppwriteException('Missing required parameter: "clientId"'); + throw new AppwriteException( + 'Missing required parameter: "clientId"', + ); } if (typeof redirectUri === 'undefined') { - throw new AppwriteException('Missing required parameter: "redirectUri"'); + throw new AppwriteException( + 'Missing required parameter: "redirectUri"', + ); } if (typeof responseType === 'undefined') { - throw new AppwriteException('Missing required parameter: "responseType"'); + throw new AppwriteException( + 'Missing required parameter: "responseType"', + ); } - - const apiPath = '/oauth2/{project_id}/par'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); - const payload: Payload = {}; + const apiPath = '/oauth2/{project_id}/par'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['client_id'] = clientId; + apiPayload['client_id'] = clientId; } if (typeof redirectUri !== 'undefined') { - payload['redirect_uri'] = redirectUri; + apiPayload['redirect_uri'] = redirectUri; } if (typeof responseType !== 'undefined') { - payload['response_type'] = responseType; + apiPayload['response_type'] = responseType; } if (typeof scope !== 'undefined') { - payload['scope'] = scope; + apiPayload['scope'] = scope; } if (typeof state !== 'undefined') { - payload['state'] = state; + apiPayload['state'] = state; } if (typeof nonce !== 'undefined') { - payload['nonce'] = nonce; + apiPayload['nonce'] = nonce; } if (typeof codeChallenge !== 'undefined') { - payload['code_challenge'] = codeChallenge; + apiPayload['code_challenge'] = codeChallenge; } if (typeof codeChallengeMethod !== 'undefined') { - payload['code_challenge_method'] = codeChallengeMethod; + apiPayload['code_challenge_method'] = codeChallengeMethod; } if (typeof prompt !== 'undefined') { - payload['prompt'] = prompt; + apiPayload['prompt'] = prompt; } if (typeof maxAge !== 'undefined') { - payload['max_age'] = maxAge; + apiPayload['max_age'] = maxAge; } if (typeof authorizationDetails !== 'undefined') { - payload['authorization_details'] = authorizationDetails; + apiPayload['authorization_details'] = authorizationDetails; } if (typeof resource !== 'undefined') { - payload['resource'] = resource; + apiPayload['resource'] = resource; } if (typeof audience !== 'undefined') { - payload['audience'] = audience; + apiPayload['audience'] = audience; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -783,7 +1129,11 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - listProjects(params?: { limit?: number, offset?: number, search?: string }): Promise; + listProjects(params?: { + limit?: number; + offset?: number; + search?: string; + }): Promise; /** * List the projects the OAuth2 access token can access. Resolves the token's `project` authorization details, expanding the `*` wildcard into the concrete set of projects the user can see. * @@ -794,51 +1144,61 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listProjects(limit?: number, offset?: number, search?: string): Promise; listProjects( - paramsOrFirst?: { limit?: number, offset?: number, search?: string } | number, - ...rest: [(number)?, (string)?] + limit?: number, + offset?: number, + search?: string, + ): Promise; + listProjects( + paramsOrFirst?: + { limit?: number; offset?: number; search?: string } | number, + ...rest: [number?, string?] ): Promise { - let params: { limit?: number, offset?: number, search?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { limit?: number, offset?: number, search?: string }; + let params: { limit?: number; offset?: number; search?: string }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + limit?: number; + offset?: number; + search?: string; + }; } else { params = { limit: paramsOrFirst as number, offset: rest[0] as number, - search: rest[1] as string + search: rest[1] as string, }; } - + const limit = params.limit; const offset = params.offset; const search = params.search; - - - const apiPath = '/oauth2/{project_id}/projects'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); - const payload: Payload = {}; + const apiPath = '/oauth2/{project_id}/projects'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); + const apiPayload: Payload = {}; if (typeof limit !== 'undefined') { - payload['limit'] = limit; + apiPayload['limit'] = limit; } if (typeof offset !== 'undefined') { - payload['offset'] = offset; + apiPayload['offset'] = offset; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -859,42 +1219,44 @@ export class Oauth2 { */ reject(grantId: string): Promise; reject( - paramsOrFirst: { grantId: string } | string + paramsOrFirst: { grantId: string } | string, ): Promise { let params: { grantId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { grantId: string }; } else { params = { - grantId: paramsOrFirst as string + grantId: paramsOrFirst as string, }; } - - const grantId = params.grantId; + const grantId = params.grantId; if (typeof grantId === 'undefined') { - throw new AppwriteException('Missing required parameter: "grantId"'); + throw new AppwriteException( + 'Missing required parameter: "grantId"', + ); } - - const apiPath = '/oauth2/{project_id}/reject'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); - const payload: Payload = {}; + const apiPath = '/oauth2/{project_id}/reject'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); + const apiPayload: Payload = {}; if (typeof grantId !== 'undefined') { - payload['grant_id'] = grantId; + apiPayload['grant_id'] = grantId; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -907,7 +1269,12 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise<{}>} */ - revoke(params: { token: string, tokenTypeHint?: string, clientId?: string, clientSecret?: string }): Promise<{}>; + revoke(params: { + token: string; + tokenTypeHint?: string; + clientId?: string; + clientSecret?: string; + }): Promise<{}>; /** * Revoke an OAuth2 access token or refresh token. * @@ -919,60 +1286,82 @@ export class Oauth2 { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - revoke(token: string, tokenTypeHint?: string, clientId?: string, clientSecret?: string): Promise<{}>; revoke( - paramsOrFirst: { token: string, tokenTypeHint?: string, clientId?: string, clientSecret?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + token: string, + tokenTypeHint?: string, + clientId?: string, + clientSecret?: string, + ): Promise<{}>; + revoke( + 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 }; + 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 + 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}/revoke'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); - const payload: Payload = {}; + const apiPath = '/oauth2/{project_id}/revoke'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); + const apiPayload: Payload = {}; if (typeof token !== 'undefined') { - payload['token'] = token; + apiPayload['token'] = token; } if (typeof tokenTypeHint !== 'undefined') { - payload['token_type_hint'] = tokenTypeHint; + apiPayload['token_type_hint'] = tokenTypeHint; } if (typeof clientId !== 'undefined') { - payload['client_id'] = clientId; + apiPayload['client_id'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['client_secret'] = clientSecret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -991,7 +1380,18 @@ export class Oauth2 { * @throws {AppwriteException} * @returns {Promise} */ - createToken(params: { grantType: string, code?: string, refreshToken?: string, deviceCode?: string, clientId?: string, clientSecret?: string, codeVerifier?: string, redirectUri?: string, resource?: string, audience?: string }): Promise; + createToken(params: { + grantType: string; + code?: string; + refreshToken?: string; + deviceCode?: string; + clientId?: string; + clientSecret?: string; + codeVerifier?: string; + redirectUri?: string; + resource?: string; + audience?: string; + }): Promise; /** * Exchange an OAuth2 authorization code, refresh token, or device code for access and refresh tokens. * @@ -1009,15 +1409,75 @@ export class Oauth2 { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createToken(grantType: string, code?: string, refreshToken?: string, deviceCode?: string, clientId?: string, clientSecret?: string, codeVerifier?: string, redirectUri?: string, resource?: string, audience?: string): Promise; createToken( - paramsOrFirst: { grantType: string, code?: string, refreshToken?: string, deviceCode?: string, clientId?: string, clientSecret?: string, codeVerifier?: string, redirectUri?: string, resource?: string, audience?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + grantType: string, + code?: string, + refreshToken?: string, + deviceCode?: string, + clientId?: string, + clientSecret?: string, + codeVerifier?: string, + redirectUri?: string, + resource?: string, + audience?: string, + ): Promise; + createToken( + paramsOrFirst: + | { + grantType: string; + code?: string; + refreshToken?: string; + deviceCode?: string; + clientId?: string; + clientSecret?: string; + codeVerifier?: string; + redirectUri?: string; + resource?: string; + audience?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { grantType: string, code?: string, refreshToken?: string, deviceCode?: string, clientId?: string, clientSecret?: string, codeVerifier?: string, redirectUri?: string, resource?: string, audience?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { grantType: string, code?: string, refreshToken?: string, deviceCode?: string, clientId?: string, clientSecret?: string, codeVerifier?: string, redirectUri?: string, resource?: string, audience?: string }; + let params: { + grantType: string; + code?: string; + refreshToken?: string; + deviceCode?: string; + clientId?: string; + clientSecret?: string; + codeVerifier?: string; + redirectUri?: string; + resource?: string; + audience?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + grantType: string; + code?: string; + refreshToken?: string; + deviceCode?: string; + clientId?: string; + clientSecret?: string; + codeVerifier?: string; + redirectUri?: string; + resource?: string; + audience?: string; + }; } else { params = { grantType: paramsOrFirst as string, @@ -1029,10 +1489,10 @@ export class Oauth2 { codeVerifier: rest[5] as string, redirectUri: rest[6] as string, resource: rest[7] as string, - audience: rest[8] as string + audience: rest[8] as string, }; } - + const grantType = params.grantType; const code = params.code; const refreshToken = params.refreshToken; @@ -1043,55 +1503,53 @@ export class Oauth2 { const redirectUri = params.redirectUri; const resource = params.resource; const audience = params.audience; - if (typeof grantType === 'undefined') { - throw new AppwriteException('Missing required parameter: "grantType"'); + throw new AppwriteException( + 'Missing required parameter: "grantType"', + ); } - - const apiPath = '/oauth2/{project_id}/token'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); - const payload: Payload = {}; + const apiPath = '/oauth2/{project_id}/token'.replace( + '{project_id}', + encodeURIComponent(String(this.client.config.project)), + ); + const apiPayload: Payload = {}; if (typeof grantType !== 'undefined') { - payload['grant_type'] = grantType; + apiPayload['grant_type'] = grantType; } if (typeof code !== 'undefined') { - payload['code'] = code; + apiPayload['code'] = code; } if (typeof refreshToken !== 'undefined') { - payload['refresh_token'] = refreshToken; + apiPayload['refresh_token'] = refreshToken; } if (typeof deviceCode !== 'undefined') { - payload['device_code'] = deviceCode; + apiPayload['device_code'] = deviceCode; } if (typeof clientId !== 'undefined') { - payload['client_id'] = clientId; + apiPayload['client_id'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['client_secret'] = clientSecret; + apiPayload['client_secret'] = clientSecret; } if (typeof codeVerifier !== 'undefined') { - payload['code_verifier'] = codeVerifier; + apiPayload['code_verifier'] = codeVerifier; } if (typeof redirectUri !== 'undefined') { - payload['redirect_uri'] = redirectUri; + apiPayload['redirect_uri'] = redirectUri; } if (typeof resource !== 'undefined') { - payload['resource'] = resource; + apiPayload['resource'] = resource; } if (typeof audience !== 'undefined') { - payload['audience'] = audience; + apiPayload['audience'] = audience; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } } diff --git a/src/services/organization.ts b/src/services/organization.ts index e2866085..a79629b9 100644 --- a/src/services/organization.ts +++ b/src/services/organization.ts @@ -1,10 +1,8 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - import { OrganizationKeyScopes } from '../enums/organization-key-scopes'; import { Region } from '../enums/region'; - export class Organization { client: Client; @@ -18,23 +16,19 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise>} */ - get(): Promise> { - + get< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(): Promise> { const apiPath = '/organization'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -44,7 +38,9 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise>} */ - update(params: { name: string }): Promise>; + update< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { name: string }): Promise>; /** * Update the current organization's name. * @@ -53,45 +49,44 @@ export class Organization { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - update(name: string): Promise>; update( - paramsOrFirst: { name: string } | string + name: string, + ): Promise>; + update( + paramsOrFirst: { name: string } | string, ): Promise> { let params: { name: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { name: string }; } else { params = { - name: paramsOrFirst as string + name: paramsOrFirst as string, }; } - - const name = params.name; + const name = params.name; if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/organization'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -101,22 +96,16 @@ export class Organization { * @returns {Promise<{}>} */ delete(): Promise<{}> { - const apiPath = '/organization'; - const payload: Payload = {}; + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -127,7 +116,10 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - listInstallations(params?: { queries?: string[], total?: boolean }): Promise; + listInstallations(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * List app installations on the organization. Any organization member can read installations. * @@ -137,47 +129,51 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listInstallations(queries?: string[], total?: boolean): Promise; listInstallations( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listInstallations( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/organization/installations'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -188,7 +184,10 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - createInstallation(params: { appId: string, authorizationDetails?: string }): Promise; + createInstallation(params: { + appId: string; + authorizationDetails?: string; + }): Promise; /** * Install an app on the organization. Only organization members with the owner role can install apps. The installation is granted the scopes the app currently requests. * @@ -198,51 +197,55 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createInstallation(appId: string, authorizationDetails?: string): Promise; createInstallation( - paramsOrFirst: { appId: string, authorizationDetails?: string } | string, - ...rest: [(string)?] + appId: string, + authorizationDetails?: string, + ): Promise; + createInstallation( + paramsOrFirst: + { appId: string; authorizationDetails?: string } | string, + ...rest: [string?] ): Promise { - let params: { appId: string, authorizationDetails?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId: string, authorizationDetails?: string }; + let params: { appId: string; authorizationDetails?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + appId: string; + authorizationDetails?: string; + }; } else { params = { appId: paramsOrFirst as string, - authorizationDetails: rest[0] as string + authorizationDetails: rest[0] as string, }; } - + const appId = params.appId; const authorizationDetails = params.authorizationDetails; - if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } - const apiPath = '/organization/installations'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof appId !== 'undefined') { - payload['appId'] = appId; + apiPayload['appId'] = appId; } if (typeof authorizationDetails !== 'undefined') { - payload['authorizationDetails'] = authorizationDetails; + apiPayload['authorizationDetails'] = authorizationDetails; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -252,7 +255,9 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - getInstallation(params: { installationId: string }): Promise; + getInstallation(params: { + installationId: string; + }): Promise; /** * Get an app installation on the organization by its unique ID. Any organization member can read installations. * @@ -263,39 +268,41 @@ export class Organization { */ getInstallation(installationId: string): Promise; getInstallation( - paramsOrFirst: { installationId: string } | string + paramsOrFirst: { installationId: string } | string, ): Promise { let params: { installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { installationId: string }; } else { params = { - installationId: paramsOrFirst as string + installationId: paramsOrFirst as string, }; } - - const installationId = params.installationId; + const installationId = params.installationId; if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } - - const apiPath = '/organization/installations/{installationId}'.replace('{installationId}', encodeURIComponent(String(installationId))); - const payload: Payload = {}; + const apiPath = '/organization/installations/{installationId}'.replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -306,7 +313,10 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - updateInstallation(params: { installationId: string, authorizationDetails?: string }): Promise; + updateInstallation(params: { + installationId: string; + authorizationDetails?: string; + }): Promise; /** * Update an app installation on the organization. Only organization members with the owner role can update installations. The installation's granted scopes are refreshed to the scopes the app currently requests; previously issued installation access tokens are revoked. * @@ -316,48 +326,57 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateInstallation(installationId: string, authorizationDetails?: string): Promise; updateInstallation( - paramsOrFirst: { installationId: string, authorizationDetails?: string } | string, - ...rest: [(string)?] + installationId: string, + authorizationDetails?: string, + ): Promise; + updateInstallation( + paramsOrFirst: + { installationId: string; authorizationDetails?: string } | string, + ...rest: [string?] ): Promise { - let params: { installationId: string, authorizationDetails?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { installationId: string, authorizationDetails?: string }; + let params: { installationId: string; authorizationDetails?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + installationId: string; + authorizationDetails?: string; + }; } else { params = { installationId: paramsOrFirst as string, - authorizationDetails: rest[0] as string + authorizationDetails: rest[0] as string, }; } - + const installationId = params.installationId; const authorizationDetails = params.authorizationDetails; - if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } - - const apiPath = '/organization/installations/{installationId}'.replace('{installationId}', encodeURIComponent(String(installationId))); - const payload: Payload = {}; + const apiPath = '/organization/installations/{installationId}'.replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); + const apiPayload: Payload = {}; if (typeof authorizationDetails !== 'undefined') { - payload['authorizationDetails'] = authorizationDetails; + apiPayload['authorizationDetails'] = authorizationDetails; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -378,40 +397,42 @@ export class Organization { */ deleteInstallation(installationId: string): Promise<{}>; deleteInstallation( - paramsOrFirst: { installationId: string } | string + paramsOrFirst: { installationId: string } | string, ): Promise<{}> { let params: { installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { installationId: string }; } else { params = { - installationId: paramsOrFirst as string + installationId: paramsOrFirst as string, }; } - - const installationId = params.installationId; + const installationId = params.installationId; if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); } - - const apiPath = '/organization/installations/{installationId}'.replace('{installationId}', encodeURIComponent(String(installationId))); - const payload: Payload = {}; + const apiPath = '/organization/installations/{installationId}'.replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -422,7 +443,10 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - listKeys(params?: { queries?: string[], total?: boolean }): Promise; + listKeys(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all API keys from the current organization. * @@ -434,45 +458,46 @@ export class Organization { */ listKeys(queries?: string[], total?: boolean): Promise; listKeys( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/organization/keys'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -485,7 +510,12 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - createKey(params: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }): Promise; + createKey(params: { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + }): Promise; /** * Create a new organization API key. * @@ -497,29 +527,54 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createKey(keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string): Promise; createKey( - paramsOrFirst: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string } | string, - ...rest: [(string)?, (OrganizationKeyScopes[])?, (string)?] + keyId: string, + name: string, + scopes: OrganizationKeyScopes[], + expire?: string, + ): Promise; + createKey( + paramsOrFirst: + | { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + } + | string, + ...rest: [string?, OrganizationKeyScopes[]?, string?] ): Promise { - let params: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }; + let params: { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + }; } else { params = { keyId: paramsOrFirst as string, name: rest[0] as string, scopes: rest[1] as OrganizationKeyScopes[], - expire: rest[2] as string + expire: rest[2] as string, }; } - + const keyId = params.keyId; const name = params.name; const scopes = params.scopes; const expire = params.expire; - if (typeof keyId === 'undefined') { throw new AppwriteException('Missing required parameter: "keyId"'); } @@ -529,35 +584,29 @@ export class Organization { if (typeof scopes === 'undefined') { throw new AppwriteException('Missing required parameter: "scopes"'); } - const apiPath = '/organization/keys'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof keyId !== 'undefined') { - payload['keyId'] = keyId; + apiPayload['keyId'] = keyId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof scopes !== 'undefined') { - payload['scopes'] = scopes; + apiPayload['scopes'] = scopes; } if (typeof expire !== 'undefined') { - payload['expire'] = expire; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -577,40 +626,38 @@ export class Organization { * @deprecated Use the object parameter style method for a better developer experience. */ getKey(keyId: string): Promise; - getKey( - paramsOrFirst: { keyId: string } | string - ): Promise { + getKey(paramsOrFirst: { keyId: string } | string): Promise { let params: { keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { keyId: string }; } else { params = { - keyId: paramsOrFirst as string + keyId: paramsOrFirst as string, }; } - - const keyId = params.keyId; + const keyId = params.keyId; if (typeof keyId === 'undefined') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/organization/keys/{keyId}'.replace('{keyId}', encodeURIComponent(String(keyId))); - const payload: Payload = {}; + const apiPath = '/organization/keys/{keyId}'.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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -623,7 +670,12 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - updateKey(params: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }): Promise; + updateKey(params: { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + }): Promise; /** * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. * @@ -635,29 +687,54 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateKey(keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string): Promise; updateKey( - paramsOrFirst: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string } | string, - ...rest: [(string)?, (OrganizationKeyScopes[])?, (string)?] + keyId: string, + name: string, + scopes: OrganizationKeyScopes[], + expire?: string, + ): Promise; + updateKey( + paramsOrFirst: + | { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + } + | string, + ...rest: [string?, OrganizationKeyScopes[]?, string?] ): Promise { - let params: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }; + let params: { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + keyId: string; + name: string; + scopes: OrganizationKeyScopes[]; + expire?: string; + }; } else { params = { keyId: paramsOrFirst as string, name: rest[0] as string, scopes: rest[1] as OrganizationKeyScopes[], - expire: rest[2] as string + expire: rest[2] as string, }; } - + const keyId = params.keyId; const name = params.name; const scopes = params.scopes; const expire = params.expire; - if (typeof keyId === 'undefined') { throw new AppwriteException('Missing required parameter: "keyId"'); } @@ -667,32 +744,29 @@ export class Organization { if (typeof scopes === 'undefined') { throw new AppwriteException('Missing required parameter: "scopes"'); } - - const apiPath = '/organization/keys/{keyId}'.replace('{keyId}', encodeURIComponent(String(keyId))); - const payload: Payload = {}; + const apiPath = '/organization/keys/{keyId}'.replace( + '{keyId}', + encodeURIComponent(String(keyId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof scopes !== 'undefined') { - payload['scopes'] = scopes; + apiPayload['scopes'] = scopes; } if (typeof expire !== 'undefined') { - payload['expire'] = expire; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -712,40 +786,38 @@ export class Organization { * @deprecated Use the object parameter style method for a better developer experience. */ deleteKey(keyId: string): Promise<{}>; - deleteKey( - paramsOrFirst: { keyId: string } | string - ): Promise<{}> { + deleteKey(paramsOrFirst: { keyId: string } | string): Promise<{}> { let params: { keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { keyId: string }; } else { params = { - keyId: paramsOrFirst as string + keyId: paramsOrFirst as string, }; } - - const keyId = params.keyId; + const keyId = params.keyId; if (typeof keyId === 'undefined') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/organization/keys/{keyId}'.replace('{keyId}', encodeURIComponent(String(keyId))); - const payload: Payload = {}; + const apiPath = '/organization/keys/{keyId}'.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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -757,7 +829,11 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - listMemberships(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listMemberships(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all memberships from the current organization. * @@ -768,52 +844,59 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listMemberships(queries?: string[], search?: string, total?: boolean): Promise; listMemberships( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listMemberships( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - - const apiPath = '/organization/memberships'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -828,7 +911,14 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - createMembership(params: { roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }): Promise; + createMembership(params: { + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: string; + }): Promise; /** * Invite a new member to join the current organization. An email with a link to join the organization will be sent to the new member's email address. If member doesn't exist in the project it will be automatically created. * @@ -842,15 +932,49 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMembership(roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string): Promise; createMembership( - paramsOrFirst: { roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string } | string[], - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?] + roles: string[], + email?: string, + userId?: string, + phone?: string, + url?: string, + name?: string, + ): Promise; + createMembership( + paramsOrFirst: + | { + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: string; + } + | string[], + ...rest: [string?, string?, string?, string?, string?] ): Promise { - let params: { roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }; + let params: { + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: string; + }; } else { params = { roles: paramsOrFirst as string[], @@ -858,55 +982,48 @@ export class Organization { userId: rest[1] as string, phone: rest[2] as string, url: rest[3] as string, - name: rest[4] as string + name: rest[4] as string, }; } - + const roles = params.roles; const email = params.email; const userId = params.userId; const phone = params.phone; const url = params.url; const name = params.name; - if (typeof roles === 'undefined') { throw new AppwriteException('Missing required parameter: "roles"'); } - const apiPath = '/organization/memberships'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof phone !== 'undefined') { - payload['phone'] = phone; + apiPayload['phone'] = phone; } if (typeof roles !== 'undefined') { - payload['roles'] = roles; + apiPayload['roles'] = roles; } if (typeof url !== 'undefined') { - payload['url'] = url; + apiPayload['url'] = url; } if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -927,39 +1044,41 @@ export class Organization { */ getMembership(membershipId: string): Promise; getMembership( - paramsOrFirst: { membershipId: string } | string + paramsOrFirst: { membershipId: string } | string, ): Promise { let params: { membershipId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { membershipId: string }; } else { params = { - membershipId: paramsOrFirst as string + membershipId: paramsOrFirst as string, }; } - - const membershipId = params.membershipId; + const membershipId = params.membershipId; if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); + throw new AppwriteException( + 'Missing required parameter: "membershipId"', + ); } - - const apiPath = '/organization/memberships/{membershipId}'.replace('{membershipId}', encodeURIComponent(String(membershipId))); - const payload: Payload = {}; + const apiPath = '/organization/memberships/{membershipId}'.replace( + '{membershipId}', + encodeURIComponent(String(membershipId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -970,7 +1089,10 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - updateMembership(params: { membershipId: string, roles: string[] }): Promise; + updateMembership(params: { + membershipId: string; + roles: string[]; + }): Promise; /** * Modify the roles of a member in the current organization. * @@ -980,51 +1102,59 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMembership(membershipId: string, roles: string[]): Promise; updateMembership( - paramsOrFirst: { membershipId: string, roles: string[] } | string, - ...rest: [(string[])?] + membershipId: string, + roles: string[], + ): Promise; + updateMembership( + paramsOrFirst: { membershipId: string; roles: string[] } | string, + ...rest: [string[]?] ): Promise { - let params: { membershipId: string, roles: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { membershipId: string, roles: string[] }; + let params: { membershipId: string; roles: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + membershipId: string; + roles: string[]; + }; } else { params = { membershipId: paramsOrFirst as string, - roles: rest[0] as string[] + roles: rest[0] as string[], }; } - + const membershipId = params.membershipId; const roles = params.roles; - if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); + throw new AppwriteException( + 'Missing required parameter: "membershipId"', + ); } if (typeof roles === 'undefined') { throw new AppwriteException('Missing required parameter: "roles"'); } - - const apiPath = '/organization/memberships/{membershipId}'.replace('{membershipId}', encodeURIComponent(String(membershipId))); - const payload: Payload = {}; + const apiPath = '/organization/memberships/{membershipId}'.replace( + '{membershipId}', + encodeURIComponent(String(membershipId)), + ); + const apiPayload: Payload = {}; if (typeof roles !== 'undefined') { - payload['roles'] = roles; + apiPayload['roles'] = roles; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1045,39 +1175,41 @@ export class Organization { */ deleteMembership(membershipId: string): Promise<{}>; deleteMembership( - paramsOrFirst: { membershipId: string } | string + paramsOrFirst: { membershipId: string } | string, ): Promise<{}> { let params: { membershipId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { membershipId: string }; } else { params = { - membershipId: paramsOrFirst as string + membershipId: paramsOrFirst as string, }; } - - const membershipId = params.membershipId; + const membershipId = params.membershipId; if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); + throw new AppwriteException( + 'Missing required parameter: "membershipId"', + ); } - - const apiPath = '/organization/memberships/{membershipId}'.replace('{membershipId}', encodeURIComponent(String(membershipId))); - const payload: Payload = {}; + const apiPath = '/organization/memberships/{membershipId}'.replace( + '{membershipId}', + encodeURIComponent(String(membershipId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1089,7 +1221,11 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - listProjects(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listProjects(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all projects. You can use the query params to filter your results. * @@ -1100,52 +1236,59 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listProjects(queries?: string[], search?: string, total?: boolean): Promise; listProjects( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listProjects( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - - const apiPath = '/organization/projects'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1157,7 +1300,11 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - createProject(params: { projectId: string, name: string, region?: Region }): Promise; + createProject(params: { + projectId: string; + name: string; + region?: Region; + }): Promise; /** * Create a new project. * @@ -1168,59 +1315,67 @@ export class Organization { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createProject(projectId: string, name: string, region?: Region): Promise; createProject( - paramsOrFirst: { projectId: string, name: string, region?: Region } | string, - ...rest: [(string)?, (Region)?] + projectId: string, + name: string, + region?: Region, + ): Promise; + createProject( + paramsOrFirst: + { projectId: string; name: string; region?: Region } | string, + ...rest: [string?, Region?] ): Promise { - let params: { projectId: string, name: string, region?: Region }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, name: string, region?: Region }; + let params: { projectId: string; name: string; region?: Region }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + name: string; + region?: Region; + }; } else { params = { projectId: paramsOrFirst as string, name: rest[0] as string, - region: rest[1] as Region + region: rest[1] as Region, }; } - + const projectId = params.projectId; const name = params.name; const region = params.region; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/organization/projects'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof projectId !== 'undefined') { - payload['projectId'] = projectId; + apiPayload['projectId'] = projectId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof region !== 'undefined') { - payload['region'] = region; + apiPayload['region'] = region; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1241,38 +1396,40 @@ export class Organization { */ getProject(projectId: string): Promise; getProject( - paramsOrFirst: { projectId: string } | string + paramsOrFirst: { projectId: string } | string, ): Promise { let params: { projectId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { projectId: string }; } else { params = { - projectId: paramsOrFirst as string + projectId: paramsOrFirst as string, }; } - - const projectId = params.projectId; + const projectId = params.projectId; if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - - const apiPath = '/organization/projects/{projectId}'.replace('{projectId}', encodeURIComponent(String(projectId))); - const payload: Payload = {}; + const apiPath = '/organization/projects/{projectId}'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); + const apiPayload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - } + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1283,7 +1440,10 @@ export class Organization { * @throws {AppwriteException} * @returns {Promise} */ - updateProject(params: { projectId: string, name: string }): Promise; + updateProject(params: { + projectId: string; + name: string; + }): Promise; /** * Update a project by its unique ID. * @@ -1295,49 +1455,54 @@ export class Organization { */ updateProject(projectId: string, name: string): Promise; updateProject( - paramsOrFirst: { projectId: string, name: string } | string, - ...rest: [(string)?] + paramsOrFirst: { projectId: string; name: string } | string, + ...rest: [string?] ): Promise { - let params: { projectId: string, name: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, name: string }; + let params: { projectId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + projectId: string; + name: string; + }; } else { params = { projectId: paramsOrFirst as string, - name: rest[0] as string + name: rest[0] as string, }; } - + const projectId = params.projectId; const name = params.name; - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/organization/projects/{projectId}'.replace('{projectId}', encodeURIComponent(String(projectId))); - const payload: Payload = {}; + const apiPath = '/organization/projects/{projectId}'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1357,39 +1522,39 @@ export class Organization { * @deprecated Use the object parameter style method for a better developer experience. */ deleteProject(projectId: string): Promise<{}>; - deleteProject( - paramsOrFirst: { projectId: string } | string - ): Promise<{}> { + deleteProject(paramsOrFirst: { projectId: string } | string): Promise<{}> { let params: { projectId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { projectId: string }; } else { params = { - projectId: paramsOrFirst as string + projectId: paramsOrFirst as string, }; } - - const projectId = params.projectId; + const projectId = params.projectId; if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); + throw new AppwriteException( + 'Missing required parameter: "projectId"', + ); } - - const apiPath = '/organization/projects/{projectId}'.replace('{projectId}', encodeURIComponent(String(projectId))); - const payload: Payload = {}; + const apiPath = '/organization/projects/{projectId}'.replace( + '{projectId}', + encodeURIComponent(String(projectId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } } diff --git a/src/services/postgresql.ts b/src/services/postgresql.ts new file mode 100644 index 00000000..414d7be2 --- /dev/null +++ b/src/services/postgresql.ts @@ -0,0 +1,3477 @@ +import { AppwriteException, Client, type Payload } from '../client'; +import type { Models } from '../models'; + +export class Postgresql { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List all dedicated databases. Results support pagination. + * + * @param {string[]} params.queries - Array of query strings. + * @throws {AppwriteException} + * @returns {Promise} + */ + list(params?: { + queries?: string[]; + }): Promise; + /** + * List all dedicated databases. Results support pagination. + * + * @param {string[]} queries - Array of query strings. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(queries?: string[]): Promise; + list( + paramsOrFirst?: { queries?: string[] } | string[], + ): Promise { + let params: { queries?: string[] }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[], + }; + } + + const queries = params.queries; + const apiPath = '/postgresql'; + 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 dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. + * + * @param {string} params.databaseId - Database 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 - Database display name. Max length: 128 chars. + * @param {string} params.version - Database engine version. Defaults to latest for selected engine. + * @param {string} params.specification - Specification identifier. Drives the allocated CPU, memory, storage, storage class, and connection ceiling. + * @param {number} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds. + * @param {string[]} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number} params.idleTimeoutMinutes - Minutes of inactivity before container scales to zero. + * @param {boolean} params.pitr - Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. + * @param {number} params.pitrRetentionDays - Number of days to retain PITR data. + * @param {boolean} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @throws {AppwriteException} + * @returns {Promise} + */ + create(params: { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }): Promise; + /** + * Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. + * + * @param {string} databaseId - Database 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 - Database display name. Max length: 128 chars. + * @param {string} version - Database engine version. Defaults to latest for selected engine. + * @param {string} specification - Specification identifier. Drives the allocated CPU, memory, storage, storage class, and connection ceiling. + * @param {number} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number} networkIdleTimeoutSeconds - Connection idle timeout in seconds. + * @param {string[]} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number} idleTimeoutMinutes - Minutes of inactivity before container scales to zero. + * @param {boolean} pitr - Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. + * @param {number} pitrRetentionDays - Number of days to retain PITR data. + * @param {boolean} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create( + databaseId: string, + name: string, + version?: string, + specification?: string, + replicas?: number, + syncMode?: string, + networkIdleTimeoutSeconds?: number, + networkIPAllowlist?: string[], + idleTimeoutMinutes?: number, + pitr?: boolean, + pitrRetentionDays?: number, + storageAutoscaling?: boolean, + storageAutoscalingThresholdPercent?: number, + storageAutoscalingMaxGb?: number, + ): Promise; + create( + paramsOrFirst: + | { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + string?, + number?, + string[]?, + number?, + boolean?, + number?, + boolean?, + number?, + number?, + ] + ): Promise { + let params: { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + version?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + version: rest[1] as string, + specification: rest[2] as string, + replicas: rest[3] as number, + syncMode: rest[4] as string, + networkIdleTimeoutSeconds: rest[5] as number, + networkIPAllowlist: rest[6] as string[], + idleTimeoutMinutes: rest[7] as number, + pitr: rest[8] as boolean, + pitrRetentionDays: rest[9] as number, + storageAutoscaling: rest[10] as boolean, + storageAutoscalingThresholdPercent: rest[11] as number, + storageAutoscalingMaxGb: rest[12] as number, + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const version = params.version; + const specification = params.specification; + const replicas = params.replicas; + const syncMode = params.syncMode; + const networkIdleTimeoutSeconds = params.networkIdleTimeoutSeconds; + const networkIPAllowlist = params.networkIPAllowlist; + const idleTimeoutMinutes = params.idleTimeoutMinutes; + const pitr = params.pitr; + const pitrRetentionDays = params.pitrRetentionDays; + const storageAutoscaling = params.storageAutoscaling; + const storageAutoscalingThresholdPercent = + params.storageAutoscalingThresholdPercent; + const storageAutoscalingMaxGb = params.storageAutoscalingMaxGb; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/postgresql'; + const apiPayload: Payload = {}; + if (typeof databaseId !== 'undefined') { + apiPayload['databaseId'] = databaseId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof version !== 'undefined') { + apiPayload['version'] = version; + } + if (typeof specification !== 'undefined') { + apiPayload['specification'] = specification; + } + if (typeof replicas !== 'undefined') { + apiPayload['replicas'] = replicas; + } + if (typeof syncMode !== 'undefined') { + apiPayload['syncMode'] = syncMode; + } + if (typeof networkIdleTimeoutSeconds !== 'undefined') { + apiPayload['networkIdleTimeoutSeconds'] = networkIdleTimeoutSeconds; + } + if (typeof networkIPAllowlist !== 'undefined') { + apiPayload['networkIPAllowlist'] = networkIPAllowlist; + } + if (typeof idleTimeoutMinutes !== 'undefined') { + apiPayload['idleTimeoutMinutes'] = idleTimeoutMinutes; + } + if (typeof pitr !== 'undefined') { + apiPayload['pitr'] = pitr; + } + if (typeof pitrRetentionDays !== 'undefined') { + apiPayload['pitrRetentionDays'] = pitrRetentionDays; + } + if (typeof storageAutoscaling !== 'undefined') { + apiPayload['storageAutoscaling'] = storageAutoscaling; + } + if (typeof storageAutoscalingThresholdPercent !== 'undefined') { + apiPayload['storageAutoscalingThresholdPercent'] = + storageAutoscalingThresholdPercent; + } + if (typeof storageAutoscalingMaxGb !== 'undefined') { + apiPayload['storageAutoscalingMaxGb'] = storageAutoscalingMaxGb; + } + 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 the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + listSpecifications(): Promise { + const apiPath = '/postgresql/specifications'; + 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); + } + + /** + * Get a dedicated database by its unique ID. Returns the database configuration and current status. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + get(params: { databaseId: string }): Promise; + /** + * Get a dedicated database by its unique ID. Returns the database configuration and current status. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(databaseId: string): Promise; + get( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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 dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.name - Database display name. + * @param {string} params.status - Database status. Allowed values: ready, paused, inactive. Set to "paused" to pause, "ready" to resume (also recovers a failed database whose infrastructure is healthy), or "inactive" to spin down a shared-pool database. + * @param {string} params.specification - Specification. Changes cpu, memory, storage, connection ceiling, and node pool based on specification config. Resource changes are applied via rolling cutover with zero downtime. + * @param {number} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[]} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[]} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). + * @throws {AppwriteException} + * @returns {Promise} + */ + update(params: { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }): Promise; + /** + * Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. + * + * @param {string} databaseId - Database ID. + * @param {string} name - Database display name. + * @param {string} status - Database status. Allowed values: ready, paused, inactive. Set to "paused" to pause, "ready" to resume (also recovers a failed database whose infrastructure is healthy), or "inactive" to spin down a shared-pool database. + * @param {string} specification - Specification. Changes cpu, memory, storage, connection ceiling, and node pool based on specification config. Resource changes are applied via rolling cutover with zero downtime. + * @param {number} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[]} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number} pitrRetentionDays - Days to retain PITR data. + * @param {boolean} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[]} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update( + databaseId: string, + name?: string, + status?: string, + specification?: string, + replicas?: number, + syncMode?: string, + networkIdleTimeoutSeconds?: number, + networkIPAllowlist?: string[], + idleTimeoutMinutes?: number, + pitr?: boolean, + pitrRetentionDays?: number, + storageAutoscaling?: boolean, + storageAutoscalingThresholdPercent?: number, + storageAutoscalingMaxGb?: number, + metricsTraceSampleRate?: number, + metricsSlowQueryLogThresholdMs?: number, + sqlApiEnabled?: boolean, + sqlApiAllowedStatements?: string[], + sqlApiMaxRows?: number, + sqlApiMaxBytes?: number, + sqlApiTimeoutSeconds?: number, + ): Promise; + update( + paramsOrFirst: + | { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + string?, + number?, + string[]?, + number?, + boolean?, + number?, + boolean?, + number?, + number?, + number?, + number?, + boolean?, + string[]?, + number?, + number?, + number?, + ] + ): Promise { + let params: { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name?: string; + status?: string; + specification?: string; + replicas?: number; + syncMode?: string; + networkIdleTimeoutSeconds?: number; + networkIPAllowlist?: string[]; + idleTimeoutMinutes?: number; + pitr?: boolean; + pitrRetentionDays?: number; + storageAutoscaling?: boolean; + storageAutoscalingThresholdPercent?: number; + storageAutoscalingMaxGb?: number; + metricsTraceSampleRate?: number; + metricsSlowQueryLogThresholdMs?: number; + sqlApiEnabled?: boolean; + sqlApiAllowedStatements?: string[]; + sqlApiMaxRows?: number; + sqlApiMaxBytes?: number; + sqlApiTimeoutSeconds?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + status: rest[1] as string, + specification: rest[2] as string, + replicas: rest[3] as number, + syncMode: rest[4] as string, + networkIdleTimeoutSeconds: rest[5] as number, + networkIPAllowlist: rest[6] as string[], + idleTimeoutMinutes: rest[7] as number, + pitr: rest[8] as boolean, + pitrRetentionDays: rest[9] as number, + storageAutoscaling: rest[10] as boolean, + storageAutoscalingThresholdPercent: rest[11] as number, + storageAutoscalingMaxGb: rest[12] as number, + metricsTraceSampleRate: rest[13] as number, + metricsSlowQueryLogThresholdMs: rest[14] as number, + sqlApiEnabled: rest[15] as boolean, + sqlApiAllowedStatements: rest[16] as string[], + sqlApiMaxRows: rest[17] as number, + sqlApiMaxBytes: rest[18] as number, + sqlApiTimeoutSeconds: rest[19] as number, + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const status = params.status; + const specification = params.specification; + const replicas = params.replicas; + const syncMode = params.syncMode; + const networkIdleTimeoutSeconds = params.networkIdleTimeoutSeconds; + const networkIPAllowlist = params.networkIPAllowlist; + const idleTimeoutMinutes = params.idleTimeoutMinutes; + const pitr = params.pitr; + const pitrRetentionDays = params.pitrRetentionDays; + const storageAutoscaling = params.storageAutoscaling; + const storageAutoscalingThresholdPercent = + params.storageAutoscalingThresholdPercent; + const storageAutoscalingMaxGb = params.storageAutoscalingMaxGb; + const metricsTraceSampleRate = params.metricsTraceSampleRate; + const metricsSlowQueryLogThresholdMs = + params.metricsSlowQueryLogThresholdMs; + const sqlApiEnabled = params.sqlApiEnabled; + const sqlApiAllowedStatements = params.sqlApiAllowedStatements; + const sqlApiMaxRows = params.sqlApiMaxRows; + const sqlApiMaxBytes = params.sqlApiMaxBytes; + const sqlApiTimeoutSeconds = params.sqlApiTimeoutSeconds; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof status !== 'undefined') { + apiPayload['status'] = status; + } + if (typeof specification !== 'undefined') { + apiPayload['specification'] = specification; + } + if (typeof replicas !== 'undefined') { + apiPayload['replicas'] = replicas; + } + if (typeof syncMode !== 'undefined') { + apiPayload['syncMode'] = syncMode; + } + if (typeof networkIdleTimeoutSeconds !== 'undefined') { + apiPayload['networkIdleTimeoutSeconds'] = networkIdleTimeoutSeconds; + } + if (typeof networkIPAllowlist !== 'undefined') { + apiPayload['networkIPAllowlist'] = networkIPAllowlist; + } + if (typeof idleTimeoutMinutes !== 'undefined') { + apiPayload['idleTimeoutMinutes'] = idleTimeoutMinutes; + } + if (typeof pitr !== 'undefined') { + apiPayload['pitr'] = pitr; + } + if (typeof pitrRetentionDays !== 'undefined') { + apiPayload['pitrRetentionDays'] = pitrRetentionDays; + } + if (typeof storageAutoscaling !== 'undefined') { + apiPayload['storageAutoscaling'] = storageAutoscaling; + } + if (typeof storageAutoscalingThresholdPercent !== 'undefined') { + apiPayload['storageAutoscalingThresholdPercent'] = + storageAutoscalingThresholdPercent; + } + if (typeof storageAutoscalingMaxGb !== 'undefined') { + apiPayload['storageAutoscalingMaxGb'] = storageAutoscalingMaxGb; + } + if (typeof metricsTraceSampleRate !== 'undefined') { + apiPayload['metricsTraceSampleRate'] = metricsTraceSampleRate; + } + if (typeof metricsSlowQueryLogThresholdMs !== 'undefined') { + apiPayload['metricsSlowQueryLogThresholdMs'] = + metricsSlowQueryLogThresholdMs; + } + if (typeof sqlApiEnabled !== 'undefined') { + apiPayload['sqlApiEnabled'] = sqlApiEnabled; + } + if (typeof sqlApiAllowedStatements !== 'undefined') { + apiPayload['sqlApiAllowedStatements'] = sqlApiAllowedStatements; + } + if (typeof sqlApiMaxRows !== 'undefined') { + apiPayload['sqlApiMaxRows'] = sqlApiMaxRows; + } + if (typeof sqlApiMaxBytes !== 'undefined') { + apiPayload['sqlApiMaxBytes'] = sqlApiMaxBytes; + } + if (typeof sqlApiTimeoutSeconds !== 'undefined') { + apiPayload['sqlApiTimeoutSeconds'] = sqlApiTimeoutSeconds; + } + 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 a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { databaseId: string }): Promise<{}>; + /** + * Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(databaseId: string): Promise<{}>; + delete(paramsOrFirst: { databaseId: string } | string): Promise<{}> { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * List all backups for a dedicated database. Results can be filtered by status and type. + * + * @param {string} params.databaseId - Database 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: status, type, databaseId + * @throws {AppwriteException} + * @returns {Promise} + */ + listBackups(params: { + databaseId: string; + queries?: string[]; + }): Promise; + /** + * List all backups for a dedicated database. Results can be filtered by status and type. + * + * @param {string} databaseId - Database 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: status, type, databaseId + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listBackups( + databaseId: string, + queries?: string[], + ): Promise; + listBackups( + paramsOrFirst: { databaseId: string; queries?: string[] } | string, + ...rest: [string[]?] + ): Promise { + let params: { databaseId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + queries: rest[0] as string[], + }; + } + + const databaseId = params.databaseId; + const queries = params.queries; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/backups'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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 manual backup of a dedicated database. The backup will be created asynchronously and its status can be checked via the get backup endpoint. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.type - Backup type: full or incremental. + * @throws {AppwriteException} + * @returns {Promise} + */ + createBackup(params: { + databaseId: string; + type?: string; + }): Promise; + /** + * Create a manual backup of a dedicated database. The backup will be created asynchronously and its status can be checked via the get backup endpoint. + * + * @param {string} databaseId - Database ID. + * @param {string} type - Backup type: full or incremental. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBackup( + databaseId: string, + type?: string, + ): Promise; + createBackup( + paramsOrFirst: { databaseId: string; type?: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; type?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + type?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + type: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const type = params.type; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/backups'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof type !== 'undefined') { + apiPayload['type'] = type; + } + 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 scheduled backup policies for a dedicated database. + * + * @param {string} params.databaseId - Database ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. + * @throws {AppwriteException} + * @returns {Promise} + */ + listBackupPolicies(params: { + databaseId: string; + queries?: string[]; + }): Promise; + /** + * List scheduled backup policies for a dedicated database. + * + * @param {string} databaseId - Database ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listBackupPolicies( + databaseId: string, + queries?: string[], + ): Promise; + listBackupPolicies( + paramsOrFirst: { databaseId: string; queries?: string[] } | string, + ...rest: [string[]?] + ): Promise { + let params: { databaseId: string; queries?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + queries: rest[0] as string[], + }; + } + + const databaseId = params.databaseId; + const queries = params.queries; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/backups/policies'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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 scheduled backup policy for a dedicated database. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.policyId - Policy 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 - Policy name. Max length: 128 chars. + * @param {string} params.schedule - Schedule CRON syntax. + * @param {number} params.retention - Days to keep backups before deletion. + * @param {string} params.type - Backup type: full or incremental. + * @param {boolean} params.enabled - Is policy enabled? When disabled, no backups will be taken. + * @throws {AppwriteException} + * @returns {Promise} + */ + createBackupPolicy(params: { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }): Promise; + /** + * Create a scheduled backup policy for a dedicated database. + * + * @param {string} databaseId - Database ID. + * @param {string} policyId - Policy 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 - Policy name. Max length: 128 chars. + * @param {string} schedule - Schedule CRON syntax. + * @param {number} retention - Days to keep backups before deletion. + * @param {string} type - Backup type: full or incremental. + * @param {boolean} enabled - Is policy enabled? When disabled, no backups will be taken. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBackupPolicy( + databaseId: string, + policyId: string, + name: string, + schedule: string, + retention: number, + type?: string, + enabled?: boolean, + ): Promise; + createBackupPolicy( + paramsOrFirst: + | { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, number?, string?, boolean?] + ): Promise { + let params: { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + name: string; + schedule: string; + retention: number; + type?: string; + enabled?: boolean; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + policyId: rest[0] as string, + name: rest[1] as string, + schedule: rest[2] as string, + retention: rest[3] as number, + type: rest[4] as string, + enabled: rest[5] as boolean, + }; + } + + const databaseId = params.databaseId; + const policyId = params.policyId; + const name = params.name; + const schedule = params.schedule; + const retention = params.retention; + const type = params.type; + const enabled = params.enabled; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof policyId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof schedule === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "schedule"', + ); + } + if (typeof retention === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "retention"', + ); + } + const apiPath = '/postgresql/{databaseId}/backups/policies'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof policyId !== 'undefined') { + apiPayload['policyId'] = policyId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof schedule !== 'undefined') { + apiPayload['schedule'] = schedule; + } + if (typeof retention !== 'undefined') { + apiPayload['retention'] = retention; + } + if (typeof type !== 'undefined') { + apiPayload['type'] = type; + } + 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('post', uri, apiHeaders, apiPayload); + } + + /** + * Get a scheduled backup policy for a dedicated database. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.policyId - Policy ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getBackupPolicy(params: { + databaseId: string; + policyId: string; + }): Promise; + /** + * Get a scheduled backup policy for a dedicated database. + * + * @param {string} databaseId - Database ID. + * @param {string} policyId - Policy ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getBackupPolicy( + databaseId: string, + policyId: string, + ): Promise; + getBackupPolicy( + paramsOrFirst: { databaseId: string; policyId: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; policyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + policyId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const policyId = params.policyId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof policyId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); + } + const apiPath = '/postgresql/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); + 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 scheduled backup policy for a dedicated database. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.policyId - Policy ID. + * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string} params.schedule - Schedule CRON syntax. + * @param {number} params.retention - Days to keep backups before deletion. + * @param {boolean} params.enabled - Is policy enabled? When disabled, no backups will be taken. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateBackupPolicy(params: { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }): Promise; + /** + * Update a scheduled backup policy for a dedicated database. + * + * @param {string} databaseId - Database ID. + * @param {string} policyId - Policy ID. + * @param {string} name - Policy name. Max length: 128 chars. + * @param {string} schedule - Schedule CRON syntax. + * @param {number} retention - Days to keep backups before deletion. + * @param {boolean} enabled - Is policy enabled? When disabled, no backups will be taken. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBackupPolicy( + databaseId: string, + policyId: string, + name?: string, + schedule?: string, + retention?: number, + enabled?: boolean, + ): Promise; + updateBackupPolicy( + paramsOrFirst: + | { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, number?, boolean?] + ): Promise { + let params: { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + name?: string; + schedule?: string; + retention?: number; + enabled?: boolean; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + policyId: rest[0] as string, + name: rest[1] as string, + schedule: rest[2] as string, + retention: rest[3] as number, + enabled: rest[4] as boolean, + }; + } + + const databaseId = params.databaseId; + const policyId = params.policyId; + const name = params.name; + const schedule = params.schedule; + const retention = params.retention; + const enabled = params.enabled; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof policyId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); + } + const apiPath = '/postgresql/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof schedule !== 'undefined') { + apiPayload['schedule'] = schedule; + } + if (typeof retention !== 'undefined') { + apiPayload['retention'] = retention; + } + 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); + } + + /** + * Delete a scheduled backup policy for a dedicated database. Backups already taken by the policy are kept until their retention expires. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.policyId - Policy ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteBackupPolicy(params: { + databaseId: string; + policyId: string; + }): Promise<{}>; + /** + * Delete a scheduled backup policy for a dedicated database. Backups already taken by the policy are kept until their retention expires. + * + * @param {string} databaseId - Database ID. + * @param {string} policyId - Policy ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteBackupPolicy(databaseId: string, policyId: string): Promise<{}>; + deleteBackupPolicy( + paramsOrFirst: { databaseId: string; policyId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { databaseId: string; policyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + policyId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + policyId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const policyId = params.policyId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof policyId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); + } + const apiPath = '/postgresql/{databaseId}/backups/policies/{policyId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{policyId}', encodeURIComponent(String(policyId))); + 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); + } + + /** + * Configure off-cluster backup storage for a dedicated database. Supports S3, GCS, and Azure Blob Storage destinations. Backups will be stored to the configured destination in addition to on-cluster storage. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.provider - Storage provider for off-cluster backups. Allowed values: s3 (Amazon S3 or S3-compatible), gcs (Google Cloud Storage), azure (Azure Blob Storage). + * @param {string} params.bucket - Storage bucket or container name. + * @param {string} params.accessKey - Access key or client ID for authentication. + * @param {string} params.secretKey - Secret key or service account JSON for authentication. + * @param {string} params.region - Storage region. + * @param {string} params.prefix - Object key prefix for backups. + * @param {string} params.endpoint - Custom endpoint for S3-compatible storage (e.g. MinIO). + * @throws {AppwriteException} + * @returns {Promise} + */ + updateBackupStorage(params: { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }): Promise; + /** + * Configure off-cluster backup storage for a dedicated database. Supports S3, GCS, and Azure Blob Storage destinations. Backups will be stored to the configured destination in addition to on-cluster storage. + * + * @param {string} databaseId - Database ID. + * @param {string} provider - Storage provider for off-cluster backups. Allowed values: s3 (Amazon S3 or S3-compatible), gcs (Google Cloud Storage), azure (Azure Blob Storage). + * @param {string} bucket - Storage bucket or container name. + * @param {string} accessKey - Access key or client ID for authentication. + * @param {string} secretKey - Secret key or service account JSON for authentication. + * @param {string} region - Storage region. + * @param {string} prefix - Object key prefix for backups. + * @param {string} endpoint - Custom endpoint for S3-compatible storage (e.g. MinIO). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBackupStorage( + databaseId: string, + provider: string, + bucket: string, + accessKey: string, + secretKey: string, + region?: string, + prefix?: string, + endpoint?: string, + ): Promise; + updateBackupStorage( + paramsOrFirst: + | { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + } + | string, + ...rest: [string?, string?, string?, string?, string?, string?, string?] + ): Promise { + let params: { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + provider: string; + bucket: string; + accessKey: string; + secretKey: string; + region?: string; + prefix?: string; + endpoint?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + provider: rest[0] as string, + bucket: rest[1] as string, + accessKey: rest[2] as string, + secretKey: rest[3] as string, + region: rest[4] as string, + prefix: rest[5] as string, + endpoint: rest[6] as string, + }; + } + + const databaseId = params.databaseId; + const provider = params.provider; + const bucket = params.bucket; + const accessKey = params.accessKey; + const secretKey = params.secretKey; + const region = params.region; + const prefix = params.prefix; + const endpoint = params.endpoint; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof provider === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "provider"', + ); + } + if (typeof bucket === 'undefined') { + throw new AppwriteException('Missing required parameter: "bucket"'); + } + if (typeof accessKey === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "accessKey"', + ); + } + if (typeof secretKey === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "secretKey"', + ); + } + const apiPath = '/postgresql/{databaseId}/backups/storage'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof provider !== 'undefined') { + apiPayload['provider'] = provider; + } + if (typeof bucket !== 'undefined') { + apiPayload['bucket'] = bucket; + } + if (typeof region !== 'undefined') { + apiPayload['region'] = region; + } + if (typeof prefix !== 'undefined') { + apiPayload['prefix'] = prefix; + } + if (typeof endpoint !== 'undefined') { + apiPayload['endpoint'] = endpoint; + } + if (typeof accessKey !== 'undefined') { + apiPayload['accessKey'] = accessKey; + } + if (typeof secretKey !== 'undefined') { + apiPayload['secretKey'] = secretKey; + } + 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 details of a specific database backup including its status, size, and timestamps. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.backupId - Backup ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getBackup(params: { + databaseId: string; + backupId: string; + }): Promise; + /** + * Get details of a specific database backup including its status, size, and timestamps. + * + * @param {string} databaseId - Database ID. + * @param {string} backupId - Backup ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getBackup( + databaseId: string, + backupId: string, + ): Promise; + getBackup( + paramsOrFirst: { databaseId: string; backupId: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; backupId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + backupId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + backupId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const backupId = params.backupId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof backupId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "backupId"', + ); + } + const apiPath = '/postgresql/{databaseId}/backups/{backupId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{backupId}', encodeURIComponent(String(backupId))); + 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 database backup. This will permanently remove the backup from storage and cannot be undone. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.backupId - Backup ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteBackup(params: { databaseId: string; backupId: string }): Promise<{}>; + /** + * Delete a database backup. This will permanently remove the backup from storage and cannot be undone. + * + * @param {string} databaseId - Database ID. + * @param {string} backupId - Backup ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteBackup(databaseId: string, backupId: string): Promise<{}>; + deleteBackup( + paramsOrFirst: { databaseId: string; backupId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { databaseId: string; backupId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + backupId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + backupId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const backupId = params.backupId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof backupId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "backupId"', + ); + } + const apiPath = '/postgresql/{databaseId}/backups/{backupId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{backupId}', encodeURIComponent(String(backupId))); + 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); + } + + /** + * List all ephemeral branches for a dedicated database. Returns branch metadata including ID, name, namespace, and expiration time. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + listBranches(params: { + databaseId: string; + }): Promise; + /** + * List all ephemeral branches for a dedicated database. Returns branch metadata including ID, name, namespace, and expiration time. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listBranches( + databaseId: string, + ): Promise; + listBranches( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/branches'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.branchId - Branch 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 {number} params.ttl - Time-to-live in seconds before the branch expires. Min 300 (5 min), max 604800 (7 days). Default: 86400 (24h). + * @throws {AppwriteException} + * @returns {Promise} + */ + createBranch(params: { + databaseId: string; + branchId?: string; + ttl?: number; + }): Promise; + /** + * Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. + * + * @param {string} databaseId - Database ID. + * @param {string} branchId - Branch 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 {number} ttl - Time-to-live in seconds before the branch expires. Min 300 (5 min), max 604800 (7 days). Default: 86400 (24h). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBranch( + databaseId: string, + branchId?: string, + ttl?: number, + ): Promise; + createBranch( + paramsOrFirst: + { databaseId: string; branchId?: string; ttl?: number } | string, + ...rest: [string?, number?] + ): Promise { + let params: { databaseId: string; branchId?: string; ttl?: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + branchId?: string; + ttl?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + branchId: rest[0] as string, + ttl: rest[1] as number, + }; + } + + const databaseId = params.databaseId; + const branchId = params.branchId; + const ttl = params.ttl; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/branches'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof branchId !== 'undefined') { + apiPayload['branchId'] = branchId; + } + 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); + } + + /** + * Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.branchId - Branch ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteBranch(params: { + databaseId: string; + branchId: string; + }): Promise; + /** + * Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. + * + * @param {string} databaseId - Database ID. + * @param {string} branchId - Branch ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteBranch( + databaseId: string, + branchId: string, + ): Promise; + deleteBranch( + paramsOrFirst: { databaseId: string; branchId: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; branchId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + branchId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + branchId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const branchId = params.branchId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof branchId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "branchId"', + ); + } + const apiPath = '/postgresql/{databaseId}/branches/{branchId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{branchId}', encodeURIComponent(String(branchId))); + 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); + } + + /** + * Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateCredentials(params: { + databaseId: string; + }): Promise; + /** + * Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateCredentials(databaseId: string): Promise; + updateCredentials( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/credentials'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.sql - SQL statement to execute. Exactly one statement per request. + * @param {object} params.bindings - Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. + * @param {number} params.timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. + * @throws {AppwriteException} + * @returns {Promise} + */ + createExecution(params: { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + }): Promise; + /** + * Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. + * + * @param {string} databaseId - Database ID. + * @param {string} sql - SQL statement to execute. Exactly one statement per request. + * @param {object} bindings - Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. + * @param {number} timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createExecution( + databaseId: string, + sql: string, + bindings?: object, + timeoutSeconds?: number, + ): Promise; + createExecution( + paramsOrFirst: + | { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + } + | string, + ...rest: [string?, object?, number?] + ): Promise { + let params: { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + sql: string; + bindings?: object; + timeoutSeconds?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + sql: rest[0] as string, + bindings: rest[1] as object, + timeoutSeconds: rest[2] as number, + }; + } + + const databaseId = params.databaseId; + const sql = params.sql; + const bindings = params.bindings; + const timeoutSeconds = params.timeoutSeconds; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof sql === 'undefined') { + throw new AppwriteException('Missing required parameter: "sql"'); + } + const apiPath = '/postgresql/{databaseId}/executions'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof sql !== 'undefined') { + apiPayload['sql'] = sql; + } + if (typeof bindings !== 'undefined') { + apiPayload['bindings'] = bindings; + } + if (typeof timeoutSeconds !== 'undefined') { + apiPayload['timeoutSeconds'] = timeoutSeconds; + } + 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 installed and available extensions for a PostgreSQL database. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + listExtensions(params: { + databaseId: string; + }): Promise; + /** + * List installed and available extensions for a PostgreSQL database. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listExtensions( + databaseId: string, + ): Promise; + listExtensions( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/extensions'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * Install a database extension. Only available for PostgreSQL databases. The install runs asynchronously; poll the extensions list endpoint for status. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.name - Extension name (e.g., pgvector, postgis, uuid-ossp). + * @throws {AppwriteException} + * @returns {Promise} + */ + createExtension(params: { + databaseId: string; + name: string; + }): Promise; + /** + * Install a database extension. Only available for PostgreSQL databases. The install runs asynchronously; poll the extensions list endpoint for status. + * + * @param {string} databaseId - Database ID. + * @param {string} name - Extension name (e.g., pgvector, postgis, uuid-ossp). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createExtension( + databaseId: string, + name: string, + ): Promise; + createExtension( + paramsOrFirst: { databaseId: string; name: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const name = params.name; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/postgresql/{databaseId}/extensions'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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('post', uri, apiHeaders, apiPayload); + } + + /** + * Uninstall a database extension from a PostgreSQL database. The uninstall runs asynchronously; poll the extensions list endpoint for status. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.extensionName - Extension name to uninstall. + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteExtension(params: { + databaseId: string; + extensionName: string; + }): Promise; + /** + * Uninstall a database extension from a PostgreSQL database. The uninstall runs asynchronously; poll the extensions list endpoint for status. + * + * @param {string} databaseId - Database ID. + * @param {string} extensionName - Extension name to uninstall. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteExtension( + databaseId: string, + extensionName: string, + ): Promise; + deleteExtension( + paramsOrFirst: { databaseId: string; extensionName: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; extensionName: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + extensionName: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + extensionName: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const extensionName = params.extensionName; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof extensionName === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "extensionName"', + ); + } + const apiPath = '/postgresql/{databaseId}/extensions/{extensionName}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{extensionName}', + encodeURIComponent(String(extensionName)), + ); + 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); + } + + /** + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. + * @throws {AppwriteException} + * @returns {Promise} + */ + createFailover(params: { + databaseId: string; + targetReplicaId?: string; + }): Promise; + /** + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. + * + * @param {string} databaseId - Database ID. + * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFailover( + databaseId: string, + targetReplicaId?: string, + ): Promise; + createFailover( + paramsOrFirst: + { databaseId: string; targetReplicaId?: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; targetReplicaId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetReplicaId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + targetReplicaId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const targetReplicaId = params.targetReplicaId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/failovers'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof targetReplicaId !== 'undefined') { + apiPayload['targetReplicaId'] = targetReplicaId; + } + 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 the maintenance window for a dedicated database. Maintenance operations like minor version upgrades will be performed during this window. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.day - Day of the week for the maintenance window. Allowed values: sun, mon, tue, wed, thu, fri, sat. + * @param {number} params.hourUtc - Hour in UTC (0-23) for maintenance window start. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateMaintenance(params: { + databaseId: string; + day: string; + hourUtc: number; + }): Promise; + /** + * Update the maintenance window for a dedicated database. Maintenance operations like minor version upgrades will be performed during this window. + * + * @param {string} databaseId - Database ID. + * @param {string} day - Day of the week for the maintenance window. Allowed values: sun, mon, tue, wed, thu, fri, sat. + * @param {number} hourUtc - Hour in UTC (0-23) for maintenance window start. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMaintenance( + databaseId: string, + day: string, + hourUtc: number, + ): Promise; + updateMaintenance( + paramsOrFirst: + { databaseId: string; day: string; hourUtc: number } | string, + ...rest: [string?, number?] + ): Promise { + let params: { databaseId: string; day: string; hourUtc: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + day: string; + hourUtc: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + day: rest[0] as string, + hourUtc: rest[1] as number, + }; + } + + const databaseId = params.databaseId; + const day = params.day; + const hourUtc = params.hourUtc; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof day === 'undefined') { + throw new AppwriteException('Missing required parameter: "day"'); + } + if (typeof hourUtc === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "hourUtc"', + ); + } + const apiPath = '/postgresql/{databaseId}/maintenance'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof day !== 'undefined') { + apiPayload['day'] = day; + } + if (typeof hourUtc !== 'undefined') { + apiPayload['hourUtc'] = hourUtc; + } + 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); + } + + /** + * Migrate a database between shared and dedicated types. Shared to dedicated provisions an always-on dedicated instance; dedicated to shared converts to a serverless instance that scales to zero when idle. Data is copied to the target with a brief read-only window during cutover. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.targetType - Target database type to migrate to. Allowed values: shared (serverless, scales to zero when idle), dedicated (always-on with persistent resources). + * @param {string} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. + * @throws {AppwriteException} + * @returns {Promise} + */ + createMigration(params: { + databaseId: string; + targetType: string; + specification?: string; + }): Promise; + /** + * Migrate a database between shared and dedicated types. Shared to dedicated provisions an always-on dedicated instance; dedicated to shared converts to a serverless instance that scales to zero when idle. Data is copied to the target with a brief read-only window during cutover. + * + * @param {string} databaseId - Database ID. + * @param {string} targetType - Target database type to migrate to. Allowed values: shared (serverless, scales to zero when idle), dedicated (always-on with persistent resources). + * @param {string} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMigration( + databaseId: string, + targetType: string, + specification?: string, + ): Promise; + createMigration( + paramsOrFirst: + | { databaseId: string; targetType: string; specification?: string } + | string, + ...rest: [string?, string?] + ): Promise { + let params: { + databaseId: string; + targetType: string; + specification?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetType: string; + specification?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + targetType: rest[0] as string, + specification: rest[1] as string, + }; + } + + const databaseId = params.databaseId; + const targetType = params.targetType; + const specification = params.specification; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof targetType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "targetType"', + ); + } + const apiPath = '/postgresql/{databaseId}/migrations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof targetType !== 'undefined') { + apiPayload['targetType'] = targetType; + } + if (typeof specification !== 'undefined') { + apiPayload['specification'] = specification; + } + 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 the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.status - Filter by operation status. + * @param {number} params.limit - Maximum number of operations to return. + * @param {number} params.offset - Number of operations to skip. + * @throws {AppwriteException} + * @returns {Promise} + */ + listOperations(params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }): Promise; + /** + * List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. + * + * @param {string} databaseId - Database ID. + * @param {string} status - Filter by operation status. + * @param {number} limit - Maximum number of operations to return. + * @param {number} offset - Number of operations to skip. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listOperations( + databaseId: string, + status?: string, + limit?: number, + offset?: number, + ): Promise; + listOperations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, number?, number?] + ): Promise { + let params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + status: rest[0] as string, + limit: rest[1] as number, + offset: rest[2] as number, + }; + } + + const databaseId = params.databaseId; + const status = params.status; + const limit = params.limit; + const offset = params.offset; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/operations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof status !== 'undefined') { + apiPayload['status'] = status; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof offset !== 'undefined') { + apiPayload['offset'] = offset; + } + 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 available point-in-time recovery windows for a dedicated database. Returns the earliest and latest recovery points. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPitr(params: { + databaseId: string; + }): Promise; + /** + * Get available point-in-time recovery windows for a dedicated database. Returns the earliest and latest recovery points. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPitr(databaseId: string): Promise; + getPitr( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/pitr'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * Get the connection pooler configuration for a dedicated database. Returns pooler mode, max connections, and pool size settings. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPooler(params: { + databaseId: string; + }): Promise; + /** + * Get the connection pooler configuration for a dedicated database. Returns pooler mode, max connections, and pool size settings. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPooler(databaseId: string): Promise; + getPooler( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/pooler'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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 connection pooler configuration for a dedicated database. Configure pool mode, max connections, and pool sizes. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.mode - Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. + * @param {number} params.maxConnections - Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. + * @param {number} params.defaultPoolSize - Default pool size per user. + * @param {boolean} params.readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + * @param {string} params.poolerCpuRequest - Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). + * @param {string} params.poolerCpuLimit - Pooler sidecar CPU limit override (Kubernetes quantity, e.g. "500m" or "1"). Leave null for the proportional default (10% of DB CPU, floor 200m). Changing this field rolls the database pod. + * @param {string} params.poolerMemoryRequest - Pooler sidecar memory request override (Kubernetes quantity, e.g. "128Mi" or "1Gi"). Leave null for the proportional default (7.5% of DB memory, floor 64Mi). + * @param {string} params.poolerMemoryLimit - Pooler sidecar memory limit override (Kubernetes quantity, e.g. "256Mi" or "1Gi"). Leave null for the proportional default (15% of DB memory, floor 128Mi). Changing this field rolls the database pod. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePooler(params: { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + }): Promise; + /** + * Update the connection pooler configuration for a dedicated database. Configure pool mode, max connections, and pool sizes. + * + * @param {string} databaseId - Database ID. + * @param {string} mode - Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. + * @param {number} maxConnections - Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. + * @param {number} defaultPoolSize - Default pool size per user. + * @param {boolean} readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + * @param {string} poolerCpuRequest - Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). + * @param {string} poolerCpuLimit - Pooler sidecar CPU limit override (Kubernetes quantity, e.g. "500m" or "1"). Leave null for the proportional default (10% of DB CPU, floor 200m). Changing this field rolls the database pod. + * @param {string} poolerMemoryRequest - Pooler sidecar memory request override (Kubernetes quantity, e.g. "128Mi" or "1Gi"). Leave null for the proportional default (7.5% of DB memory, floor 64Mi). + * @param {string} poolerMemoryLimit - Pooler sidecar memory limit override (Kubernetes quantity, e.g. "256Mi" or "1Gi"). Leave null for the proportional default (15% of DB memory, floor 128Mi). Changing this field rolls the database pod. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePooler( + databaseId: string, + mode?: string, + maxConnections?: number, + defaultPoolSize?: number, + readWriteSplitting?: boolean, + poolerCpuRequest?: string, + poolerCpuLimit?: string, + poolerMemoryRequest?: string, + poolerMemoryLimit?: string, + ): Promise; + updatePooler( + paramsOrFirst: + | { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + } + | string, + ...rest: [ + string?, + number?, + number?, + boolean?, + string?, + string?, + string?, + string?, + ] + ): Promise { + let params: { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + mode?: string; + maxConnections?: number; + defaultPoolSize?: number; + readWriteSplitting?: boolean; + poolerCpuRequest?: string; + poolerCpuLimit?: string; + poolerMemoryRequest?: string; + poolerMemoryLimit?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + mode: rest[0] as string, + maxConnections: rest[1] as number, + defaultPoolSize: rest[2] as number, + readWriteSplitting: rest[3] as boolean, + poolerCpuRequest: rest[4] as string, + poolerCpuLimit: rest[5] as string, + poolerMemoryRequest: rest[6] as string, + poolerMemoryLimit: rest[7] as string, + }; + } + + const databaseId = params.databaseId; + const mode = params.mode; + const maxConnections = params.maxConnections; + const defaultPoolSize = params.defaultPoolSize; + const readWriteSplitting = params.readWriteSplitting; + const poolerCpuRequest = params.poolerCpuRequest; + const poolerCpuLimit = params.poolerCpuLimit; + const poolerMemoryRequest = params.poolerMemoryRequest; + const poolerMemoryLimit = params.poolerMemoryLimit; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/pooler'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof mode !== 'undefined') { + apiPayload['mode'] = mode; + } + if (typeof maxConnections !== 'undefined') { + apiPayload['maxConnections'] = maxConnections; + } + if (typeof defaultPoolSize !== 'undefined') { + apiPayload['defaultPoolSize'] = defaultPoolSize; + } + if (typeof readWriteSplitting !== 'undefined') { + apiPayload['readWriteSplitting'] = readWriteSplitting; + } + if (typeof poolerCpuRequest !== 'undefined') { + apiPayload['poolerCpuRequest'] = poolerCpuRequest; + } + if (typeof poolerCpuLimit !== 'undefined') { + apiPayload['poolerCpuLimit'] = poolerCpuLimit; + } + if (typeof poolerMemoryRequest !== 'undefined') { + apiPayload['poolerMemoryRequest'] = poolerMemoryRequest; + } + if (typeof poolerMemoryLimit !== 'undefined') { + apiPayload['poolerMemoryLimit'] = poolerMemoryLimit; + } + 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 high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getReplicas(params: { + databaseId: string; + }): Promise; + /** + * Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getReplicas(databaseId: string): Promise; + getReplicas( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/replicas'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * List all restorations for a dedicated database. Results can be filtered by status and type. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.status - Filter by restoration status. + * @param {string} params.type - Filter by restoration type. + * @param {number} params.limit - Maximum number of restorations to return. + * @param {number} params.offset - Number of restorations to skip. + * @throws {AppwriteException} + * @returns {Promise} + */ + listRestorations(params: { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }): Promise; + /** + * List all restorations for a dedicated database. Results can be filtered by status and type. + * + * @param {string} databaseId - Database ID. + * @param {string} status - Filter by restoration status. + * @param {string} type - Filter by restoration type. + * @param {number} limit - Maximum number of restorations to return. + * @param {number} offset - Number of restorations to skip. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRestorations( + databaseId: string, + status?: string, + type?: string, + limit?: number, + offset?: number, + ): Promise; + listRestorations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, string?, number?, number?] + ): Promise { + let params: { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + type?: string; + limit?: number; + offset?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + status: rest[0] as string, + type: rest[1] as string, + limit: rest[2] as number, + offset: rest[3] as number, + }; + } + + const databaseId = params.databaseId; + const status = params.status; + const type = params.type; + const limit = params.limit; + const offset = params.offset; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/restorations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof status !== 'undefined') { + apiPayload['status'] = status; + } + if (typeof type !== 'undefined') { + apiPayload['type'] = type; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof offset !== 'undefined') { + apiPayload['offset'] = offset; + } + 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); + } + + /** + * Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.type - Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. + * @param {string} params.backupId - Backup ID to restore from (required for backup type). + * @param {string} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string} params.targetTime - Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRestoration(params: { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }): Promise; + /** + * Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + * + * @param {string} databaseId - Database ID. + * @param {string} type - Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. + * @param {string} backupId - Backup ID to restore from (required for backup type). + * @param {string} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string} targetTime - Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRestoration( + databaseId: string, + type?: string, + backupId?: string, + targetDatabaseId?: string, + targetTime?: string, + ): Promise; + createRestoration( + paramsOrFirst: + | { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + } + | string, + ...rest: [string?, string?, string?, string?] + ): Promise { + let params: { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + type?: string; + backupId?: string; + targetDatabaseId?: string; + targetTime?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + type: rest[0] as string, + backupId: rest[1] as string, + targetDatabaseId: rest[2] as string, + targetTime: rest[3] as string, + }; + } + + const databaseId = params.databaseId; + const type = params.type; + const backupId = params.backupId; + const targetDatabaseId = params.targetDatabaseId; + const targetTime = params.targetTime; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/restorations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof type !== 'undefined') { + apiPayload['type'] = type; + } + if (typeof backupId !== 'undefined') { + apiPayload['backupId'] = backupId; + } + if (typeof targetDatabaseId !== 'undefined') { + apiPayload['targetDatabaseId'] = targetDatabaseId; + } + if (typeof targetTime !== 'undefined') { + apiPayload['targetTime'] = targetTime; + } + 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 details of a specific database restoration including its status, type, and timestamps. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getRestoration(params: { + databaseId: string; + restorationId: string; + }): Promise; + /** + * Get details of a specific database restoration including its status, type, and timestamps. + * + * @param {string} databaseId - Database ID. + * @param {string} restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRestoration( + databaseId: string, + restorationId: string, + ): Promise; + getRestoration( + paramsOrFirst: { databaseId: string; restorationId: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; restorationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + restorationId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + restorationId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const restorationId = params.restorationId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof restorationId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); + } + const apiPath = '/postgresql/{databaseId}/restorations/{restorationId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{restorationId}', + encodeURIComponent(String(restorationId)), + ); + 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); + } + + /** + * Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getStatus(params: { databaseId: string }): Promise; + /** + * Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getStatus(databaseId: string): Promise; + getStatus( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/postgresql/{databaseId}/status'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.targetVersion - Target engine version to upgrade to. + * @throws {AppwriteException} + * @returns {Promise} + */ + createUpgrade(params: { + databaseId: string; + targetVersion: string; + }): Promise; + /** + * Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. + * + * @param {string} databaseId - Database ID. + * @param {string} targetVersion - Target engine version to upgrade to. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createUpgrade( + databaseId: string, + targetVersion: string, + ): Promise; + createUpgrade( + paramsOrFirst: { databaseId: string; targetVersion: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; targetVersion: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetVersion: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + targetVersion: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const targetVersion = params.targetVersion; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof targetVersion === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "targetVersion"', + ); + } + const apiPath = '/postgresql/{databaseId}/upgrades'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof targetVersion !== 'undefined') { + apiPayload['targetVersion'] = targetVersion; + } + 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); + } +} diff --git a/src/services/presences.ts b/src/services/presences.ts index d7e8af9a..eb155365 100644 --- a/src/services/presences.ts +++ b/src/services/presences.ts @@ -1,8 +1,6 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - - export class Presences { client: Client; @@ -12,7 +10,7 @@ export class Presences { /** * List presence logs. Expired entries are filtered out automatically. - * + * * * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. @@ -20,10 +18,14 @@ export class Presences { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], total?: boolean, ttl?: number }): Promise; + list(params?: { + queries?: string[]; + total?: boolean; + ttl?: number; + }): Promise; /** * List presence logs. Expired entries are filtered out automatically. - * + * * * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. @@ -32,57 +34,64 @@ export class Presences { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], total?: boolean, ttl?: number): Promise; list( - paramsOrFirst?: { queries?: string[], total?: boolean, ttl?: number } | string[], - ...rest: [(boolean)?, (number)?] + queries?: string[], + total?: boolean, + ttl?: number, + ): Promise; + list( + paramsOrFirst?: + { queries?: string[]; total?: boolean; ttl?: number } | string[], + ...rest: [boolean?, number?] ): Promise { - let params: { queries?: string[], total?: boolean, ttl?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean, ttl?: number }; + let params: { queries?: string[]; total?: boolean; ttl?: number }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + ttl?: number; + }; } else { params = { queries: paramsOrFirst as string[], total: rest[0] as boolean, - ttl: rest[1] as number + ttl: rest[1] as number, }; } - + const queries = params.queries; const total = params.total; const ttl = params.ttl; - - const apiPath = '/presences'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + apiPayload['total'] = total; } if (typeof ttl !== 'undefined') { - payload['ttl'] = ttl; + apiPayload['ttl'] = ttl; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Get a presence log by its unique ID. Entries whose `expiresAt` is in the past are treated as not found. - * + * * * @param {string} params.presenceId - Presence unique ID. * @throws {AppwriteException} @@ -91,7 +100,7 @@ export class Presences { get(params: { presenceId: string }): Promise; /** * Get a presence log by its unique ID. Entries whose `expiresAt` is in the past are treated as not found. - * + * * * @param {string} presenceId - Presence unique ID. * @throws {AppwriteException} @@ -100,44 +109,46 @@ export class Presences { */ get(presenceId: string): Promise; get( - paramsOrFirst: { presenceId: string } | string + paramsOrFirst: { presenceId: string } | string, ): Promise { let params: { presenceId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { presenceId: string }; } else { params = { - presenceId: paramsOrFirst as string + presenceId: paramsOrFirst as string, }; } - - const presenceId = params.presenceId; + const presenceId = params.presenceId; if (typeof presenceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "presenceId"'); + throw new AppwriteException( + 'Missing required parameter: "presenceId"', + ); } - - const apiPath = '/presences/{presenceId}'.replace('{presenceId}', encodeURIComponent(String(presenceId))); - const payload: Payload = {}; + const apiPath = '/presences/{presenceId}'.replace( + '{presenceId}', + encodeURIComponent(String(presenceId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Create or update a presence log by its user ID. - * + * * * @param {string} params.presenceId - Presence unique ID. * @param {string} params.userId - User ID. @@ -148,10 +159,17 @@ export class Presences { * @throws {AppwriteException} * @returns {Promise} */ - upsert(params: { presenceId: string, userId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }): Promise; + upsert(params: { + presenceId: string; + userId: string; + status: string; + permissions?: string[]; + expiresAt?: string; + metadata?: object; + }): Promise; /** * Create or update a presence log by its user ID. - * + * * * @param {string} presenceId - Presence unique ID. * @param {string} userId - User ID. @@ -163,15 +181,49 @@ export class Presences { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - upsert(presenceId: string, userId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object): Promise; upsert( - paramsOrFirst: { presenceId: string, userId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object } | string, - ...rest: [(string)?, (string)?, (string[])?, (string)?, (object)?] + presenceId: string, + userId: string, + status: string, + permissions?: string[], + expiresAt?: string, + metadata?: object, + ): Promise; + upsert( + paramsOrFirst: + | { + presenceId: string; + userId: string; + status: string; + permissions?: string[]; + expiresAt?: string; + metadata?: object; + } + | string, + ...rest: [string?, string?, string[]?, string?, object?] ): Promise { - let params: { presenceId: string, userId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { presenceId: string, userId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }; + let params: { + presenceId: string; + userId: string; + status: string; + permissions?: string[]; + expiresAt?: string; + metadata?: object; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + presenceId: string; + userId: string; + status: string; + permissions?: string[]; + expiresAt?: string; + metadata?: object; + }; } else { params = { presenceId: paramsOrFirst as string, @@ -179,19 +231,20 @@ export class Presences { status: rest[1] as string, permissions: rest[2] as string[], expiresAt: rest[3] as string, - metadata: rest[4] as object + metadata: rest[4] as object, }; } - + const presenceId = params.presenceId; const userId = params.userId; const status = params.status; const permissions = params.permissions; const expiresAt = params.expiresAt; const metadata = params.metadata; - if (typeof presenceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "presenceId"'); + throw new AppwriteException( + 'Missing required parameter: "presenceId"', + ); } if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); @@ -199,43 +252,40 @@ export class Presences { if (typeof status === 'undefined') { throw new AppwriteException('Missing required parameter: "status"'); } - - const apiPath = '/presences/{presenceId}'.replace('{presenceId}', encodeURIComponent(String(presenceId))); - const payload: Payload = {}; + const apiPath = '/presences/{presenceId}'.replace( + '{presenceId}', + encodeURIComponent(String(presenceId)), + ); + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof status !== 'undefined') { - payload['status'] = status; + apiPayload['status'] = status; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof expiresAt !== 'undefined') { - payload['expiresAt'] = expiresAt; + apiPayload['expiresAt'] = expiresAt; } if (typeof metadata !== 'undefined') { - payload['metadata'] = metadata; + apiPayload['metadata'] = metadata; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** * Update a presence log by its unique ID. Using the patch method you can pass only specific fields that will get updated. - * + * * * @param {string} params.presenceId - Presence unique ID. * @param {string} params.userId - User ID. @@ -247,10 +297,18 @@ export class Presences { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { presenceId: string, userId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }): Promise; + update(params: { + presenceId: string; + userId: string; + status?: string; + expiresAt?: string; + metadata?: object; + permissions?: string[]; + purge?: boolean; + }): Promise; /** * Update a presence log by its unique ID. Using the patch method you can pass only specific fields that will get updated. - * + * * * @param {string} presenceId - Presence unique ID. * @param {string} userId - User ID. @@ -263,15 +321,53 @@ export class Presences { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(presenceId: string, userId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean): Promise; update( - paramsOrFirst: { presenceId: string, userId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (object)?, (string[])?, (boolean)?] + presenceId: string, + userId: string, + status?: string, + expiresAt?: string, + metadata?: object, + permissions?: string[], + purge?: boolean, + ): Promise; + update( + paramsOrFirst: + | { + presenceId: string; + userId: string; + status?: string; + expiresAt?: string; + metadata?: object; + permissions?: string[]; + purge?: boolean; + } + | string, + ...rest: [string?, string?, string?, object?, string[]?, boolean?] ): Promise { - let params: { presenceId: string, userId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { presenceId: string, userId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; + let params: { + presenceId: string; + userId: string; + status?: string; + expiresAt?: string; + metadata?: object; + permissions?: string[]; + purge?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + presenceId: string; + userId: string; + status?: string; + expiresAt?: string; + metadata?: object; + permissions?: string[]; + purge?: boolean; + }; } else { params = { presenceId: paramsOrFirst as string, @@ -280,10 +376,10 @@ export class Presences { expiresAt: rest[2] as string, metadata: rest[3] as object, permissions: rest[4] as string[], - purge: rest[5] as boolean + purge: rest[5] as boolean, }; } - + const presenceId = params.presenceId; const userId = params.userId; const status = params.status; @@ -291,53 +387,51 @@ export class Presences { const metadata = params.metadata; const permissions = params.permissions; const purge = params.purge; - if (typeof presenceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "presenceId"'); + throw new AppwriteException( + 'Missing required parameter: "presenceId"', + ); } if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/presences/{presenceId}'.replace('{presenceId}', encodeURIComponent(String(presenceId))); - const payload: Payload = {}; + const apiPath = '/presences/{presenceId}'.replace( + '{presenceId}', + encodeURIComponent(String(presenceId)), + ); + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof status !== 'undefined') { - payload['status'] = status; + apiPayload['status'] = status; } if (typeof expiresAt !== 'undefined') { - payload['expiresAt'] = expiresAt; + apiPayload['expiresAt'] = expiresAt; } if (typeof metadata !== 'undefined') { - payload['metadata'] = metadata; + apiPayload['metadata'] = metadata; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof purge !== 'undefined') { - payload['purge'] = purge; + apiPayload['purge'] = purge; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Delete a presence log by its unique ID. - * + * * * @param {string} params.presenceId - Presence unique ID. * @throws {AppwriteException} @@ -346,7 +440,7 @@ export class Presences { delete(params: { presenceId: string }): Promise<{}>; /** * Delete a presence log by its unique ID. - * + * * * @param {string} presenceId - Presence unique ID. * @throws {AppwriteException} @@ -354,39 +448,39 @@ export class Presences { * @deprecated Use the object parameter style method for a better developer experience. */ delete(presenceId: string): Promise<{}>; - delete( - paramsOrFirst: { presenceId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { presenceId: string } | string): Promise<{}> { let params: { presenceId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { presenceId: string }; } else { params = { - presenceId: paramsOrFirst as string + presenceId: paramsOrFirst as string, }; } - - const presenceId = params.presenceId; + const presenceId = params.presenceId; if (typeof presenceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "presenceId"'); + throw new AppwriteException( + 'Missing required parameter: "presenceId"', + ); } - - const apiPath = '/presences/{presenceId}'.replace('{presenceId}', encodeURIComponent(String(presenceId))); - const payload: Payload = {}; + const apiPath = '/presences/{presenceId}'.replace( + '{presenceId}', + encodeURIComponent(String(presenceId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } } diff --git a/src/services/project.ts b/src/services/project.ts index 990a2303..2c6ea0ad 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -1,7 +1,6 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - import { ProjectAuthMethodId } from '../enums/project-auth-method-id'; import { ProjectKeyScopes } from '../enums/project-key-scopes'; import { ProjectOAuth2GooglePrompt } from '../enums/project-o-auth-2-google-prompt'; @@ -13,7 +12,6 @@ import { ProjectServiceId } from '../enums/project-service-id'; import { ProjectSMTPSecure } from '../enums/project-smtp-secure'; import { ProjectEmailTemplateId } from '../enums/project-email-template-id'; import { ProjectEmailTemplateLocale } from '../enums/project-email-template-locale'; - export class Project { client: Client; @@ -28,21 +26,15 @@ export class Project { * @returns {Promise} */ get(): Promise { - const apiPath = '/project'; - const payload: Payload = {}; + const apiPayload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - } + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -52,35 +44,32 @@ export class Project { * @returns {Promise<{}>} */ delete(): Promise<{}> { - const apiPath = '/project'; - const payload: Payload = {}; + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** - * Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. + * Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. * * @param {ProjectAuthMethodId} params.methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone * @param {boolean} params.enabled - Auth method status. * @throws {AppwriteException} * @returns {Promise} */ - updateAuthMethod(params: { methodId: ProjectAuthMethodId, enabled: boolean }): Promise; + updateAuthMethod(params: { + methodId: ProjectAuthMethodId; + enabled: boolean; + }): Promise; /** - * Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. + * Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. * * @param {ProjectAuthMethodId} methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone * @param {boolean} enabled - Auth method status. @@ -88,51 +77,64 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateAuthMethod(methodId: ProjectAuthMethodId, enabled: boolean): Promise; updateAuthMethod( - paramsOrFirst: { methodId: ProjectAuthMethodId, enabled: boolean } | ProjectAuthMethodId, - ...rest: [(boolean)?] + methodId: ProjectAuthMethodId, + enabled: boolean, + ): Promise; + updateAuthMethod( + paramsOrFirst: + | { methodId: ProjectAuthMethodId; enabled: boolean } + | ProjectAuthMethodId, + ...rest: [boolean?] ): Promise { - let params: { methodId: ProjectAuthMethodId, enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('methodId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { methodId: ProjectAuthMethodId, enabled: boolean }; + let params: { methodId: ProjectAuthMethodId; enabled: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('methodId' in paramsOrFirst || 'enabled' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + methodId: ProjectAuthMethodId; + enabled: boolean; + }; } else { params = { methodId: paramsOrFirst as ProjectAuthMethodId, - enabled: rest[0] as boolean + enabled: rest[0] as boolean, }; } - + const methodId = params.methodId; const enabled = params.enabled; - if (typeof methodId === 'undefined') { - throw new AppwriteException('Missing required parameter: "methodId"'); + throw new AppwriteException( + 'Missing required parameter: "methodId"', + ); } if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - - const apiPath = '/project/auth-methods/{methodId}'.replace('{methodId}', encodeURIComponent(String(methodId))); - const payload: Payload = {}; + const apiPath = '/project/auth-methods/{methodId}'.replace( + '{methodId}', + encodeURIComponent(String(methodId)), + ); + const apiPayload: Payload = {}; if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -143,7 +145,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - listKeys(params?: { queries?: string[], total?: boolean }): Promise; + listKeys(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all API keys from the current project. * @@ -155,50 +160,51 @@ export class Project { */ listKeys(queries?: string[], total?: boolean): Promise; listKeys( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/project/keys'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Create a new ephemeral API key. 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 {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. @@ -206,10 +212,13 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - createEphemeralKey(params: { scopes: ProjectKeyScopes[], duration: number }): Promise; + createEphemeralKey(params: { + scopes: ProjectKeyScopes[]; + duration: number; + }): Promise; /** * Create a new ephemeral API key. 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 {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. @@ -218,58 +227,66 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEphemeralKey(scopes: ProjectKeyScopes[], duration: number): Promise; createEphemeralKey( - paramsOrFirst: { scopes: ProjectKeyScopes[], duration: number } | ProjectKeyScopes[], - ...rest: [(number)?] + scopes: ProjectKeyScopes[], + duration: number, + ): Promise; + createEphemeralKey( + paramsOrFirst: + | { scopes: ProjectKeyScopes[]; duration: number } + | ProjectKeyScopes[], + ...rest: [number?] ): Promise { - let params: { scopes: ProjectKeyScopes[], duration: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('scopes' in paramsOrFirst || 'duration' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { scopes: ProjectKeyScopes[], duration: number }; + let params: { scopes: ProjectKeyScopes[]; duration: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('scopes' in paramsOrFirst || 'duration' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + scopes: ProjectKeyScopes[]; + duration: number; + }; } else { params = { scopes: paramsOrFirst as ProjectKeyScopes[], - duration: rest[0] as number + duration: rest[0] as number, }; } - + const scopes = params.scopes; const duration = params.duration; - if (typeof scopes === 'undefined') { throw new AppwriteException('Missing required parameter: "scopes"'); } if (typeof duration === 'undefined') { - throw new AppwriteException('Missing required parameter: "duration"'); + throw new AppwriteException( + 'Missing required parameter: "duration"', + ); } - const apiPath = '/project/keys/ephemeral'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof scopes !== 'undefined') { - payload['scopes'] = scopes; + apiPayload['scopes'] = scopes; } if (typeof duration !== 'undefined') { - payload['duration'] = duration; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** - * Get a key by its unique ID. + * Get a key by its unique ID. * * @param {string} params.keyId - Key ID. * @throws {AppwriteException} @@ -277,7 +294,7 @@ export class Project { */ getKey(params: { keyId: string }): Promise; /** - * Get a key by its unique ID. + * Get a key by its unique ID. * * @param {string} keyId - Key ID. * @throws {AppwriteException} @@ -285,40 +302,38 @@ export class Project { * @deprecated Use the object parameter style method for a better developer experience. */ getKey(keyId: string): Promise; - getKey( - paramsOrFirst: { keyId: string } | string - ): Promise { + getKey(paramsOrFirst: { keyId: string } | string): Promise { let params: { keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { keyId: string }; } else { params = { - keyId: paramsOrFirst as string + keyId: paramsOrFirst as string, }; } - - const keyId = params.keyId; + const keyId = params.keyId; if (typeof keyId === 'undefined') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/project/keys/{keyId}'.replace('{keyId}', encodeURIComponent(String(keyId))); - const payload: Payload = {}; + const apiPath = '/project/keys/{keyId}'.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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -331,7 +346,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateKey(params: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }): Promise; + updateKey(params: { + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }): Promise; /** * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. * @@ -343,29 +363,54 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateKey(keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string): Promise; updateKey( - paramsOrFirst: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string } | string, - ...rest: [(string)?, (ProjectKeyScopes[])?, (string)?] + keyId: string, + name: string, + scopes: ProjectKeyScopes[], + expire?: string, + ): Promise; + updateKey( + paramsOrFirst: + | { + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + } + | string, + ...rest: [string?, ProjectKeyScopes[]?, string?] ): Promise { - let params: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }; + let params: { + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + keyId: string; + name: string; + scopes: ProjectKeyScopes[]; + expire?: string; + }; } else { params = { keyId: paramsOrFirst as string, name: rest[0] as string, scopes: rest[1] as ProjectKeyScopes[], - expire: rest[2] as string + expire: rest[2] as string, }; } - + const keyId = params.keyId; const name = params.name; const scopes = params.scopes; const expire = params.expire; - if (typeof keyId === 'undefined') { throw new AppwriteException('Missing required parameter: "keyId"'); } @@ -375,32 +420,29 @@ export class Project { if (typeof scopes === 'undefined') { throw new AppwriteException('Missing required parameter: "scopes"'); } - - const apiPath = '/project/keys/{keyId}'.replace('{keyId}', encodeURIComponent(String(keyId))); - const payload: Payload = {}; + const apiPath = '/project/keys/{keyId}'.replace( + '{keyId}', + encodeURIComponent(String(keyId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof scopes !== 'undefined') { - payload['scopes'] = scopes; + apiPayload['scopes'] = scopes; } if (typeof expire !== 'undefined') { - payload['expire'] = expire; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -420,40 +462,38 @@ export class Project { * @deprecated Use the object parameter style method for a better developer experience. */ deleteKey(keyId: string): Promise<{}>; - deleteKey( - paramsOrFirst: { keyId: string } | string - ): Promise<{}> { + deleteKey(paramsOrFirst: { keyId: string } | string): Promise<{}> { let params: { keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { keyId: string }; } else { params = { - keyId: paramsOrFirst as string + keyId: paramsOrFirst as string, }; } - - const keyId = params.keyId; + const keyId = params.keyId; if (typeof keyId === 'undefined') { throw new AppwriteException('Missing required parameter: "keyId"'); } - - const apiPath = '/project/keys/{keyId}'.replace('{keyId}', encodeURIComponent(String(keyId))); - const payload: Payload = {}; + const apiPath = '/project/keys/{keyId}'.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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -474,43 +514,40 @@ export class Project { */ updateLabels(labels: string[]): Promise; updateLabels( - paramsOrFirst: { labels: string[] } | string[] + paramsOrFirst: { labels: string[] } | string[], ): Promise { let params: { labels: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { labels: string[] }; } else { params = { - labels: paramsOrFirst as string[] + labels: paramsOrFirst as string[], }; } - - const labels = params.labels; + const labels = params.labels; if (typeof labels === 'undefined') { throw new AppwriteException('Missing required parameter: "labels"'); } - const apiPath = '/project/labels'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof labels !== 'undefined') { - payload['labels'] = labels; + apiPayload['labels'] = labels; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -521,7 +558,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - listMockPhones(params?: { queries?: string[], total?: boolean }): Promise; + listMockPhones(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all mock phones in the project. This endpoint returns an array of all mock phones and their OTPs. * @@ -531,47 +571,51 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listMockPhones(queries?: string[], total?: boolean): Promise; listMockPhones( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listMockPhones( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/project/mock-phones'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -582,7 +626,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - createMockPhone(params: { number: string, otp: string }): Promise; + createMockPhone(params: { + number: string; + otp: string; + }): Promise; /** * Create a new mock phone for your project. Use this endpoint to register a mock phone number and its sign-in OTP for your testers. * @@ -594,52 +641,49 @@ export class Project { */ createMockPhone(number: string, otp: string): Promise; createMockPhone( - paramsOrFirst: { number: string, otp: string } | string, - ...rest: [(string)?] + paramsOrFirst: { number: string; otp: string } | string, + ...rest: [string?] ): Promise { - let params: { number: string, otp: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { number: string, otp: string }; + let params: { number: string; otp: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { number: string; otp: string }; } else { params = { number: paramsOrFirst as string, - otp: rest[0] as string + otp: rest[0] as string, }; } - + const number = params.number; const otp = params.otp; - if (typeof number === 'undefined') { throw new AppwriteException('Missing required parameter: "number"'); } if (typeof otp === 'undefined') { throw new AppwriteException('Missing required parameter: "otp"'); } - const apiPath = '/project/mock-phones'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof number !== 'undefined') { - payload['number'] = number; + apiPayload['number'] = number; } if (typeof otp !== 'undefined') { - payload['otp'] = otp; + apiPayload['otp'] = otp; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -660,39 +704,39 @@ export class Project { */ getMockPhone(number: string): Promise; getMockPhone( - paramsOrFirst: { number: string } | string + paramsOrFirst: { number: string } | string, ): Promise { let params: { number: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { number: string }; } else { params = { - number: paramsOrFirst as string + number: paramsOrFirst as string, }; } - - const number = params.number; + const number = params.number; if (typeof number === 'undefined') { throw new AppwriteException('Missing required parameter: "number"'); } - - const apiPath = '/project/mock-phones/{number}'.replace('{number}', encodeURIComponent(String(number))); - const payload: Payload = {}; + const apiPath = '/project/mock-phones/{number}'.replace( + '{number}', + encodeURIComponent(String(number)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -703,7 +747,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateMockPhone(params: { number: string, otp: string }): Promise; + updateMockPhone(params: { + number: string; + otp: string; + }): Promise; /** * Update a mock phone by its unique number. Use this endpoint to update the mock phone's OTP. * @@ -715,49 +762,49 @@ export class Project { */ updateMockPhone(number: string, otp: string): Promise; updateMockPhone( - paramsOrFirst: { number: string, otp: string } | string, - ...rest: [(string)?] + paramsOrFirst: { number: string; otp: string } | string, + ...rest: [string?] ): Promise { - let params: { number: string, otp: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { number: string, otp: string }; + let params: { number: string; otp: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { number: string; otp: string }; } else { params = { number: paramsOrFirst as string, - otp: rest[0] as string + otp: rest[0] as string, }; } - + const number = params.number; const otp = params.otp; - if (typeof number === 'undefined') { throw new AppwriteException('Missing required parameter: "number"'); } if (typeof otp === 'undefined') { throw new AppwriteException('Missing required parameter: "otp"'); } - - const apiPath = '/project/mock-phones/{number}'.replace('{number}', encodeURIComponent(String(number))); - const payload: Payload = {}; + const apiPath = '/project/mock-phones/{number}'.replace( + '{number}', + encodeURIComponent(String(number)), + ); + const apiPayload: Payload = {}; if (typeof otp !== 'undefined') { - payload['otp'] = otp; + apiPayload['otp'] = otp; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -777,40 +824,38 @@ export class Project { * @deprecated Use the object parameter style method for a better developer experience. */ deleteMockPhone(number: string): Promise<{}>; - deleteMockPhone( - paramsOrFirst: { number: string } | string - ): Promise<{}> { + deleteMockPhone(paramsOrFirst: { number: string } | string): Promise<{}> { let params: { number: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { number: string }; } else { params = { - number: paramsOrFirst as string + number: paramsOrFirst as string, }; } - - const number = params.number; + const number = params.number; if (typeof number === 'undefined') { throw new AppwriteException('Missing required parameter: "number"'); } - - const apiPath = '/project/mock-phones/{number}'.replace('{number}', encodeURIComponent(String(number))); - const payload: Payload = {}; + const apiPath = '/project/mock-phones/{number}'.replace( + '{number}', + encodeURIComponent(String(number)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -821,7 +866,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - listOAuth2Providers(params?: { queries?: string[], total?: boolean }): Promise; + listOAuth2Providers(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all OAuth2 providers supported by the server, along with the project's configuration for each. Credential fields are write-only and always returned empty. * @@ -831,47 +879,51 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listOAuth2Providers(queries?: string[], total?: boolean): Promise; listOAuth2Providers( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listOAuth2Providers( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/project/oauth2'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -896,7 +948,24 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Server(params: { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, installationAccessTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[], installationScopes?: string[] }): Promise; + updateOAuth2Server(params: { + enabled: boolean; + authorizationUrl: string; + scopes?: string[]; + authorizationDetailsTypes?: string[]; + accessTokenDuration?: number; + refreshTokenDuration?: number; + publicAccessTokenDuration?: number; + publicRefreshTokenDuration?: number; + installationAccessTokenDuration?: number; + confidentialPkce?: boolean; + verificationUrl?: string; + userCodeLength?: number; + userCodeFormat?: string; + deviceCodeDuration?: number; + defaultScopes?: string[]; + installationScopes?: string[]; + }): Promise; /** * Update the OAuth2 server (OIDC provider) configuration. * @@ -920,15 +989,105 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Server(enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, installationAccessTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[], installationScopes?: string[]): Promise; updateOAuth2Server( - paramsOrFirst: { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, installationAccessTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[], installationScopes?: string[] } | boolean, - ...rest: [(string)?, (string[])?, (string[])?, (number)?, (number)?, (number)?, (number)?, (number)?, (boolean)?, (string)?, (number)?, (string)?, (number)?, (string[])?, (string[])?] + enabled: boolean, + authorizationUrl: string, + scopes?: string[], + authorizationDetailsTypes?: string[], + accessTokenDuration?: number, + refreshTokenDuration?: number, + publicAccessTokenDuration?: number, + publicRefreshTokenDuration?: number, + installationAccessTokenDuration?: number, + confidentialPkce?: boolean, + verificationUrl?: string, + userCodeLength?: number, + userCodeFormat?: string, + deviceCodeDuration?: number, + defaultScopes?: string[], + installationScopes?: string[], + ): Promise; + updateOAuth2Server( + paramsOrFirst: + | { + enabled: boolean; + authorizationUrl: string; + scopes?: string[]; + authorizationDetailsTypes?: string[]; + accessTokenDuration?: number; + refreshTokenDuration?: number; + publicAccessTokenDuration?: number; + publicRefreshTokenDuration?: number; + installationAccessTokenDuration?: number; + confidentialPkce?: boolean; + verificationUrl?: string; + userCodeLength?: number; + userCodeFormat?: string; + deviceCodeDuration?: number; + defaultScopes?: string[]; + installationScopes?: string[]; + } + | boolean, + ...rest: [ + string?, + string[]?, + string[]?, + number?, + number?, + number?, + number?, + number?, + boolean?, + string?, + number?, + string?, + number?, + string[]?, + string[]?, + ] ): Promise { - let params: { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, installationAccessTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[], installationScopes?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, installationAccessTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[], installationScopes?: string[] }; + let params: { + enabled: boolean; + authorizationUrl: string; + scopes?: string[]; + authorizationDetailsTypes?: string[]; + accessTokenDuration?: number; + refreshTokenDuration?: number; + publicAccessTokenDuration?: number; + publicRefreshTokenDuration?: number; + installationAccessTokenDuration?: number; + confidentialPkce?: boolean; + verificationUrl?: string; + userCodeLength?: number; + userCodeFormat?: string; + deviceCodeDuration?: number; + defaultScopes?: string[]; + installationScopes?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + enabled: boolean; + authorizationUrl: string; + scopes?: string[]; + authorizationDetailsTypes?: string[]; + accessTokenDuration?: number; + refreshTokenDuration?: number; + publicAccessTokenDuration?: number; + publicRefreshTokenDuration?: number; + installationAccessTokenDuration?: number; + confidentialPkce?: boolean; + verificationUrl?: string; + userCodeLength?: number; + userCodeFormat?: string; + deviceCodeDuration?: number; + defaultScopes?: string[]; + installationScopes?: string[]; + }; } else { params = { enabled: paramsOrFirst as boolean, @@ -946,10 +1105,10 @@ export class Project { userCodeFormat: rest[11] as string, deviceCodeDuration: rest[12] as number, defaultScopes: rest[13] as string[], - installationScopes: rest[14] as string[] + installationScopes: rest[14] as string[], }; } - + const enabled = params.enabled; const authorizationUrl = params.authorizationUrl; const scopes = params.scopes; @@ -958,7 +1117,8 @@ export class Project { const refreshTokenDuration = params.refreshTokenDuration; const publicAccessTokenDuration = params.publicAccessTokenDuration; const publicRefreshTokenDuration = params.publicRefreshTokenDuration; - const installationAccessTokenDuration = params.installationAccessTokenDuration; + const installationAccessTokenDuration = + params.installationAccessTokenDuration; const confidentialPkce = params.confidentialPkce; const verificationUrl = params.verificationUrl; const userCodeLength = params.userCodeLength; @@ -966,78 +1126,77 @@ export class Project { const deviceCodeDuration = params.deviceCodeDuration; const defaultScopes = params.defaultScopes; const installationScopes = params.installationScopes; - if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } if (typeof authorizationUrl === 'undefined') { - throw new AppwriteException('Missing required parameter: "authorizationUrl"'); + throw new AppwriteException( + 'Missing required parameter: "authorizationUrl"', + ); } - const apiPath = '/project/oauth2-server'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof authorizationUrl !== 'undefined') { - payload['authorizationUrl'] = authorizationUrl; + apiPayload['authorizationUrl'] = authorizationUrl; } if (typeof scopes !== 'undefined') { - payload['scopes'] = scopes; + apiPayload['scopes'] = scopes; } if (typeof authorizationDetailsTypes !== 'undefined') { - payload['authorizationDetailsTypes'] = authorizationDetailsTypes; + apiPayload['authorizationDetailsTypes'] = authorizationDetailsTypes; } if (typeof accessTokenDuration !== 'undefined') { - payload['accessTokenDuration'] = accessTokenDuration; + apiPayload['accessTokenDuration'] = accessTokenDuration; } if (typeof refreshTokenDuration !== 'undefined') { - payload['refreshTokenDuration'] = refreshTokenDuration; + apiPayload['refreshTokenDuration'] = refreshTokenDuration; } if (typeof publicAccessTokenDuration !== 'undefined') { - payload['publicAccessTokenDuration'] = publicAccessTokenDuration; + apiPayload['publicAccessTokenDuration'] = publicAccessTokenDuration; } if (typeof publicRefreshTokenDuration !== 'undefined') { - payload['publicRefreshTokenDuration'] = publicRefreshTokenDuration; + apiPayload['publicRefreshTokenDuration'] = + publicRefreshTokenDuration; } if (typeof installationAccessTokenDuration !== 'undefined') { - payload['installationAccessTokenDuration'] = installationAccessTokenDuration; + apiPayload['installationAccessTokenDuration'] = + installationAccessTokenDuration; } if (typeof confidentialPkce !== 'undefined') { - payload['confidentialPkce'] = confidentialPkce; + apiPayload['confidentialPkce'] = confidentialPkce; } if (typeof verificationUrl !== 'undefined') { - payload['verificationUrl'] = verificationUrl; + apiPayload['verificationUrl'] = verificationUrl; } if (typeof userCodeLength !== 'undefined') { - payload['userCodeLength'] = userCodeLength; + apiPayload['userCodeLength'] = userCodeLength; } if (typeof userCodeFormat !== 'undefined') { - payload['userCodeFormat'] = userCodeFormat; + apiPayload['userCodeFormat'] = userCodeFormat; } if (typeof deviceCodeDuration !== 'undefined') { - payload['deviceCodeDuration'] = deviceCodeDuration; + apiPayload['deviceCodeDuration'] = deviceCodeDuration; } if (typeof defaultScopes !== 'undefined') { - payload['defaultScopes'] = defaultScopes; + apiPayload['defaultScopes'] = defaultScopes; } if (typeof installationScopes !== 'undefined') { - payload['installationScopes'] = installationScopes; + apiPayload['installationScopes'] = installationScopes; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1049,7 +1208,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Amazon(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Amazon(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Amazon configuration. * @@ -1060,53 +1223,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Amazon(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Amazon( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Amazon( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/amazon'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1120,7 +1295,13 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Apple(params?: { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean }): Promise; + updateOAuth2Apple(params?: { + serviceId?: string; + keyId?: string; + teamId?: string; + p8File?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Apple configuration. * @@ -1133,63 +1314,87 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Apple(serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean): Promise; updateOAuth2Apple( - paramsOrFirst?: { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?] + serviceId?: string, + keyId?: string, + teamId?: string, + p8File?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Apple( + paramsOrFirst?: + | { + serviceId?: string; + keyId?: string; + teamId?: string; + p8File?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, boolean?] ): Promise { - let params: { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean }; + let params: { + serviceId?: string; + keyId?: string; + teamId?: string; + p8File?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + serviceId?: string; + keyId?: string; + teamId?: string; + p8File?: string; + enabled?: boolean; + }; } else { params = { serviceId: paramsOrFirst as string, keyId: rest[0] as string, teamId: rest[1] as string, p8File: rest[2] as string, - enabled: rest[3] as boolean + enabled: rest[3] as boolean, }; } - + const serviceId = params.serviceId; const keyId = params.keyId; const teamId = params.teamId; const p8File = params.p8File; const enabled = params.enabled; - - const apiPath = '/project/oauth2/apple'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof serviceId !== 'undefined') { - payload['serviceId'] = serviceId; + apiPayload['serviceId'] = serviceId; } if (typeof keyId !== 'undefined') { - payload['keyId'] = keyId; + apiPayload['keyId'] = keyId; } if (typeof teamId !== 'undefined') { - payload['teamId'] = teamId; + apiPayload['teamId'] = teamId; } if (typeof p8File !== 'undefined') { - payload['p8File'] = p8File; + apiPayload['p8File'] = p8File; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1201,7 +1406,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Appwrite(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Appwrite(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Appwrite configuration. * @@ -1212,53 +1421,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Appwrite(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Appwrite( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Appwrite( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/appwrite'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1271,7 +1492,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Auth0(params?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }): Promise; + updateOAuth2Auth0(params?: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Auth0 configuration. * @@ -1283,58 +1509,78 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Auth0(clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean): Promise; updateOAuth2Auth0( - paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + endpoint?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Auth0( + paramsOrFirst?: + | { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, endpoint: rest[1] as string, - enabled: rest[2] as boolean + enabled: rest[2] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const endpoint = params.endpoint; const enabled = params.enabled; - - const apiPath = '/project/oauth2/auth0'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof endpoint !== 'undefined') { - payload['endpoint'] = endpoint; + apiPayload['endpoint'] = endpoint; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1347,7 +1593,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Authentik(params?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }): Promise; + updateOAuth2Authentik(params?: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Authentik configuration. * @@ -1359,58 +1610,78 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Authentik(clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean): Promise; updateOAuth2Authentik( - paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + endpoint?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Authentik( + paramsOrFirst?: + | { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, endpoint: rest[1] as string, - enabled: rest[2] as boolean + enabled: rest[2] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const endpoint = params.endpoint; const enabled = params.enabled; - - const apiPath = '/project/oauth2/authentik'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof endpoint !== 'undefined') { - payload['endpoint'] = endpoint; + apiPayload['endpoint'] = endpoint; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1422,7 +1693,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Autodesk(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Autodesk(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Autodesk configuration. * @@ -1433,53 +1708,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Autodesk(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Autodesk( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Autodesk( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/autodesk'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1491,7 +1778,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Bitbucket(params?: { key?: string, secret?: string, enabled?: boolean }): Promise; + updateOAuth2Bitbucket(params?: { + key?: string; + secret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Bitbucket configuration. * @@ -1502,53 +1793,60 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Bitbucket(key?: string, secret?: string, enabled?: boolean): Promise; updateOAuth2Bitbucket( - paramsOrFirst?: { key?: string, secret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + key?: string, + secret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Bitbucket( + paramsOrFirst?: + { key?: string; secret?: string; enabled?: boolean } | string, + ...rest: [string?, boolean?] ): Promise { - let params: { key?: string, secret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { key?: string, secret?: string, enabled?: boolean }; + let params: { key?: string; secret?: string; enabled?: boolean }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + key?: string; + secret?: string; + enabled?: boolean; + }; } else { params = { key: paramsOrFirst as string, secret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const key = params.key; const secret = params.secret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/bitbucket'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + apiPayload['secret'] = secret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1560,7 +1858,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Bitly(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Bitly(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Bitly configuration. * @@ -1571,53 +1873,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Bitly(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Bitly( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Bitly( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/bitly'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1629,7 +1943,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Box(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Box(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Box configuration. * @@ -1640,53 +1958,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Box(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Box( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Box( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/box'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1698,7 +2028,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Dailymotion(params?: { apiKey?: string, apiSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Dailymotion(params?: { + apiKey?: string; + apiSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Dailymotion configuration. * @@ -1709,53 +2043,60 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Dailymotion(apiKey?: string, apiSecret?: string, enabled?: boolean): Promise; updateOAuth2Dailymotion( - paramsOrFirst?: { apiKey?: string, apiSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + apiKey?: string, + apiSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Dailymotion( + paramsOrFirst?: + { apiKey?: string; apiSecret?: string; enabled?: boolean } | string, + ...rest: [string?, boolean?] ): Promise { - let params: { apiKey?: string, apiSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { apiKey?: string, apiSecret?: string, enabled?: boolean }; + let params: { apiKey?: string; apiSecret?: string; enabled?: boolean }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + apiKey?: string; + apiSecret?: string; + enabled?: boolean; + }; } else { params = { apiKey: paramsOrFirst as string, apiSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const apiKey = params.apiKey; const apiSecret = params.apiSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/dailymotion'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + apiPayload['apiKey'] = apiKey; } if (typeof apiSecret !== 'undefined') { - payload['apiSecret'] = apiSecret; + apiPayload['apiSecret'] = apiSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1767,7 +2108,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Discord(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Discord(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Discord configuration. * @@ -1778,53 +2123,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Discord(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Discord( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Discord( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/discord'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1836,7 +2193,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Disqus(params?: { publicKey?: string, secretKey?: string, enabled?: boolean }): Promise; + updateOAuth2Disqus(params?: { + publicKey?: string; + secretKey?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Disqus configuration. * @@ -1847,53 +2208,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Disqus(publicKey?: string, secretKey?: string, enabled?: boolean): Promise; updateOAuth2Disqus( - paramsOrFirst?: { publicKey?: string, secretKey?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + publicKey?: string, + secretKey?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Disqus( + paramsOrFirst?: + | { publicKey?: string; secretKey?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { publicKey?: string, secretKey?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { publicKey?: string, secretKey?: string, enabled?: boolean }; + let params: { + publicKey?: string; + secretKey?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + publicKey?: string; + secretKey?: string; + enabled?: boolean; + }; } else { params = { publicKey: paramsOrFirst as string, secretKey: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const publicKey = params.publicKey; const secretKey = params.secretKey; const enabled = params.enabled; - - const apiPath = '/project/oauth2/disqus'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof publicKey !== 'undefined') { - payload['publicKey'] = publicKey; + apiPayload['publicKey'] = publicKey; } if (typeof secretKey !== 'undefined') { - payload['secretKey'] = secretKey; + apiPayload['secretKey'] = secretKey; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1905,7 +2278,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Dropbox(params?: { appKey?: string, appSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Dropbox(params?: { + appKey?: string; + appSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Dropbox configuration. * @@ -1916,53 +2293,60 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Dropbox(appKey?: string, appSecret?: string, enabled?: boolean): Promise; updateOAuth2Dropbox( - paramsOrFirst?: { appKey?: string, appSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + appKey?: string, + appSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Dropbox( + paramsOrFirst?: + { appKey?: string; appSecret?: string; enabled?: boolean } | string, + ...rest: [string?, boolean?] ): Promise { - let params: { appKey?: string, appSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appKey?: string, appSecret?: string, enabled?: boolean }; + let params: { appKey?: string; appSecret?: string; enabled?: boolean }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + appKey?: string; + appSecret?: string; + enabled?: boolean; + }; } else { params = { appKey: paramsOrFirst as string, appSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const appKey = params.appKey; const appSecret = params.appSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/dropbox'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof appKey !== 'undefined') { - payload['appKey'] = appKey; + apiPayload['appKey'] = appKey; } if (typeof appSecret !== 'undefined') { - payload['appSecret'] = appSecret; + apiPayload['appSecret'] = appSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1974,7 +2358,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Etsy(params?: { keyString?: string, sharedSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Etsy(params?: { + keyString?: string; + sharedSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Etsy configuration. * @@ -1985,53 +2373,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Etsy(keyString?: string, sharedSecret?: string, enabled?: boolean): Promise; updateOAuth2Etsy( - paramsOrFirst?: { keyString?: string, sharedSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + keyString?: string, + sharedSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Etsy( + paramsOrFirst?: + | { keyString?: string; sharedSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { keyString?: string, sharedSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyString?: string, sharedSecret?: string, enabled?: boolean }; + let params: { + keyString?: string; + sharedSecret?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + keyString?: string; + sharedSecret?: string; + enabled?: boolean; + }; } else { params = { keyString: paramsOrFirst as string, sharedSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const keyString = params.keyString; const sharedSecret = params.sharedSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/etsy'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof keyString !== 'undefined') { - payload['keyString'] = keyString; + apiPayload['keyString'] = keyString; } if (typeof sharedSecret !== 'undefined') { - payload['sharedSecret'] = sharedSecret; + apiPayload['sharedSecret'] = sharedSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2043,7 +2443,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Facebook(params?: { appId?: string, appSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Facebook(params?: { + appId?: string; + appSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Facebook configuration. * @@ -2054,53 +2458,60 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Facebook(appId?: string, appSecret?: string, enabled?: boolean): Promise; updateOAuth2Facebook( - paramsOrFirst?: { appId?: string, appSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + appId?: string, + appSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Facebook( + paramsOrFirst?: + { appId?: string; appSecret?: string; enabled?: boolean } | string, + ...rest: [string?, boolean?] ): Promise { - let params: { appId?: string, appSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { appId?: string, appSecret?: string, enabled?: boolean }; + let params: { appId?: string; appSecret?: string; enabled?: boolean }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + appId?: string; + appSecret?: string; + enabled?: boolean; + }; } else { params = { appId: paramsOrFirst as string, appSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const appId = params.appId; const appSecret = params.appSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/facebook'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof appId !== 'undefined') { - payload['appId'] = appId; + apiPayload['appId'] = appId; } if (typeof appSecret !== 'undefined') { - payload['appSecret'] = appSecret; + apiPayload['appSecret'] = appSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2112,7 +2523,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Figma(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Figma(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Figma configuration. * @@ -2123,53 +2538,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Figma(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Figma( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Figma( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/figma'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2182,7 +2609,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2FusionAuth(params?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }): Promise; + updateOAuth2FusionAuth(params?: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 FusionAuth configuration. * @@ -2194,58 +2626,78 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2FusionAuth(clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean): Promise; updateOAuth2FusionAuth( - paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + endpoint?: string, + enabled?: boolean, + ): Promise; + updateOAuth2FusionAuth( + paramsOrFirst?: + | { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + endpoint?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, endpoint: rest[1] as string, - enabled: rest[2] as boolean + enabled: rest[2] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const endpoint = params.endpoint; const enabled = params.enabled; - - const apiPath = '/project/oauth2/fusionauth'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof endpoint !== 'undefined') { - payload['endpoint'] = endpoint; + apiPayload['endpoint'] = endpoint; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2257,7 +2709,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2GitHub(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2GitHub(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 GitHub configuration. * @@ -2268,53 +2724,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2GitHub(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2GitHub( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2GitHub( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/github'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2327,7 +2795,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Gitlab(params?: { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean }): Promise; + updateOAuth2Gitlab(params?: { + applicationId?: string; + secret?: string; + endpoint?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Gitlab configuration. * @@ -2339,58 +2812,78 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Gitlab(applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean): Promise; updateOAuth2Gitlab( - paramsOrFirst?: { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + applicationId?: string, + secret?: string, + endpoint?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Gitlab( + paramsOrFirst?: + | { + applicationId?: string; + secret?: string; + endpoint?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean }; + let params: { + applicationId?: string; + secret?: string; + endpoint?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + applicationId?: string; + secret?: string; + endpoint?: string; + enabled?: boolean; + }; } else { params = { applicationId: paramsOrFirst as string, secret: rest[0] as string, endpoint: rest[1] as string, - enabled: rest[2] as boolean + enabled: rest[2] as boolean, }; } - + const applicationId = params.applicationId; const secret = params.secret; const endpoint = params.endpoint; const enabled = params.enabled; - - const apiPath = '/project/oauth2/gitlab'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof applicationId !== 'undefined') { - payload['applicationId'] = applicationId; + apiPayload['applicationId'] = applicationId; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + apiPayload['secret'] = secret; } if (typeof endpoint !== 'undefined') { - payload['endpoint'] = endpoint; + apiPayload['endpoint'] = endpoint; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2403,7 +2896,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Google(params?: { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean }): Promise; + updateOAuth2Google(params?: { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2GooglePrompt[]; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Google configuration. * @@ -2415,72 +2913,183 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Google(clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean): Promise; updateOAuth2Google( - paramsOrFirst?: { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean } | string, - ...rest: [(string)?, (ProjectOAuth2GooglePrompt[])?, (boolean)?] + clientId?: string, + clientSecret?: string, + prompt?: ProjectOAuth2GooglePrompt[], + enabled?: boolean, + ): Promise; + updateOAuth2Google( + paramsOrFirst?: + | { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2GooglePrompt[]; + enabled?: boolean; + } + | string, + ...rest: [string?, ProjectOAuth2GooglePrompt[]?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2GooglePrompt[]; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + prompt?: ProjectOAuth2GooglePrompt[]; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, prompt: rest[1] as ProjectOAuth2GooglePrompt[], - enabled: rest[2] as boolean + 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/google'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof prompt !== 'undefined') { - payload['prompt'] = prompt; + apiPayload['prompt'] = prompt; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** - * Update the project OAuth2 Keycloak configuration. + * Update the project OAuth2 Hugging Face configuration. * - * @param {string} params.clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} params.clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO - * @param {string} params.endpoint - Domain of Keycloak instance. For example: keycloak.example.com + * @param {string} params.clientId - 'Client ID' of Hugging Face OAuth2 app. For example: 2ab9cff9-d711-40ad-a91e-b08a49c42d24 + * @param {string} params.clientSecret - 'Client Secret' of Hugging Face OAuth2 app. For example: oauth_app_secret_wcLhRtl000000000000000000000xbNdLt + * @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} + */ + updateOAuth2HuggingFace(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; + /** + * Update the project OAuth2 Hugging Face configuration. + * + * @param {string} clientId - 'Client ID' of Hugging Face OAuth2 app. For example: 2ab9cff9-d711-40ad-a91e-b08a49c42d24 + * @param {string} clientSecret - 'Client Secret' of Hugging Face OAuth2 app. For example: oauth_app_secret_wcLhRtl000000000000000000000xbNdLt + * @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. + */ + updateOAuth2HuggingFace( + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2HuggingFace( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] + ): 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/huggingface'; + 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 Keycloak configuration. + * + * @param {string} params.clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + * @param {string} params.clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + * @param {string} params.endpoint - Domain of Keycloak instance. For example: keycloak.example.com * @param {string} params.realmName - Keycloak realm name. For example: appwrite-realm * @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} */ - updateOAuth2Keycloak(params?: { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean }): Promise; + updateOAuth2Keycloak(params?: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + realmName?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Keycloak configuration. * @@ -2493,63 +3102,87 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Keycloak(clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean): Promise; updateOAuth2Keycloak( - paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + endpoint?: string, + realmName?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Keycloak( + paramsOrFirst?: + | { + clientId?: string; + clientSecret?: string; + endpoint?: string; + realmName?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + endpoint?: string; + realmName?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + endpoint?: string; + realmName?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, endpoint: rest[1] as string, realmName: rest[2] as string, - enabled: rest[3] as boolean + enabled: rest[3] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const endpoint = params.endpoint; const realmName = params.realmName; const enabled = params.enabled; - - const apiPath = '/project/oauth2/keycloak'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof endpoint !== 'undefined') { - payload['endpoint'] = endpoint; + apiPayload['endpoint'] = endpoint; } if (typeof realmName !== 'undefined') { - payload['realmName'] = realmName; + apiPayload['realmName'] = realmName; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2561,7 +3194,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Kick(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Kick(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Kick configuration. * @@ -2572,53 +3209,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Kick(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Kick( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Kick( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/kick'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2630,7 +3279,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Linkedin(params?: { clientId?: string, primaryClientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Linkedin(params?: { + clientId?: string; + primaryClientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Linkedin configuration. * @@ -2641,53 +3294,69 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Linkedin(clientId?: string, primaryClientSecret?: string, enabled?: boolean): Promise; updateOAuth2Linkedin( - paramsOrFirst?: { clientId?: string, primaryClientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + primaryClientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Linkedin( + paramsOrFirst?: + | { + clientId?: string; + primaryClientSecret?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, primaryClientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, primaryClientSecret?: string, enabled?: boolean }; + let params: { + clientId?: string; + primaryClientSecret?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + primaryClientSecret?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, primaryClientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const primaryClientSecret = params.primaryClientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/linkedin'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof primaryClientSecret !== 'undefined') { - payload['primaryClientSecret'] = primaryClientSecret; + apiPayload['primaryClientSecret'] = primaryClientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2700,7 +3369,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Microsoft(params?: { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean }): Promise; + updateOAuth2Microsoft(params?: { + applicationId?: string; + applicationSecret?: string; + tenant?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Microsoft configuration. * @@ -2712,58 +3386,78 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Microsoft(applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean): Promise; updateOAuth2Microsoft( - paramsOrFirst?: { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + applicationId?: string, + applicationSecret?: string, + tenant?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Microsoft( + paramsOrFirst?: + | { + applicationId?: string; + applicationSecret?: string; + tenant?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean }; + let params: { + applicationId?: string; + applicationSecret?: string; + tenant?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + applicationId?: string; + applicationSecret?: string; + tenant?: string; + enabled?: boolean; + }; } else { params = { applicationId: paramsOrFirst as string, applicationSecret: rest[0] as string, tenant: rest[1] as string, - enabled: rest[2] as boolean + enabled: rest[2] as boolean, }; } - + const applicationId = params.applicationId; const applicationSecret = params.applicationSecret; const tenant = params.tenant; const enabled = params.enabled; - - const apiPath = '/project/oauth2/microsoft'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof applicationId !== 'undefined') { - payload['applicationId'] = applicationId; + apiPayload['applicationId'] = applicationId; } if (typeof applicationSecret !== 'undefined') { - payload['applicationSecret'] = applicationSecret; + apiPayload['applicationSecret'] = applicationSecret; } if (typeof tenant !== 'undefined') { - payload['tenant'] = tenant; + apiPayload['tenant'] = tenant; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2775,7 +3469,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Notion(params?: { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Notion(params?: { + oauthClientId?: string; + oauthClientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Notion configuration. * @@ -2786,53 +3484,69 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Notion(oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean): Promise; updateOAuth2Notion( - paramsOrFirst?: { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + oauthClientId?: string, + oauthClientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Notion( + paramsOrFirst?: + | { + oauthClientId?: string; + oauthClientSecret?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean }; + let params: { + oauthClientId?: string; + oauthClientSecret?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + oauthClientId?: string; + oauthClientSecret?: string; + enabled?: boolean; + }; } else { params = { oauthClientId: paramsOrFirst as string, oauthClientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const oauthClientId = params.oauthClientId; const oauthClientSecret = params.oauthClientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/notion'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof oauthClientId !== 'undefined') { - payload['oauthClientId'] = oauthClientId; + apiPayload['oauthClientId'] = oauthClientId; } if (typeof oauthClientSecret !== 'undefined') { - payload['oauthClientSecret'] = oauthClientSecret; + apiPayload['oauthClientSecret'] = oauthClientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2850,7 +3564,17 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Oidc(params?: { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, prompt?: ProjectOAuth2OidcPrompt[], maxAge?: number, enabled?: boolean }): Promise; + updateOAuth2Oidc(params?: { + clientId?: string; + clientSecret?: string; + wellKnownURL?: string; + authorizationURL?: string; + tokenURL?: string; + userInfoURL?: string; + prompt?: ProjectOAuth2OidcPrompt[]; + maxAge?: number; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Oidc configuration. * @@ -2867,15 +3591,71 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Oidc(clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, prompt?: ProjectOAuth2OidcPrompt[], maxAge?: number, enabled?: boolean): Promise; updateOAuth2Oidc( - paramsOrFirst?: { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, prompt?: ProjectOAuth2OidcPrompt[], maxAge?: number, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (ProjectOAuth2OidcPrompt[])?, (number)?, (boolean)?] + clientId?: string, + clientSecret?: string, + wellKnownURL?: string, + authorizationURL?: string, + tokenURL?: string, + userInfoURL?: string, + prompt?: ProjectOAuth2OidcPrompt[], + maxAge?: number, + enabled?: boolean, + ): Promise; + updateOAuth2Oidc( + paramsOrFirst?: + | { + clientId?: string; + clientSecret?: string; + wellKnownURL?: string; + authorizationURL?: string; + tokenURL?: string; + userInfoURL?: string; + prompt?: ProjectOAuth2OidcPrompt[]; + maxAge?: number; + enabled?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + ProjectOAuth2OidcPrompt[]?, + number?, + boolean?, + ] ): Promise { - let params: { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, prompt?: ProjectOAuth2OidcPrompt[], maxAge?: number, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, prompt?: ProjectOAuth2OidcPrompt[], maxAge?: number, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + wellKnownURL?: string; + authorizationURL?: string; + tokenURL?: string; + userInfoURL?: string; + prompt?: ProjectOAuth2OidcPrompt[]; + maxAge?: number; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + wellKnownURL?: string; + authorizationURL?: string; + tokenURL?: string; + userInfoURL?: string; + prompt?: ProjectOAuth2OidcPrompt[]; + maxAge?: number; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, @@ -2886,10 +3666,10 @@ export class Project { userInfoURL: rest[4] as string, prompt: rest[5] as ProjectOAuth2OidcPrompt[], maxAge: rest[6] as number, - enabled: rest[7] as boolean + enabled: rest[7] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const wellKnownURL = params.wellKnownURL; @@ -2899,51 +3679,44 @@ export class Project { const prompt = params.prompt; const maxAge = params.maxAge; const enabled = params.enabled; - - const apiPath = '/project/oauth2/oidc'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof wellKnownURL !== 'undefined') { - payload['wellKnownURL'] = wellKnownURL; + apiPayload['wellKnownURL'] = wellKnownURL; } if (typeof authorizationURL !== 'undefined') { - payload['authorizationURL'] = authorizationURL; + apiPayload['authorizationURL'] = authorizationURL; } if (typeof tokenURL !== 'undefined') { - payload['tokenURL'] = tokenURL; + apiPayload['tokenURL'] = tokenURL; } if (typeof userInfoURL !== 'undefined') { - payload['userInfoURL'] = userInfoURL; + apiPayload['userInfoURL'] = userInfoURL; } if (typeof prompt !== 'undefined') { - payload['prompt'] = prompt; + apiPayload['prompt'] = prompt; } if (typeof maxAge !== 'undefined') { - payload['maxAge'] = maxAge; + apiPayload['maxAge'] = maxAge; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2957,7 +3730,13 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Okta(params?: { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean }): Promise; + updateOAuth2Okta(params?: { + clientId?: string; + clientSecret?: string; + domain?: string; + authorizationServerId?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Okta configuration. * @@ -2970,63 +3749,87 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Okta(clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean): Promise; updateOAuth2Okta( - paramsOrFirst?: { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + domain?: string, + authorizationServerId?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Okta( + paramsOrFirst?: + | { + clientId?: string; + clientSecret?: string; + domain?: string; + authorizationServerId?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, string?, boolean?] ): Promise { - let params: { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean }; + let params: { + clientId?: string; + clientSecret?: string; + domain?: string; + authorizationServerId?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + clientSecret?: string; + domain?: string; + authorizationServerId?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, domain: rest[1] as string, authorizationServerId: rest[2] as string, - enabled: rest[3] as boolean + enabled: rest[3] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const domain = params.domain; const authorizationServerId = params.authorizationServerId; const enabled = params.enabled; - - const apiPath = '/project/oauth2/okta'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof domain !== 'undefined') { - payload['domain'] = domain; + apiPayload['domain'] = domain; } if (typeof authorizationServerId !== 'undefined') { - payload['authorizationServerId'] = authorizationServerId; + apiPayload['authorizationServerId'] = authorizationServerId; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3038,7 +3841,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Paypal(params?: { clientId?: string, secretKey?: string, enabled?: boolean }): Promise; + updateOAuth2Paypal(params?: { + clientId?: string; + secretKey?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Paypal configuration. * @@ -3049,53 +3856,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Paypal(clientId?: string, secretKey?: string, enabled?: boolean): Promise; updateOAuth2Paypal( - paramsOrFirst?: { clientId?: string, secretKey?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + secretKey?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Paypal( + paramsOrFirst?: + | { clientId?: string; secretKey?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, secretKey?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, secretKey?: string, enabled?: boolean }; + let params: { + clientId?: string; + secretKey?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + secretKey?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, secretKey: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const secretKey = params.secretKey; const enabled = params.enabled; - - const apiPath = '/project/oauth2/paypal'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof secretKey !== 'undefined') { - payload['secretKey'] = secretKey; + apiPayload['secretKey'] = secretKey; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3107,7 +3926,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2PaypalSandbox(params?: { clientId?: string, secretKey?: string, enabled?: boolean }): Promise; + updateOAuth2PaypalSandbox(params?: { + clientId?: string; + secretKey?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 PaypalSandbox configuration. * @@ -3118,53 +3941,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2PaypalSandbox(clientId?: string, secretKey?: string, enabled?: boolean): Promise; updateOAuth2PaypalSandbox( - paramsOrFirst?: { clientId?: string, secretKey?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + secretKey?: string, + enabled?: boolean, + ): Promise; + updateOAuth2PaypalSandbox( + paramsOrFirst?: + | { clientId?: string; secretKey?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, secretKey?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, secretKey?: string, enabled?: boolean }; + let params: { + clientId?: string; + secretKey?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + secretKey?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, secretKey: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const secretKey = params.secretKey; const enabled = params.enabled; - - const apiPath = '/project/oauth2/paypalSandbox'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof secretKey !== 'undefined') { - payload['secretKey'] = secretKey; + apiPayload['secretKey'] = secretKey; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3176,7 +4011,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Podio(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Podio(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Podio configuration. * @@ -3187,53 +4026,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Podio(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Podio( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Podio( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/podio'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3245,7 +4096,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Salesforce(params?: { customerKey?: string, customerSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Salesforce(params?: { + customerKey?: string; + customerSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Salesforce configuration. * @@ -3256,53 +4111,69 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Salesforce(customerKey?: string, customerSecret?: string, enabled?: boolean): Promise; updateOAuth2Salesforce( - paramsOrFirst?: { customerKey?: string, customerSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + customerKey?: string, + customerSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Salesforce( + paramsOrFirst?: + | { + customerKey?: string; + customerSecret?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { customerKey?: string, customerSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { customerKey?: string, customerSecret?: string, enabled?: boolean }; + let params: { + customerKey?: string; + customerSecret?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + customerKey?: string; + customerSecret?: string; + enabled?: boolean; + }; } else { params = { customerKey: paramsOrFirst as string, customerSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const customerKey = params.customerKey; const customerSecret = params.customerSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/salesforce'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof customerKey !== 'undefined') { - payload['customerKey'] = customerKey; + apiPayload['customerKey'] = customerKey; } if (typeof customerSecret !== 'undefined') { - payload['customerSecret'] = customerSecret; + apiPayload['customerSecret'] = customerSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3314,7 +4185,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Slack(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Slack(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Slack configuration. * @@ -3325,53 +4200,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Slack(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Slack( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Slack( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/slack'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3383,7 +4270,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Spotify(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Spotify(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Spotify configuration. * @@ -3394,53 +4285,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Spotify(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Spotify( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Spotify( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/spotify'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3452,7 +4355,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Stripe(params?: { clientId?: string, apiSecretKey?: string, enabled?: boolean }): Promise; + updateOAuth2Stripe(params?: { + clientId?: string; + apiSecretKey?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Stripe configuration. * @@ -3463,53 +4370,65 @@ export class Project { * @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)?] + clientId?: string, + apiSecretKey?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Stripe( + paramsOrFirst?: + | { clientId?: string; apiSecretKey?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { clientId?: string, apiSecretKey?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, apiSecretKey?: string, enabled?: boolean }; + let params: { + clientId?: string; + apiSecretKey?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + clientId?: string; + apiSecretKey?: string; + enabled?: boolean; + }; } else { params = { clientId: paramsOrFirst as string, apiSecretKey: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const apiSecretKey = params.apiSecretKey; const enabled = params.enabled; - - const apiPath = '/project/oauth2/stripe'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof apiSecretKey !== 'undefined') { - payload['apiSecretKey'] = apiSecretKey; + apiPayload['apiSecretKey'] = apiSecretKey; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3521,7 +4440,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Tradeshift(params?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Tradeshift(params?: { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Tradeshift configuration. * @@ -3532,53 +4455,69 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Tradeshift(oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean): Promise; updateOAuth2Tradeshift( - paramsOrFirst?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + oauth2ClientId?: string, + oauth2ClientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Tradeshift( + paramsOrFirst?: + | { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; + let params: { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + }; } else { params = { oauth2ClientId: paramsOrFirst as string, oauth2ClientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const oauth2ClientId = params.oauth2ClientId; const oauth2ClientSecret = params.oauth2ClientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/tradeshift'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof oauth2ClientId !== 'undefined') { - payload['oauth2ClientId'] = oauth2ClientId; + apiPayload['oauth2ClientId'] = oauth2ClientId; } if (typeof oauth2ClientSecret !== 'undefined') { - payload['oauth2ClientSecret'] = oauth2ClientSecret; + apiPayload['oauth2ClientSecret'] = oauth2ClientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3590,7 +4529,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2TradeshiftSandbox(params?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2TradeshiftSandbox(params?: { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Tradeshift Sandbox configuration. * @@ -3601,53 +4544,69 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2TradeshiftSandbox(oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean): Promise; updateOAuth2TradeshiftSandbox( - paramsOrFirst?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + oauth2ClientId?: string, + oauth2ClientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2TradeshiftSandbox( + paramsOrFirst?: + | { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; + let params: { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + oauth2ClientId?: string; + oauth2ClientSecret?: string; + enabled?: boolean; + }; } else { params = { oauth2ClientId: paramsOrFirst as string, oauth2ClientSecret: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const oauth2ClientId = params.oauth2ClientId; const oauth2ClientSecret = params.oauth2ClientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/tradeshiftBox'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof oauth2ClientId !== 'undefined') { - payload['oauth2ClientId'] = oauth2ClientId; + apiPayload['oauth2ClientId'] = oauth2ClientId; } if (typeof oauth2ClientSecret !== 'undefined') { - payload['oauth2ClientSecret'] = oauth2ClientSecret; + apiPayload['oauth2ClientSecret'] = oauth2ClientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3659,7 +4618,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Twitch(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Twitch(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Twitch configuration. * @@ -3670,53 +4633,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Twitch(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Twitch( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Twitch( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/twitch'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3728,7 +4703,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2WordPress(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2WordPress(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 WordPress configuration. * @@ -3739,53 +4718,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2WordPress(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2WordPress( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2WordPress( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/wordpress'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3797,7 +4788,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2X(params?: { customerKey?: string, secretKey?: string, enabled?: boolean }): Promise; + updateOAuth2X(params?: { + customerKey?: string; + secretKey?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 X configuration. * @@ -3808,53 +4803,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2X(customerKey?: string, secretKey?: string, enabled?: boolean): Promise; updateOAuth2X( - paramsOrFirst?: { customerKey?: string, secretKey?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + customerKey?: string, + secretKey?: string, + enabled?: boolean, + ): Promise; + updateOAuth2X( + paramsOrFirst?: + | { customerKey?: string; secretKey?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { customerKey?: string, secretKey?: string, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { customerKey?: string, secretKey?: string, enabled?: boolean }; + let params: { + customerKey?: string; + secretKey?: string; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + customerKey?: string; + secretKey?: string; + enabled?: boolean; + }; } else { params = { customerKey: paramsOrFirst as string, secretKey: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, }; } - + const customerKey = params.customerKey; const secretKey = params.secretKey; const enabled = params.enabled; - - const apiPath = '/project/oauth2/x'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof customerKey !== 'undefined') { - payload['customerKey'] = customerKey; + apiPayload['customerKey'] = customerKey; } if (typeof secretKey !== 'undefined') { - payload['secretKey'] = secretKey; + apiPayload['secretKey'] = secretKey; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3866,7 +4873,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Yahoo(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Yahoo(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Yahoo configuration. * @@ -3877,53 +4888,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Yahoo(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Yahoo( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Yahoo( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/yahoo'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3935,7 +4958,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Yandex(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Yandex(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Yandex configuration. * @@ -3946,53 +4973,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Yandex(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Yandex( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Yandex( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/yandex'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4004,7 +5043,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Zoho(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Zoho(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Zoho configuration. * @@ -4015,53 +5058,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Zoho(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Zoho( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Zoho( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/zoho'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4073,7 +5128,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Zoom(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + updateOAuth2Zoom(params?: { + clientId?: string; + clientSecret?: string; + enabled?: boolean; + }): Promise; /** * Update the project OAuth2 Zoom configuration. * @@ -4084,53 +5143,65 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Zoom(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; updateOAuth2Zoom( - paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + clientId?: string, + clientSecret?: string, + enabled?: boolean, + ): Promise; + updateOAuth2Zoom( + paramsOrFirst?: + | { clientId?: string; clientSecret?: string; enabled?: boolean } + | string, + ...rest: [string?, boolean?] ): 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 }; + 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 + enabled: rest[1] as boolean, }; } - + const clientId = params.clientId; const clientSecret = params.clientSecret; const enabled = params.enabled; - - const apiPath = '/project/oauth2/zoom'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { - payload['clientId'] = clientId; + apiPayload['clientId'] = clientId; } if (typeof clientSecret !== 'undefined') { - payload['clientSecret'] = clientSecret; + apiPayload['clientSecret'] = clientSecret; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4138,52 +5209,188 @@ export class Project { * * @param {ProjectOAuthProviderId} params.providerId - OAuth2 provider key. For example: github, google, apple. * @throws {AppwriteException} - * @returns {Promise} - */ - getOAuth2Provider(params: { providerId: ProjectOAuthProviderId }): Promise; + * @returns {Promise} + */ + getOAuth2Provider(params: { + providerId: ProjectOAuthProviderId; + }): Promise< + | Models.OAuth2Github + | Models.OAuth2Discord + | Models.OAuth2Figma + | Models.OAuth2Dropbox + | Models.OAuth2Dailymotion + | Models.OAuth2Bitbucket + | Models.OAuth2Bitly + | Models.OAuth2Box + | Models.OAuth2Autodesk + | Models.OAuth2Google + | Models.OAuth2Zoom + | Models.OAuth2Zoho + | Models.OAuth2Yandex + | Models.OAuth2X + | Models.OAuth2WordPress + | Models.OAuth2Twitch + | Models.OAuth2Stripe + | Models.OAuth2Spotify + | Models.OAuth2Slack + | Models.OAuth2Podio + | Models.OAuth2Notion + | Models.OAuth2Salesforce + | Models.OAuth2Yahoo + | Models.OAuth2HuggingFace + | Models.OAuth2Linkedin + | Models.OAuth2Disqus + | Models.OAuth2Amazon + | Models.OAuth2Etsy + | Models.OAuth2Facebook + | Models.OAuth2Tradeshift + | Models.OAuth2Paypal + | Models.OAuth2Gitlab + | Models.OAuth2Authentik + | Models.OAuth2Auth0 + | Models.OAuth2FusionAuth + | Models.OAuth2Keycloak + | Models.OAuth2Oidc + | Models.OAuth2Apple + | Models.OAuth2Okta + | Models.OAuth2Kick + | Models.OAuth2Microsoft + >; /** * 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(providerId: ProjectOAuthProviderId): Promise; getOAuth2Provider( - paramsOrFirst: { providerId: ProjectOAuthProviderId } | ProjectOAuthProviderId - ): Promise { + providerId: ProjectOAuthProviderId, + ): Promise< + | Models.OAuth2Github + | Models.OAuth2Discord + | Models.OAuth2Figma + | Models.OAuth2Dropbox + | Models.OAuth2Dailymotion + | Models.OAuth2Bitbucket + | Models.OAuth2Bitly + | Models.OAuth2Box + | Models.OAuth2Autodesk + | Models.OAuth2Google + | Models.OAuth2Zoom + | Models.OAuth2Zoho + | Models.OAuth2Yandex + | Models.OAuth2X + | Models.OAuth2WordPress + | Models.OAuth2Twitch + | Models.OAuth2Stripe + | Models.OAuth2Spotify + | Models.OAuth2Slack + | Models.OAuth2Podio + | Models.OAuth2Notion + | Models.OAuth2Salesforce + | Models.OAuth2Yahoo + | Models.OAuth2HuggingFace + | Models.OAuth2Linkedin + | Models.OAuth2Disqus + | Models.OAuth2Amazon + | Models.OAuth2Etsy + | Models.OAuth2Facebook + | Models.OAuth2Tradeshift + | Models.OAuth2Paypal + | Models.OAuth2Gitlab + | Models.OAuth2Authentik + | Models.OAuth2Auth0 + | Models.OAuth2FusionAuth + | Models.OAuth2Keycloak + | Models.OAuth2Oidc + | Models.OAuth2Apple + | Models.OAuth2Okta + | Models.OAuth2Kick + | Models.OAuth2Microsoft + >; + getOAuth2Provider( + paramsOrFirst: + { providerId: ProjectOAuthProviderId } | ProjectOAuthProviderId, + ): Promise< + | Models.OAuth2Github + | Models.OAuth2Discord + | Models.OAuth2Figma + | Models.OAuth2Dropbox + | Models.OAuth2Dailymotion + | Models.OAuth2Bitbucket + | Models.OAuth2Bitly + | Models.OAuth2Box + | Models.OAuth2Autodesk + | Models.OAuth2Google + | Models.OAuth2Zoom + | Models.OAuth2Zoho + | Models.OAuth2Yandex + | Models.OAuth2X + | Models.OAuth2WordPress + | Models.OAuth2Twitch + | Models.OAuth2Stripe + | Models.OAuth2Spotify + | Models.OAuth2Slack + | Models.OAuth2Podio + | Models.OAuth2Notion + | Models.OAuth2Salesforce + | Models.OAuth2Yahoo + | Models.OAuth2HuggingFace + | Models.OAuth2Linkedin + | Models.OAuth2Disqus + | Models.OAuth2Amazon + | Models.OAuth2Etsy + | Models.OAuth2Facebook + | Models.OAuth2Tradeshift + | Models.OAuth2Paypal + | Models.OAuth2Gitlab + | Models.OAuth2Authentik + | Models.OAuth2Auth0 + | Models.OAuth2FusionAuth + | Models.OAuth2Keycloak + | Models.OAuth2Oidc + | Models.OAuth2Apple + | Models.OAuth2Okta + | Models.OAuth2Kick + | Models.OAuth2Microsoft + > { let params: { providerId: ProjectOAuthProviderId }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('providerId' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: ProjectOAuthProviderId }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'providerId' in paramsOrFirst + ) { + params = (paramsOrFirst || {}) as { + providerId: ProjectOAuthProviderId; + }; } else { params = { - providerId: paramsOrFirst as ProjectOAuthProviderId + providerId: paramsOrFirst as ProjectOAuthProviderId, }; } - - const providerId = params.providerId; + const providerId = params.providerId; if (typeof providerId === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerId"'); + throw new AppwriteException( + 'Missing required parameter: "providerId"', + ); } - - const apiPath = '/project/oauth2/{providerId}'.replace('{providerId}', encodeURIComponent(String(providerId))); - const payload: Payload = {}; + const apiPath = '/project/oauth2/{providerId}'.replace( + '{providerId}', + encodeURIComponent(String(providerId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4194,7 +5401,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - listPlatforms(params?: { queries?: string[], total?: boolean }): Promise; + listPlatforms(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all platforms in the project. This endpoint returns an array of all platforms and their configurations. * @@ -4204,47 +5414,51 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listPlatforms(queries?: string[], total?: boolean): Promise; listPlatforms( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listPlatforms( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/project/platforms'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4256,7 +5470,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - createAndroidPlatform(params: { platformId: string, name: string, applicationId: string }): Promise; + createAndroidPlatform(params: { + platformId: string; + name: string; + applicationId: 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. * @@ -4267,62 +5485,73 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createAndroidPlatform(platformId: string, name: string, applicationId: string): Promise; createAndroidPlatform( - paramsOrFirst: { platformId: string, name: string, applicationId: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + applicationId: string, + ): Promise; + createAndroidPlatform( + paramsOrFirst: + | { platformId: string; name: string; applicationId: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, applicationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, applicationId: string }; + let params: { platformId: string; name: string; applicationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + applicationId: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - applicationId: rest[1] as string + applicationId: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof applicationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "applicationId"'); + throw new AppwriteException( + 'Missing required parameter: "applicationId"', + ); } - const apiPath = '/project/platforms/android'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof platformId !== 'undefined') { - payload['platformId'] = platformId; + apiPayload['platformId'] = platformId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof applicationId !== 'undefined') { - payload['applicationId'] = applicationId; + apiPayload['applicationId'] = applicationId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4334,7 +5563,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateAndroidPlatform(params: { platformId: string, name: string, applicationId: string }): Promise; + updateAndroidPlatform(params: { + platformId: string; + name: string; + applicationId: string; + }): Promise; /** * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. * @@ -4345,59 +5578,73 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateAndroidPlatform(platformId: string, name: string, applicationId: string): Promise; updateAndroidPlatform( - paramsOrFirst: { platformId: string, name: string, applicationId: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + applicationId: string, + ): Promise; + updateAndroidPlatform( + paramsOrFirst: + | { platformId: string; name: string; applicationId: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, applicationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, applicationId: string }; + let params: { platformId: string; name: string; applicationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + applicationId: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - applicationId: rest[1] as string + applicationId: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof applicationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "applicationId"'); + throw new AppwriteException( + 'Missing required parameter: "applicationId"', + ); } - - const apiPath = '/project/platforms/android/{platformId}'.replace('{platformId}', encodeURIComponent(String(platformId))); - const payload: Payload = {}; + const apiPath = '/project/platforms/android/{platformId}'.replace( + '{platformId}', + encodeURIComponent(String(platformId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof applicationId !== 'undefined') { - payload['applicationId'] = applicationId; + apiPayload['applicationId'] = applicationId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -4409,7 +5656,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - createApplePlatform(params: { platformId: string, name: string, bundleIdentifier: string }): Promise; + createApplePlatform(params: { + platformId: string; + name: string; + bundleIdentifier: string; + }): Promise; /** * Create a new Apple platform for your project. Use this endpoint to register a new Apple platform where your users will run your application which will interact with the Appwrite API. * @@ -4420,62 +5671,77 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createApplePlatform(platformId: string, name: string, bundleIdentifier: string): Promise; createApplePlatform( - paramsOrFirst: { platformId: string, name: string, bundleIdentifier: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + bundleIdentifier: string, + ): Promise; + createApplePlatform( + paramsOrFirst: + | { platformId: string; name: string; bundleIdentifier: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, bundleIdentifier: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, bundleIdentifier: string }; + let params: { + platformId: string; + name: string; + bundleIdentifier: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + bundleIdentifier: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - bundleIdentifier: rest[1] as string + bundleIdentifier: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const bundleIdentifier = params.bundleIdentifier; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof bundleIdentifier === 'undefined') { - throw new AppwriteException('Missing required parameter: "bundleIdentifier"'); + throw new AppwriteException( + 'Missing required parameter: "bundleIdentifier"', + ); } - const apiPath = '/project/platforms/apple'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof platformId !== 'undefined') { - payload['platformId'] = platformId; + apiPayload['platformId'] = platformId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof bundleIdentifier !== 'undefined') { - payload['bundleIdentifier'] = bundleIdentifier; + apiPayload['bundleIdentifier'] = bundleIdentifier; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4487,7 +5753,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateApplePlatform(params: { platformId: string, name: string, bundleIdentifier: string }): Promise; + updateApplePlatform(params: { + platformId: string; + name: string; + bundleIdentifier: string; + }): Promise; /** * Update an Apple platform by its unique ID. Use this endpoint to update the platform's name or bundle identifier. * @@ -4498,59 +5768,77 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateApplePlatform(platformId: string, name: string, bundleIdentifier: string): Promise; updateApplePlatform( - paramsOrFirst: { platformId: string, name: string, bundleIdentifier: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + bundleIdentifier: string, + ): Promise; + updateApplePlatform( + paramsOrFirst: + | { platformId: string; name: string; bundleIdentifier: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, bundleIdentifier: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, bundleIdentifier: string }; + let params: { + platformId: string; + name: string; + bundleIdentifier: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + bundleIdentifier: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - bundleIdentifier: rest[1] as string + bundleIdentifier: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const bundleIdentifier = params.bundleIdentifier; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof bundleIdentifier === 'undefined') { - throw new AppwriteException('Missing required parameter: "bundleIdentifier"'); + throw new AppwriteException( + 'Missing required parameter: "bundleIdentifier"', + ); } - - const apiPath = '/project/platforms/apple/{platformId}'.replace('{platformId}', encodeURIComponent(String(platformId))); - const payload: Payload = {}; + const apiPath = '/project/platforms/apple/{platformId}'.replace( + '{platformId}', + encodeURIComponent(String(platformId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof bundleIdentifier !== 'undefined') { - payload['bundleIdentifier'] = bundleIdentifier; + apiPayload['bundleIdentifier'] = bundleIdentifier; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -4562,7 +5850,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - createLinuxPlatform(params: { platformId: string, name: string, packageName: string }): Promise; + createLinuxPlatform(params: { + platformId: string; + name: string; + packageName: string; + }): Promise; /** * Create a new Linux platform for your project. Use this endpoint to register a new Linux platform where your users will run your application which will interact with the Appwrite API. * @@ -4573,62 +5865,72 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createLinuxPlatform(platformId: string, name: string, packageName: string): Promise; createLinuxPlatform( - paramsOrFirst: { platformId: string, name: string, packageName: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + packageName: string, + ): Promise; + createLinuxPlatform( + paramsOrFirst: + { platformId: string; name: string; packageName: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, packageName: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, packageName: string }; + let params: { platformId: string; name: string; packageName: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + packageName: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - packageName: rest[1] as string + packageName: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const packageName = params.packageName; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof packageName === 'undefined') { - throw new AppwriteException('Missing required parameter: "packageName"'); + throw new AppwriteException( + 'Missing required parameter: "packageName"', + ); } - const apiPath = '/project/platforms/linux'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof platformId !== 'undefined') { - payload['platformId'] = platformId; + apiPayload['platformId'] = platformId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof packageName !== 'undefined') { - payload['packageName'] = packageName; + apiPayload['packageName'] = packageName; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4640,7 +5942,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateLinuxPlatform(params: { platformId: string, name: string, packageName: string }): Promise; + updateLinuxPlatform(params: { + platformId: string; + name: string; + packageName: string; + }): Promise; /** * Update a Linux platform by its unique ID. Use this endpoint to update the platform's name or package name. * @@ -4651,59 +5957,72 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateLinuxPlatform(platformId: string, name: string, packageName: string): Promise; updateLinuxPlatform( - paramsOrFirst: { platformId: string, name: string, packageName: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + packageName: string, + ): Promise; + updateLinuxPlatform( + paramsOrFirst: + { platformId: string; name: string; packageName: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, packageName: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, packageName: string }; + let params: { platformId: string; name: string; packageName: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + packageName: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - packageName: rest[1] as string + packageName: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const packageName = params.packageName; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof packageName === 'undefined') { - throw new AppwriteException('Missing required parameter: "packageName"'); + throw new AppwriteException( + 'Missing required parameter: "packageName"', + ); } - - const apiPath = '/project/platforms/linux/{platformId}'.replace('{platformId}', encodeURIComponent(String(platformId))); - const payload: Payload = {}; + const apiPath = '/project/platforms/linux/{platformId}'.replace( + '{platformId}', + encodeURIComponent(String(platformId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof packageName !== 'undefined') { - payload['packageName'] = packageName; + apiPayload['packageName'] = packageName; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -4715,7 +6034,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - createWebPlatform(params: { platformId: string, name: string, hostname: string }): Promise; + createWebPlatform(params: { + platformId: string; + name: string; + hostname: string; + }): Promise; /** * Create a new web platform for your project. Use this endpoint to register a new platform where your users will run your application which will interact with the Appwrite API. * @@ -4726,62 +6049,72 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createWebPlatform(platformId: string, name: string, hostname: string): Promise; createWebPlatform( - paramsOrFirst: { platformId: string, name: string, hostname: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + hostname: string, + ): Promise; + createWebPlatform( + paramsOrFirst: + { platformId: string; name: string; hostname: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, hostname: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, hostname: string }; + let params: { platformId: string; name: string; hostname: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + hostname: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - hostname: rest[1] as string + hostname: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const hostname = params.hostname; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof hostname === 'undefined') { - throw new AppwriteException('Missing required parameter: "hostname"'); + throw new AppwriteException( + 'Missing required parameter: "hostname"', + ); } - const apiPath = '/project/platforms/web'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof platformId !== 'undefined') { - payload['platformId'] = platformId; + apiPayload['platformId'] = platformId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof hostname !== 'undefined') { - payload['hostname'] = hostname; + apiPayload['hostname'] = hostname; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4793,7 +6126,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateWebPlatform(params: { platformId: string, name: string, hostname: string }): Promise; + updateWebPlatform(params: { + platformId: string; + name: string; + hostname: string; + }): Promise; /** * Update a web platform by its unique ID. Use this endpoint to update the platform's name or hostname. * @@ -4804,59 +6141,72 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateWebPlatform(platformId: string, name: string, hostname: string): Promise; updateWebPlatform( - paramsOrFirst: { platformId: string, name: string, hostname: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + hostname: string, + ): Promise; + updateWebPlatform( + paramsOrFirst: + { platformId: string; name: string; hostname: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, hostname: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, hostname: string }; + let params: { platformId: string; name: string; hostname: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + hostname: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - hostname: rest[1] as string + hostname: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const hostname = params.hostname; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof hostname === 'undefined') { - throw new AppwriteException('Missing required parameter: "hostname"'); + throw new AppwriteException( + 'Missing required parameter: "hostname"', + ); } - - const apiPath = '/project/platforms/web/{platformId}'.replace('{platformId}', encodeURIComponent(String(platformId))); - const payload: Payload = {}; + const apiPath = '/project/platforms/web/{platformId}'.replace( + '{platformId}', + encodeURIComponent(String(platformId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof hostname !== 'undefined') { - payload['hostname'] = hostname; + apiPayload['hostname'] = hostname; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -4868,7 +6218,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - createWindowsPlatform(params: { platformId: string, name: string, packageIdentifierName: string }): Promise; + createWindowsPlatform(params: { + platformId: string; + name: string; + packageIdentifierName: string; + }): Promise; /** * Create a new Windows platform for your project. Use this endpoint to register a new Windows platform where your users will run your application which will interact with the Appwrite API. * @@ -4879,62 +6233,81 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createWindowsPlatform(platformId: string, name: string, packageIdentifierName: string): Promise; createWindowsPlatform( - paramsOrFirst: { platformId: string, name: string, packageIdentifierName: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + packageIdentifierName: string, + ): Promise; + createWindowsPlatform( + paramsOrFirst: + | { + platformId: string; + name: string; + packageIdentifierName: string; + } + | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, packageIdentifierName: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, packageIdentifierName: string }; + let params: { + platformId: string; + name: string; + packageIdentifierName: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + packageIdentifierName: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - packageIdentifierName: rest[1] as string + packageIdentifierName: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const packageIdentifierName = params.packageIdentifierName; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof packageIdentifierName === 'undefined') { - throw new AppwriteException('Missing required parameter: "packageIdentifierName"'); + throw new AppwriteException( + 'Missing required parameter: "packageIdentifierName"', + ); } - const apiPath = '/project/platforms/windows'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof platformId !== 'undefined') { - payload['platformId'] = platformId; + apiPayload['platformId'] = platformId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof packageIdentifierName !== 'undefined') { - payload['packageIdentifierName'] = packageIdentifierName; + apiPayload['packageIdentifierName'] = packageIdentifierName; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4946,7 +6319,11 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateWindowsPlatform(params: { platformId: string, name: string, packageIdentifierName: string }): Promise; + updateWindowsPlatform(params: { + platformId: string; + name: string; + packageIdentifierName: string; + }): Promise; /** * Update a Windows platform by its unique ID. Use this endpoint to update the platform's name or package identifier name. * @@ -4957,59 +6334,81 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateWindowsPlatform(platformId: string, name: string, packageIdentifierName: string): Promise; updateWindowsPlatform( - paramsOrFirst: { platformId: string, name: string, packageIdentifierName: string } | string, - ...rest: [(string)?, (string)?] + platformId: string, + name: string, + packageIdentifierName: string, + ): Promise; + updateWindowsPlatform( + paramsOrFirst: + | { + platformId: string; + name: string; + packageIdentifierName: string; + } + | string, + ...rest: [string?, string?] ): Promise { - let params: { platformId: string, name: string, packageIdentifierName: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, packageIdentifierName: string }; + let params: { + platformId: string; + name: string; + packageIdentifierName: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + platformId: string; + name: string; + packageIdentifierName: string; + }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, - packageIdentifierName: rest[1] as string + packageIdentifierName: rest[1] as string, }; } - + const platformId = params.platformId; const name = params.name; const packageIdentifierName = params.packageIdentifierName; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof packageIdentifierName === 'undefined') { - throw new AppwriteException('Missing required parameter: "packageIdentifierName"'); + throw new AppwriteException( + 'Missing required parameter: "packageIdentifierName"', + ); } - - const apiPath = '/project/platforms/windows/{platformId}'.replace('{platformId}', encodeURIComponent(String(platformId))); - const payload: Payload = {}; + const apiPath = '/project/platforms/windows/{platformId}'.replace( + '{platformId}', + encodeURIComponent(String(platformId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof packageIdentifierName !== 'undefined') { - payload['packageIdentifierName'] = packageIdentifierName; + apiPayload['packageIdentifierName'] = packageIdentifierName; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -5019,7 +6418,15 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - getPlatform(params: { platformId: string }): Promise; + getPlatform(params: { + platformId: string; + }): Promise< + | Models.PlatformWeb + | Models.PlatformApple + | Models.PlatformAndroid + | Models.PlatformWindows + | Models.PlatformLinux + >; /** * Get a platform by its unique ID. This endpoint returns the platform's details, including its name, type, and key configurations. * @@ -5028,41 +6435,57 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getPlatform(platformId: string): Promise; getPlatform( - paramsOrFirst: { platformId: string } | string - ): Promise { + platformId: string, + ): Promise< + | Models.PlatformWeb + | Models.PlatformApple + | Models.PlatformAndroid + | Models.PlatformWindows + | Models.PlatformLinux + >; + getPlatform( + paramsOrFirst: { platformId: string } | string, + ): Promise< + | Models.PlatformWeb + | Models.PlatformApple + | Models.PlatformAndroid + | Models.PlatformWindows + | Models.PlatformLinux + > { let params: { platformId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { platformId: string }; } else { params = { - platformId: paramsOrFirst as string + platformId: paramsOrFirst as string, }; } - - const platformId = params.platformId; + const platformId = params.platformId; if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } - - const apiPath = '/project/platforms/{platformId}'.replace('{platformId}', encodeURIComponent(String(platformId))); - const payload: Payload = {}; + const apiPath = '/project/platforms/{platformId}'.replace( + '{platformId}', + encodeURIComponent(String(platformId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -5083,39 +6506,41 @@ export class Project { */ deletePlatform(platformId: string): Promise<{}>; deletePlatform( - paramsOrFirst: { platformId: string } | string + paramsOrFirst: { platformId: string } | string, ): Promise<{}> { let params: { platformId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { platformId: string }; } else { params = { - platformId: paramsOrFirst as string + platformId: paramsOrFirst as string, }; } - - const platformId = params.platformId; + const platformId = params.platformId; if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + throw new AppwriteException( + 'Missing required parameter: "platformId"', + ); } - - const apiPath = '/project/platforms/{platformId}'.replace('{platformId}', encodeURIComponent(String(platformId))); - const payload: Payload = {}; + const apiPath = '/project/platforms/{platformId}'.replace( + '{platformId}', + encodeURIComponent(String(platformId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -5126,7 +6551,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - listPolicies(params?: { queries?: string[], total?: boolean }): Promise; + listPolicies(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all project policies and their current configuration. * @@ -5136,47 +6564,51 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listPolicies(queries?: string[], total?: boolean): Promise; listPolicies( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listPolicies( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/project/policies'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -5186,7 +6618,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateDenyAliasedEmailPolicy(params: { enabled: boolean }): Promise; + updateDenyAliasedEmailPolicy(params: { + enabled: boolean; + }): Promise; /** * Configures if aliased emails such as subaddresses and emails with suffixes are denied during new users sign-ups and email updates. * @@ -5197,43 +6631,42 @@ export class Project { */ updateDenyAliasedEmailPolicy(enabled: boolean): Promise; updateDenyAliasedEmailPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - - const enabled = params.enabled; + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/deny-aliased-email'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5243,7 +6676,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateDenyCorporateEmailPolicy(params: { enabled: boolean }): Promise; + updateDenyCorporateEmailPolicy(params: { + enabled: boolean; + }): Promise; /** * Configures if only corporate email addresses (non-free and non-disposable domains) are allowed during new user sign-ups and email updates. * @@ -5254,43 +6689,42 @@ export class Project { */ updateDenyCorporateEmailPolicy(enabled: boolean): Promise; updateDenyCorporateEmailPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - - const enabled = params.enabled; + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/deny-corporate-email'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5300,7 +6734,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateDenyDisposableEmailPolicy(params: { enabled: boolean }): Promise; + updateDenyDisposableEmailPolicy(params: { + enabled: boolean; + }): Promise; /** * Configures if disposable emails from known temporary domains are denied during new users sign-ups and email updates. * @@ -5311,43 +6747,42 @@ export class Project { */ updateDenyDisposableEmailPolicy(enabled: boolean): Promise; updateDenyDisposableEmailPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - - const enabled = params.enabled; + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/deny-disposable-email'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5357,7 +6792,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateDenyFreeEmailPolicy(params: { enabled: boolean }): Promise; + updateDenyFreeEmailPolicy(params: { + enabled: boolean; + }): Promise; /** * Configures if emails from free providers such as Gmail or Yahoo are denied during new users sign-ups and email updates. * @@ -5368,43 +6805,42 @@ export class Project { */ updateDenyFreeEmailPolicy(enabled: boolean): Promise; updateDenyFreeEmailPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - - const enabled = params.enabled; + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/deny-free-email'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5419,7 +6855,14 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateMembershipPrivacyPolicy(params?: { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean, userAccessedAt?: boolean }): Promise; + updateMembershipPrivacyPolicy(params?: { + userId?: boolean; + userEmail?: boolean; + userPhone?: boolean; + userName?: boolean; + userMFA?: boolean; + userAccessedAt?: boolean; + }): Promise; /** * Updating this policy allows you to control if team members can see other members information. When enabled, all team members can see ID, name, email, phone number, and MFA status of other members.. * @@ -5433,15 +6876,50 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMembershipPrivacyPolicy(userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean, userAccessedAt?: boolean): Promise; updateMembershipPrivacyPolicy( - paramsOrFirst?: { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean, userAccessedAt?: boolean } | boolean, - ...rest: [(boolean)?, (boolean)?, (boolean)?, (boolean)?, (boolean)?] + userId?: boolean, + userEmail?: boolean, + userPhone?: boolean, + userName?: boolean, + userMFA?: boolean, + userAccessedAt?: boolean, + ): Promise; + updateMembershipPrivacyPolicy( + paramsOrFirst?: + | { + userId?: boolean; + userEmail?: boolean; + userPhone?: boolean; + userName?: boolean; + userMFA?: boolean; + userAccessedAt?: boolean; + } + | boolean, + ...rest: [boolean?, boolean?, boolean?, boolean?, boolean?] ): Promise { - let params: { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean, userAccessedAt?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean, userAccessedAt?: boolean }; + let params: { + userId?: boolean; + userEmail?: boolean; + userPhone?: boolean; + userName?: boolean; + userMFA?: boolean; + userAccessedAt?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + userId?: boolean; + userEmail?: boolean; + userPhone?: boolean; + userName?: boolean; + userMFA?: boolean; + userAccessedAt?: boolean; + }; } else { params = { userId: paramsOrFirst as boolean, @@ -5449,52 +6927,45 @@ export class Project { userPhone: rest[1] as boolean, userName: rest[2] as boolean, userMFA: rest[3] as boolean, - userAccessedAt: rest[4] as boolean + userAccessedAt: rest[4] as boolean, }; } - + const userId = params.userId; const userEmail = params.userEmail; const userPhone = params.userPhone; const userName = params.userName; const userMFA = params.userMFA; const userAccessedAt = params.userAccessedAt; - - const apiPath = '/project/policies/membership-privacy'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof userEmail !== 'undefined') { - payload['userEmail'] = userEmail; + apiPayload['userEmail'] = userEmail; } if (typeof userPhone !== 'undefined') { - payload['userPhone'] = userPhone; + apiPayload['userPhone'] = userPhone; } if (typeof userName !== 'undefined') { - payload['userName'] = userName; + apiPayload['userName'] = userName; } if (typeof userMFA !== 'undefined') { - payload['userMFA'] = userMFA; + apiPayload['userMFA'] = userMFA; } if (typeof userAccessedAt !== 'undefined') { - payload['userAccessedAt'] = userAccessedAt; + apiPayload['userAccessedAt'] = userAccessedAt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5507,7 +6978,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateMFAFactorsPolicy(params?: { totp?: boolean, email?: boolean, phone?: boolean, custom?: boolean }): Promise; + updateMFAFactorsPolicy(params?: { + totp?: boolean; + email?: boolean; + phone?: boolean; + custom?: boolean; + }): Promise; /** * Updating this policy allows you to control which factors users can use to complete an MFA challenge. Disabled factors cannot be used to create a challenge and are reported as unavailable when listing factors. The custom factor is disabled by default; enable it to deliver challenge codes through your own channel. Recovery codes always remain available as a fallback. * @@ -5519,58 +6995,78 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMFAFactorsPolicy(totp?: boolean, email?: boolean, phone?: boolean, custom?: boolean): Promise; updateMFAFactorsPolicy( - paramsOrFirst?: { totp?: boolean, email?: boolean, phone?: boolean, custom?: boolean } | boolean, - ...rest: [(boolean)?, (boolean)?, (boolean)?] + totp?: boolean, + email?: boolean, + phone?: boolean, + custom?: boolean, + ): Promise; + updateMFAFactorsPolicy( + paramsOrFirst?: + | { + totp?: boolean; + email?: boolean; + phone?: boolean; + custom?: boolean; + } + | boolean, + ...rest: [boolean?, boolean?, boolean?] ): Promise { - let params: { totp?: boolean, email?: boolean, phone?: boolean, custom?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { totp?: boolean, email?: boolean, phone?: boolean, custom?: boolean }; + let params: { + totp?: boolean; + email?: boolean; + phone?: boolean; + custom?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + totp?: boolean; + email?: boolean; + phone?: boolean; + custom?: boolean; + }; } else { params = { totp: paramsOrFirst as boolean, email: rest[0] as boolean, phone: rest[1] as boolean, - custom: rest[2] as boolean + custom: rest[2] as boolean, }; } - + const totp = params.totp; const email = params.email; const phone = params.phone; const custom = params.custom; - - const apiPath = '/project/policies/mfa-factors'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof totp !== 'undefined') { - payload['totp'] = totp; + apiPayload['totp'] = totp; } if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof phone !== 'undefined') { - payload['phone'] = phone; + apiPayload['phone'] = phone; } if (typeof custom !== 'undefined') { - payload['custom'] = custom; + apiPayload['custom'] = custom; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5580,7 +7076,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updatePasswordDictionaryPolicy(params: { enabled: boolean }): Promise; + updatePasswordDictionaryPolicy(params: { + enabled: boolean; + }): Promise; /** * Updating this policy allows you to control if new passwords are checked against most common passwords dictionary. When enabled, and user changes their password, password must not be contained in the dictionary. * @@ -5591,58 +7089,59 @@ export class Project { */ updatePasswordDictionaryPolicy(enabled: boolean): Promise; updatePasswordDictionaryPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - - const enabled = params.enabled; + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/password-dictionary'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Updates one of password strength policies. Based on total length configured, previous password hashes are stored, and users cannot choose a new password that is already stored in the passwird history list, when updating an user password, or setting new one through password recovery. - * + * * Keep in mind, while password history policy is disabled, the history is not being stored. Enabling the policy will not have any history on existing users, and it will only start to collect and enforce the policy on password changes since the policy is enabled. * * @param {number} params.total - Set the password history length per user. Value can be between 1 and 20, or null to disable the limit. * @throws {AppwriteException} * @returns {Promise} */ - updatePasswordHistoryPolicy(params: { total?: number }): Promise; + updatePasswordHistoryPolicy(params: { + total?: number; + }): Promise; /** * Updates one of password strength policies. Based on total length configured, previous password hashes are stored, and users cannot choose a new password that is already stored in the passwird history list, when updating an user password, or setting new one through password recovery. - * + * * Keep in mind, while password history policy is disabled, the history is not being stored. Enabling the policy will not have any history on existing users, and it will only start to collect and enforce the policy on password changes since the policy is enabled. * * @param {number} total - Set the password history length per user. Value can be between 1 and 20, or null to disable the limit. @@ -5652,43 +7151,40 @@ export class Project { */ updatePasswordHistoryPolicy(total?: number): Promise; updatePasswordHistoryPolicy( - paramsOrFirst?: { total?: number } | number + paramsOrFirst?: { total?: number } | number, ): Promise { let params: { total?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { total?: number }; } else { params = { - total: paramsOrFirst as number + total: paramsOrFirst as number, }; } - - const total = params.total; + const total = params.total; if (typeof total === 'undefined') { throw new AppwriteException('Missing required parameter: "total"'); } - const apiPath = '/project/policies/password-history'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof total !== 'undefined') { - payload['total'] = total; + apiPayload['total'] = total; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5698,7 +7194,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updatePasswordPersonalDataPolicy(params: { enabled: boolean }): Promise; + updatePasswordPersonalDataPolicy(params: { + enabled: boolean; + }): Promise; /** * Updating this policy allows you to control if password strength is checked against personal data. When enabled, and user sets or changes their password, the password must not contain user ID, name, email or phone number. * @@ -5709,43 +7207,42 @@ export class Project { */ updatePasswordPersonalDataPolicy(enabled: boolean): Promise; updatePasswordPersonalDataPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - - const enabled = params.enabled; + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/password-personal-data'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5759,7 +7256,13 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updatePasswordStrengthPolicy(params?: { min?: number, uppercase?: boolean, lowercase?: boolean, number?: boolean, symbols?: boolean }): Promise; + updatePasswordStrengthPolicy(params?: { + min?: number; + uppercase?: boolean; + lowercase?: boolean; + number?: boolean; + symbols?: boolean; + }): Promise; /** * Update the password strength requirements for users in the project. * @@ -5772,63 +7275,87 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePasswordStrengthPolicy(min?: number, uppercase?: boolean, lowercase?: boolean, number?: boolean, symbols?: boolean): Promise; updatePasswordStrengthPolicy( - paramsOrFirst?: { min?: number, uppercase?: boolean, lowercase?: boolean, number?: boolean, symbols?: boolean } | number, - ...rest: [(boolean)?, (boolean)?, (boolean)?, (boolean)?] + min?: number, + uppercase?: boolean, + lowercase?: boolean, + number?: boolean, + symbols?: boolean, + ): Promise; + updatePasswordStrengthPolicy( + paramsOrFirst?: + | { + min?: number; + uppercase?: boolean; + lowercase?: boolean; + number?: boolean; + symbols?: boolean; + } + | number, + ...rest: [boolean?, boolean?, boolean?, boolean?] ): Promise { - let params: { min?: number, uppercase?: boolean, lowercase?: boolean, number?: boolean, symbols?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { min?: number, uppercase?: boolean, lowercase?: boolean, number?: boolean, symbols?: boolean }; + let params: { + min?: number; + uppercase?: boolean; + lowercase?: boolean; + number?: boolean; + symbols?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + min?: number; + uppercase?: boolean; + lowercase?: boolean; + number?: boolean; + symbols?: boolean; + }; } else { params = { min: paramsOrFirst as number, uppercase: rest[0] as boolean, lowercase: rest[1] as boolean, number: rest[2] as boolean, - symbols: rest[3] as boolean + symbols: rest[3] as boolean, }; } - + const min = params.min; const uppercase = params.uppercase; const lowercase = params.lowercase; const number = params.number; const symbols = params.symbols; - - const apiPath = '/project/policies/password-strength'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof min !== 'undefined') { - payload['min'] = min; + apiPayload['min'] = min; } if (typeof uppercase !== 'undefined') { - payload['uppercase'] = uppercase; + apiPayload['uppercase'] = uppercase; } if (typeof lowercase !== 'undefined') { - payload['lowercase'] = lowercase; + apiPayload['lowercase'] = lowercase; } if (typeof number !== 'undefined') { - payload['number'] = number; + apiPayload['number'] = number; } if (typeof symbols !== 'undefined') { - payload['symbols'] = symbols; + apiPayload['symbols'] = symbols; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5838,7 +7365,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateSessionAlertPolicy(params: { enabled: boolean }): Promise; + updateSessionAlertPolicy(params: { + enabled: boolean; + }): Promise; /** * Updating this policy allows you to control if email alert is sent upon session creation. When enabled, and user signs into their account, they will be sent an email notification. There is an exception, the first session after a new sign up does not trigger an alert, even if the policy is enabled. * @@ -5849,43 +7378,42 @@ export class Project { */ updateSessionAlertPolicy(enabled: boolean): Promise; updateSessionAlertPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - - const enabled = params.enabled; + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/session-alert'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5895,7 +7423,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateSessionDurationPolicy(params: { duration: number }): Promise; + updateSessionDurationPolicy(params: { + duration: number; + }): Promise; /** * Update maximum duration how long sessions created within a project should stay active for. * @@ -5906,43 +7436,42 @@ export class Project { */ updateSessionDurationPolicy(duration: number): Promise; updateSessionDurationPolicy( - paramsOrFirst: { duration: number } | number + paramsOrFirst: { duration: number } | number, ): Promise { let params: { duration: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { duration: number }; } else { params = { - duration: paramsOrFirst as number + duration: paramsOrFirst as number, }; } - - const duration = params.duration; + const duration = params.duration; if (typeof duration === 'undefined') { - throw new AppwriteException('Missing required parameter: "duration"'); + throw new AppwriteException( + 'Missing required parameter: "duration"', + ); } - const apiPath = '/project/policies/session-duration'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof duration !== 'undefined') { - payload['duration'] = duration; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5952,7 +7481,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateSessionInvalidationPolicy(params: { enabled: boolean }): Promise; + updateSessionInvalidationPolicy(params: { + enabled: boolean; + }): Promise; /** * Updating this policy allows you to control if existing sessions should be invalidated when a password of a user is changed. When enabled, and user changes their password, they will be logged out of all their devices. * @@ -5963,43 +7494,42 @@ export class Project { */ updateSessionInvalidationPolicy(enabled: boolean): Promise; updateSessionInvalidationPolicy( - paramsOrFirst: { enabled: boolean } | boolean + paramsOrFirst: { enabled: boolean } | boolean, ): Promise { let params: { enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - enabled: paramsOrFirst as boolean + enabled: paramsOrFirst as boolean, }; } - - const enabled = params.enabled; + const enabled = params.enabled; if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - const apiPath = '/project/policies/session-invalidation'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6009,7 +7539,9 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateSessionLimitPolicy(params: { total: number }): Promise; + updateSessionLimitPolicy(params: { + total: number; + }): Promise; /** * Update the maximum number of sessions allowed per user. When the limit is hit, the oldest session will be deleted to make room for new one. * @@ -6020,43 +7552,40 @@ export class Project { */ updateSessionLimitPolicy(total: number): Promise; updateSessionLimitPolicy( - paramsOrFirst: { total: number } | number + paramsOrFirst: { total: number } | number, ): Promise { let params: { total: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { total: number }; } else { params = { - total: paramsOrFirst as number + total: paramsOrFirst as number, }; } - - const total = params.total; + const total = params.total; if (typeof total === 'undefined') { throw new AppwriteException('Missing required parameter: "total"'); } - const apiPath = '/project/policies/session-limit'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof total !== 'undefined') { - payload['total'] = total; + apiPayload['total'] = total; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6077,43 +7606,40 @@ export class Project { */ updateUserLimitPolicy(total?: number): Promise; updateUserLimitPolicy( - paramsOrFirst?: { total?: number } | number + paramsOrFirst?: { total?: number } | number, ): Promise { let params: { total?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { total?: number }; } else { params = { - total: paramsOrFirst as number + total: paramsOrFirst as number, }; } - - const total = params.total; + const total = params.total; if (typeof total === 'undefined') { throw new AppwriteException('Missing required parameter: "total"'); } - const apiPath = '/project/policies/user-limit'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof total !== 'undefined') { - payload['total'] = total; + apiPayload['total'] = total; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6123,7 +7649,25 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - getPolicy(params: { policyId: ProjectPolicyId }): Promise; + getPolicy(params: { + policyId: ProjectPolicyId; + }): Promise< + | Models.PolicyPasswordDictionary + | Models.PolicyPasswordHistory + | Models.PolicyPasswordStrength + | Models.PolicyPasswordPersonalData + | Models.PolicySessionAlert + | Models.PolicySessionDuration + | Models.PolicySessionInvalidation + | Models.PolicySessionLimit + | Models.PolicyUserLimit + | Models.PolicyMembershipPrivacy + | Models.PolicyMfaFactors + | Models.PolicyDenyAliasedEmail + | Models.PolicyDenyDisposableEmail + | Models.PolicyDenyFreeEmail + | Models.PolicyDenyCorporateEmail + >; /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * @@ -6132,54 +7676,94 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getPolicy(policyId: ProjectPolicyId): Promise; getPolicy( - paramsOrFirst: { policyId: ProjectPolicyId } | ProjectPolicyId - ): Promise { + policyId: ProjectPolicyId, + ): Promise< + | Models.PolicyPasswordDictionary + | Models.PolicyPasswordHistory + | Models.PolicyPasswordStrength + | Models.PolicyPasswordPersonalData + | Models.PolicySessionAlert + | Models.PolicySessionDuration + | Models.PolicySessionInvalidation + | Models.PolicySessionLimit + | Models.PolicyUserLimit + | Models.PolicyMembershipPrivacy + | Models.PolicyMfaFactors + | Models.PolicyDenyAliasedEmail + | Models.PolicyDenyDisposableEmail + | Models.PolicyDenyFreeEmail + | Models.PolicyDenyCorporateEmail + >; + getPolicy( + paramsOrFirst: { policyId: ProjectPolicyId } | ProjectPolicyId, + ): Promise< + | Models.PolicyPasswordDictionary + | Models.PolicyPasswordHistory + | Models.PolicyPasswordStrength + | Models.PolicyPasswordPersonalData + | Models.PolicySessionAlert + | Models.PolicySessionDuration + | Models.PolicySessionInvalidation + | Models.PolicySessionLimit + | Models.PolicyUserLimit + | Models.PolicyMembershipPrivacy + | Models.PolicyMfaFactors + | Models.PolicyDenyAliasedEmail + | Models.PolicyDenyDisposableEmail + | Models.PolicyDenyFreeEmail + | Models.PolicyDenyCorporateEmail + > { let params: { policyId: ProjectPolicyId }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('policyId' in paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + 'policyId' in paramsOrFirst + ) { params = (paramsOrFirst || {}) as { policyId: ProjectPolicyId }; } else { params = { - policyId: paramsOrFirst as ProjectPolicyId + policyId: paramsOrFirst as ProjectPolicyId, }; } - - const policyId = params.policyId; + const policyId = params.policyId; if (typeof policyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "policyId"'); + throw new AppwriteException( + 'Missing required parameter: "policyId"', + ); } - - const apiPath = '/project/policies/{policyId}'.replace('{policyId}', encodeURIComponent(String(policyId))); - const payload: Payload = {}; + const apiPath = '/project/policies/{policyId}'.replace( + '{policyId}', + encodeURIComponent(String(policyId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** - * Update properties of a specific protocol. Use this endpoint to enable or disable a protocol in your project. + * Update properties of a specific protocol. Use this endpoint to enable or disable a protocol in your project. * * @param {ProjectProtocolId} params.protocolId - Protocol name. Can be one of: rest, graphql, websocket * @param {boolean} params.enabled - Protocol status. * @throws {AppwriteException} * @returns {Promise} */ - updateProtocol(params: { protocolId: ProjectProtocolId, enabled: boolean }): Promise; + updateProtocol(params: { + protocolId: ProjectProtocolId; + enabled: boolean; + }): Promise; /** - * Update properties of a specific protocol. Use this endpoint to enable or disable a protocol in your project. + * Update properties of a specific protocol. Use this endpoint to enable or disable a protocol in your project. * * @param {ProjectProtocolId} protocolId - Protocol name. Can be one of: rest, graphql, websocket * @param {boolean} enabled - Protocol status. @@ -6187,64 +7771,80 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateProtocol(protocolId: ProjectProtocolId, enabled: boolean): Promise; updateProtocol( - paramsOrFirst: { protocolId: ProjectProtocolId, enabled: boolean } | ProjectProtocolId, - ...rest: [(boolean)?] + protocolId: ProjectProtocolId, + enabled: boolean, + ): Promise; + updateProtocol( + paramsOrFirst: + | { protocolId: ProjectProtocolId; enabled: boolean } + | ProjectProtocolId, + ...rest: [boolean?] ): Promise { - let params: { protocolId: ProjectProtocolId, enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('protocolId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { protocolId: ProjectProtocolId, enabled: boolean }; + let params: { protocolId: ProjectProtocolId; enabled: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('protocolId' in paramsOrFirst || 'enabled' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + protocolId: ProjectProtocolId; + enabled: boolean; + }; } else { params = { protocolId: paramsOrFirst as ProjectProtocolId, - enabled: rest[0] as boolean + enabled: rest[0] as boolean, }; } - + const protocolId = params.protocolId; const enabled = params.enabled; - if (typeof protocolId === 'undefined') { - throw new AppwriteException('Missing required parameter: "protocolId"'); + throw new AppwriteException( + 'Missing required parameter: "protocolId"', + ); } if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - - const apiPath = '/project/protocols/{protocolId}'.replace('{protocolId}', encodeURIComponent(String(protocolId))); - const payload: Payload = {}; + const apiPath = '/project/protocols/{protocolId}'.replace( + '{protocolId}', + encodeURIComponent(String(protocolId)), + ); + const apiPayload: Payload = {}; if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** - * Update properties of a specific service. Use this endpoint to enable or disable a service in your project. + * Update properties of a specific service. Use this endpoint to enable or disable a service in your project. * * @param {ProjectServiceId} params.serviceId - Service name. Can be one of: account, avatars, databases, tablesdb, locale, health, project, storage, teams, users, vcs, sites, functions, proxy, graphql, migrations, messaging, advisor, oauth2 * @param {boolean} params.enabled - Service status. * @throws {AppwriteException} * @returns {Promise} */ - updateService(params: { serviceId: ProjectServiceId, enabled: boolean }): Promise; + updateService(params: { + serviceId: ProjectServiceId; + enabled: boolean; + }): Promise; /** - * Update properties of a specific service. Use this endpoint to enable or disable a service in your project. + * Update properties of a specific service. Use this endpoint to enable or disable a service in your project. * * @param {ProjectServiceId} serviceId - Service name. Can be one of: account, avatars, databases, tablesdb, locale, health, project, storage, teams, users, vcs, sites, functions, proxy, graphql, migrations, messaging, advisor, oauth2 * @param {boolean} enabled - Service status. @@ -6252,51 +7852,64 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateService(serviceId: ProjectServiceId, enabled: boolean): Promise; updateService( - paramsOrFirst: { serviceId: ProjectServiceId, enabled: boolean } | ProjectServiceId, - ...rest: [(boolean)?] + serviceId: ProjectServiceId, + enabled: boolean, + ): Promise; + updateService( + paramsOrFirst: + | { serviceId: ProjectServiceId; enabled: boolean } + | ProjectServiceId, + ...rest: [boolean?] ): Promise { - let params: { serviceId: ProjectServiceId, enabled: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('serviceId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { serviceId: ProjectServiceId, enabled: boolean }; + let params: { serviceId: ProjectServiceId; enabled: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('serviceId' in paramsOrFirst || 'enabled' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + serviceId: ProjectServiceId; + enabled: boolean; + }; } else { params = { serviceId: paramsOrFirst as ProjectServiceId, - enabled: rest[0] as boolean + enabled: rest[0] as boolean, }; } - + const serviceId = params.serviceId; const enabled = params.enabled; - if (typeof serviceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "serviceId"'); + throw new AppwriteException( + 'Missing required parameter: "serviceId"', + ); } if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + throw new AppwriteException( + 'Missing required parameter: "enabled"', + ); } - - const apiPath = '/project/services/{serviceId}'.replace('{serviceId}', encodeURIComponent(String(serviceId))); - const payload: Payload = {}; + const apiPath = '/project/services/{serviceId}'.replace( + '{serviceId}', + encodeURIComponent(String(serviceId)), + ); + const apiPayload: Payload = {}; if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6315,7 +7928,18 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateSMTP(params?: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean }): Promise; + updateSMTP(params?: { + host?: string; + port?: number; + username?: string; + password?: string; + senderEmail?: string; + senderName?: string; + replyToEmail?: string; + replyToName?: string; + secure?: ProjectSMTPSecure; + enabled?: boolean; + }): Promise; /** * Update the SMTP configuration for your project. Use this endpoint to configure your project's SMTP provider with your custom settings for sending transactional emails. * @@ -6333,15 +7957,76 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSMTP(host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean): Promise; updateSMTP( - paramsOrFirst?: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean } | string, - ...rest: [(number)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (ProjectSMTPSecure)?, (boolean)?] + host?: string, + port?: number, + username?: string, + password?: string, + senderEmail?: string, + senderName?: string, + replyToEmail?: string, + replyToName?: string, + secure?: ProjectSMTPSecure, + enabled?: boolean, + ): Promise; + updateSMTP( + paramsOrFirst?: + | { + host?: string; + port?: number; + username?: string; + password?: string; + senderEmail?: string; + senderName?: string; + replyToEmail?: string; + replyToName?: string; + secure?: ProjectSMTPSecure; + enabled?: boolean; + } + | string, + ...rest: [ + number?, + string?, + string?, + string?, + string?, + string?, + string?, + ProjectSMTPSecure?, + boolean?, + ] ): Promise { - let params: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean }; + let params: { + host?: string; + port?: number; + username?: string; + password?: string; + senderEmail?: string; + senderName?: string; + replyToEmail?: string; + replyToName?: string; + secure?: ProjectSMTPSecure; + enabled?: boolean; + }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + host?: string; + port?: number; + username?: string; + password?: string; + senderEmail?: string; + senderName?: string; + replyToEmail?: string; + replyToName?: string; + secure?: ProjectSMTPSecure; + enabled?: boolean; + }; } else { params = { host: paramsOrFirst as string, @@ -6353,10 +8038,10 @@ export class Project { replyToEmail: rest[5] as string, replyToName: rest[6] as string, secure: rest[7] as ProjectSMTPSecure, - enabled: rest[8] as boolean + enabled: rest[8] as boolean, }; } - + const host = params.host; const port = params.port; const username = params.username; @@ -6367,58 +8052,51 @@ export class Project { const replyToName = params.replyToName; const secure = params.secure; const enabled = params.enabled; - - const apiPath = '/project/smtp'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof host !== 'undefined') { - payload['host'] = host; + apiPayload['host'] = host; } if (typeof port !== 'undefined') { - payload['port'] = port; + apiPayload['port'] = port; } if (typeof username !== 'undefined') { - payload['username'] = username; + apiPayload['username'] = username; } if (typeof password !== 'undefined') { - payload['password'] = password; + apiPayload['password'] = password; } if (typeof senderEmail !== 'undefined') { - payload['senderEmail'] = senderEmail; + apiPayload['senderEmail'] = senderEmail; } if (typeof senderName !== 'undefined') { - payload['senderName'] = senderName; + apiPayload['senderName'] = senderName; } if (typeof replyToEmail !== 'undefined') { - payload['replyToEmail'] = replyToEmail; + apiPayload['replyToEmail'] = replyToEmail; } if (typeof replyToName !== 'undefined') { - payload['replyToName'] = replyToName; + apiPayload['replyToName'] = replyToName; } if (typeof secure !== 'undefined') { - payload['secure'] = secure; + apiPayload['secure'] = secure; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** - * Send a test email to verify SMTP configuration. + * Send a test email to verify SMTP configuration. * * @param {string[]} params.emails - Array of emails to send test email to. Maximum of 10 emails are allowed. * @throws {AppwriteException} @@ -6426,7 +8104,7 @@ export class Project { */ createSMTPTest(params: { emails: string[] }): Promise<{}>; /** - * Send a test email to verify SMTP configuration. + * Send a test email to verify SMTP configuration. * * @param {string[]} emails - Array of emails to send test email to. Maximum of 10 emails are allowed. * @throws {AppwriteException} @@ -6435,42 +8113,39 @@ export class Project { */ createSMTPTest(emails: string[]): Promise<{}>; createSMTPTest( - paramsOrFirst: { emails: string[] } | string[] + paramsOrFirst: { emails: string[] } | string[], ): Promise<{}> { let params: { emails: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { emails: string[] }; } else { params = { - emails: paramsOrFirst as string[] + emails: paramsOrFirst as string[], }; } - - const emails = params.emails; + const emails = params.emails; if (typeof emails === 'undefined') { throw new AppwriteException('Missing required parameter: "emails"'); } - const apiPath = '/project/smtp/tests'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof emails !== 'undefined') { - payload['emails'] = emails; + apiPayload['emails'] = emails; } 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', - } + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -6481,7 +8156,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - listEmailTemplates(params?: { queries?: string[], total?: boolean }): Promise; + listEmailTemplates(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all custom email templates configured for the project. This endpoint returns an array of all configured email templates and their locales. * @@ -6491,47 +8169,51 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listEmailTemplates(queries?: string[], total?: boolean): Promise; listEmailTemplates( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listEmailTemplates( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/project/templates/email'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -6548,7 +8230,16 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateEmailTemplate(params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }): Promise; + updateEmailTemplate(params: { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + subject?: string; + message?: string; + senderName?: string; + senderEmail?: string; + replyToEmail?: string; + replyToName?: string; + }): Promise; /** * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. * @@ -6564,15 +8255,73 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmailTemplate(templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string): Promise; updateEmailTemplate( - paramsOrFirst: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string } | ProjectEmailTemplateId, - ...rest: [(ProjectEmailTemplateLocale)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + templateId: ProjectEmailTemplateId, + locale?: ProjectEmailTemplateLocale, + subject?: string, + message?: string, + senderName?: string, + senderEmail?: string, + replyToEmail?: string, + replyToName?: string, + ): Promise; + updateEmailTemplate( + paramsOrFirst: + | { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + subject?: string; + message?: string; + senderName?: string; + senderEmail?: string; + replyToEmail?: string; + replyToName?: string; + } + | ProjectEmailTemplateId, + ...rest: [ + ProjectEmailTemplateLocale?, + string?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise { - let params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('templateId' in paramsOrFirst || 'locale' in paramsOrFirst || 'subject' in paramsOrFirst || 'message' in paramsOrFirst || 'senderName' in paramsOrFirst || 'senderEmail' in paramsOrFirst || 'replyToEmail' in paramsOrFirst || 'replyToName' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }; + let params: { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + subject?: string; + message?: string; + senderName?: string; + senderEmail?: string; + replyToEmail?: string; + replyToName?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('templateId' in paramsOrFirst || + 'locale' in paramsOrFirst || + 'subject' in paramsOrFirst || + 'message' in paramsOrFirst || + 'senderName' in paramsOrFirst || + 'senderEmail' in paramsOrFirst || + 'replyToEmail' in paramsOrFirst || + 'replyToName' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + subject?: string; + message?: string; + senderName?: string; + senderEmail?: string; + replyToEmail?: string; + replyToName?: string; + }; } else { params = { templateId: paramsOrFirst as ProjectEmailTemplateId, @@ -6582,10 +8331,10 @@ export class Project { senderName: rest[3] as string, senderEmail: rest[4] as string, replyToEmail: rest[5] as string, - replyToName: rest[6] as string + replyToName: rest[6] as string, }; } - + const templateId = params.templateId; const locale = params.locale; const subject = params.subject; @@ -6594,51 +8343,46 @@ export class Project { const senderEmail = params.senderEmail; const replyToEmail = params.replyToEmail; const replyToName = params.replyToName; - if (typeof templateId === 'undefined') { - throw new AppwriteException('Missing required parameter: "templateId"'); + throw new AppwriteException( + 'Missing required parameter: "templateId"', + ); } - const apiPath = '/project/templates/email'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof templateId !== 'undefined') { - payload['templateId'] = templateId; + apiPayload['templateId'] = templateId; } if (typeof locale !== 'undefined') { - payload['locale'] = locale; + apiPayload['locale'] = locale; } if (typeof subject !== 'undefined') { - payload['subject'] = subject; + apiPayload['subject'] = subject; } if (typeof message !== 'undefined') { - payload['message'] = message; + apiPayload['message'] = message; } if (typeof senderName !== 'undefined') { - payload['senderName'] = senderName; + apiPayload['senderName'] = senderName; } if (typeof senderEmail !== 'undefined') { - payload['senderEmail'] = senderEmail; + apiPayload['senderEmail'] = senderEmail; } if (typeof replyToEmail !== 'undefined') { - payload['replyToEmail'] = replyToEmail; + apiPayload['replyToEmail'] = replyToEmail; } if (typeof replyToName !== 'undefined') { - payload['replyToName'] = replyToName; + apiPayload['replyToName'] = replyToName; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6649,7 +8393,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - getEmailTemplate(params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }): Promise; + getEmailTemplate(params: { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + }): Promise; /** * Get a custom email template for the specified locale and type. This endpoint returns the template content, subject, and other configuration details. * @@ -6659,47 +8406,64 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getEmailTemplate(templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale): Promise; getEmailTemplate( - paramsOrFirst: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale } | ProjectEmailTemplateId, - ...rest: [(ProjectEmailTemplateLocale)?] + templateId: ProjectEmailTemplateId, + locale?: ProjectEmailTemplateLocale, + ): Promise; + getEmailTemplate( + paramsOrFirst: + | { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + } + | ProjectEmailTemplateId, + ...rest: [ProjectEmailTemplateLocale?] ): Promise { - let params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('templateId' in paramsOrFirst || 'locale' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }; + let params: { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) && + ('templateId' in paramsOrFirst || 'locale' in paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + templateId: ProjectEmailTemplateId; + locale?: ProjectEmailTemplateLocale; + }; } else { params = { templateId: paramsOrFirst as ProjectEmailTemplateId, - locale: rest[0] as ProjectEmailTemplateLocale + locale: rest[0] as ProjectEmailTemplateLocale, }; } - + const templateId = params.templateId; const locale = params.locale; - if (typeof templateId === 'undefined') { - throw new AppwriteException('Missing required parameter: "templateId"'); + throw new AppwriteException( + 'Missing required parameter: "templateId"', + ); } - - const apiPath = '/project/templates/email/{templateId}'.replace('{templateId}', encodeURIComponent(String(templateId))); - const payload: Payload = {}; + const apiPath = '/project/templates/email/{templateId}'.replace( + '{templateId}', + encodeURIComponent(String(templateId)), + ); + const apiPayload: Payload = {}; if (typeof locale !== 'undefined') { - payload['locale'] = locale; + apiPayload['locale'] = locale; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -6710,7 +8474,10 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - listVariables(params?: { queries?: string[], total?: boolean }): Promise; + listVariables(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all project environment variables. * @@ -6720,96 +8487,132 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listVariables(queries?: string[], total?: boolean): Promise; listVariables( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listVariables( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/project/variables'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Create a new project environment variable. These variables can be accessed by all functions and sites in the project. * * @param {string} params.variableId - Variable unique 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.key - Variable key. Max length: 255 chars. + * @param {string} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} */ - createVariable(params: { variableId: string, key: string, value: string, secret?: boolean }): Promise; + createVariable(params: { + variableId: string; + key: string; + value: string; + secret?: boolean; + }): Promise; /** * Create a new project environment variable. These variables can be accessed by all functions and sites in the project. * * @param {string} variableId - Variable unique 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} key - Variable key. Max length: 255 chars. + * @param {string} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVariable(variableId: string, key: string, value: string, secret?: boolean): Promise; createVariable( - paramsOrFirst: { variableId: string, key: string, value: string, secret?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + variableId: string, + key: string, + value: string, + secret?: boolean, + ): Promise; + createVariable( + paramsOrFirst: + | { + variableId: string; + key: string; + value: string; + secret?: boolean; + } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { variableId: string, key: string, value: string, secret?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { variableId: string, key: string, value: string, secret?: boolean }; + let params: { + variableId: string; + key: string; + value: string; + secret?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + variableId: string; + key: string; + value: string; + secret?: boolean; + }; } else { params = { variableId: paramsOrFirst as string, key: rest[0] as string, value: rest[1] as string, - secret: rest[2] as boolean + secret: rest[2] as boolean, }; } - + const variableId = params.variableId; const key = params.key; const value = params.value; const secret = params.secret; - if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -6817,39 +8620,33 @@ export class Project { if (typeof value === 'undefined') { throw new AppwriteException('Missing required parameter: "value"'); } - const apiPath = '/project/variables'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof variableId !== 'undefined') { - payload['variableId'] = variableId; + apiPayload['variableId'] = variableId; } if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof value !== 'undefined') { - payload['value'] = value; + apiPayload['value'] = value; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** - * Get a variable by its unique ID. + * Get a variable by its unique ID. * * @param {string} params.variableId - Variable unique ID. * @throws {AppwriteException} @@ -6857,7 +8654,7 @@ export class Project { */ getVariable(params: { variableId: string }): Promise; /** - * Get a variable by its unique ID. + * Get a variable by its unique ID. * * @param {string} variableId - Variable unique ID. * @throws {AppwriteException} @@ -6866,119 +8663,150 @@ export class Project { */ getVariable(variableId: string): Promise; getVariable( - paramsOrFirst: { variableId: string } | string + paramsOrFirst: { variableId: string } | string, ): Promise { let params: { variableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { variableId: string }; } else { params = { - variableId: paramsOrFirst as string + variableId: paramsOrFirst as string, }; } - - const variableId = params.variableId; + const variableId = params.variableId; if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } - - const apiPath = '/project/variables/{variableId}'.replace('{variableId}', encodeURIComponent(String(variableId))); - const payload: Payload = {}; + const apiPath = '/project/variables/{variableId}'.replace( + '{variableId}', + encodeURIComponent(String(variableId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Update variable by its unique ID. * * @param {string} params.variableId - Variable unique ID. - * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} */ - updateVariable(params: { variableId: string, key?: string, value?: string, secret?: boolean }): Promise; + updateVariable(params: { + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }): Promise; /** * Update variable by its unique ID. * * @param {string} variableId - Variable unique ID. - * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateVariable(variableId: string, key?: string, value?: string, secret?: boolean): Promise; updateVariable( - paramsOrFirst: { variableId: string, key?: string, value?: string, secret?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + variableId: string, + key?: string, + value?: string, + secret?: boolean, + ): Promise; + updateVariable( + paramsOrFirst: + | { + variableId: string; + key?: string; + value?: string; + secret?: boolean; + } + | string, + ...rest: [string?, string?, boolean?] ): Promise { - let params: { variableId: string, key?: string, value?: string, secret?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { variableId: string, key?: string, value?: string, secret?: boolean }; + let params: { + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }; } else { params = { variableId: paramsOrFirst as string, key: rest[0] as string, value: rest[1] as string, - secret: rest[2] as boolean + secret: rest[2] as boolean, }; } - + const variableId = params.variableId; const key = params.key; const value = params.value; const secret = params.secret; - if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } - - const apiPath = '/project/variables/{variableId}'.replace('{variableId}', encodeURIComponent(String(variableId))); - const payload: Payload = {}; + const apiPath = '/project/variables/{variableId}'.replace( + '{variableId}', + encodeURIComponent(String(variableId)), + ); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof value !== 'undefined') { - payload['value'] = value; + apiPayload['value'] = value; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** - * Delete a variable by its unique ID. + * Delete a variable by its unique ID. * * @param {string} params.variableId - Variable unique ID. * @throws {AppwriteException} @@ -6986,7 +8814,7 @@ export class Project { */ deleteVariable(params: { variableId: string }): Promise<{}>; /** - * Delete a variable by its unique ID. + * Delete a variable by its unique ID. * * @param {string} variableId - Variable unique ID. * @throws {AppwriteException} @@ -6995,38 +8823,40 @@ export class Project { */ deleteVariable(variableId: string): Promise<{}>; deleteVariable( - paramsOrFirst: { variableId: string } | string + paramsOrFirst: { variableId: string } | string, ): Promise<{}> { let params: { variableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { variableId: string }; } else { params = { - variableId: paramsOrFirst as string + variableId: paramsOrFirst as string, }; } - - const variableId = params.variableId; + const variableId = params.variableId; if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } - - const apiPath = '/project/variables/{variableId}'.replace('{variableId}', encodeURIComponent(String(variableId))); - const payload: Payload = {}; + const apiPath = '/project/variables/{variableId}'.replace( + '{variableId}', + encodeURIComponent(String(variableId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } } diff --git a/src/services/proxy.ts b/src/services/proxy.ts index 78584510..1f4d674e 100644 --- a/src/services/proxy.ts +++ b/src/services/proxy.ts @@ -1,11 +1,9 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - import { InvalidationType } from '../enums/invalidation-type'; import { StatusCode } from '../enums/status-code'; import { ProxyResourceType } from '../enums/proxy-resource-type'; - export class Proxy { client: Client; @@ -15,7 +13,7 @@ export class Proxy { /** * Create a new CDN cache invalidation for a domain. Executes a hard purge of cached content. - * + * * Depending on type, the invalidation purges a single cache tag, a single URL path, or all cached content for the domain. * * @param {string} params.domain - Domain name. @@ -24,10 +22,14 @@ export class Proxy { * @throws {AppwriteException} * @returns {Promise} */ - createInvalidation(params: { domain: string, type: InvalidationType, reference?: string }): Promise; + createInvalidation(params: { + domain: string; + type: InvalidationType; + reference?: string; + }): Promise; /** * Create a new CDN cache invalidation for a domain. Executes a hard purge of cached content. - * + * * Depending on type, the invalidation purges a single cache tag, a single URL path, or all cached content for the domain. * * @param {string} domain - Domain name. @@ -37,59 +39,70 @@ export class Proxy { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createInvalidation(domain: string, type: InvalidationType, reference?: string): Promise; createInvalidation( - paramsOrFirst: { domain: string, type: InvalidationType, reference?: string } | string, - ...rest: [(InvalidationType)?, (string)?] + domain: string, + type: InvalidationType, + reference?: string, + ): Promise; + createInvalidation( + paramsOrFirst: + | { domain: string; type: InvalidationType; reference?: string } + | string, + ...rest: [InvalidationType?, string?] ): Promise { - let params: { domain: string, type: InvalidationType, reference?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domain: string, type: InvalidationType, reference?: string }; + let params: { + domain: string; + type: InvalidationType; + reference?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domain: string; + type: InvalidationType; + reference?: string; + }; } else { params = { domain: paramsOrFirst as string, type: rest[0] as InvalidationType, - reference: rest[1] as string + reference: rest[1] as string, }; } - + const domain = params.domain; const type = params.type; const reference = params.reference; - if (typeof domain === 'undefined') { throw new AppwriteException('Missing required parameter: "domain"'); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - const apiPath = '/proxy/invalidations'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof domain !== 'undefined') { - payload['domain'] = domain; + apiPayload['domain'] = domain; } if (typeof type !== 'undefined') { - payload['type'] = type; + apiPayload['type'] = type; } if (typeof reference !== 'undefined') { - payload['reference'] = reference; + apiPayload['reference'] = reference; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -100,7 +113,10 @@ export class Proxy { * @throws {AppwriteException} * @returns {Promise} */ - listRules(params?: { queries?: string[], total?: boolean }): Promise; + listRules(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all the proxy rules. You can use the query params to filter your results. * @@ -110,52 +126,56 @@ export class Proxy { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listRules(queries?: string[], total?: boolean): Promise; listRules( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + queries?: string[], + total?: boolean, + ): Promise; + listRules( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/proxy/rules'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Create a new proxy rule for serving Appwrite's API on custom domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} params.domain - Domain name. @@ -165,7 +185,7 @@ export class Proxy { createAPIRule(params: { domain: string }): Promise; /** * Create a new proxy rule for serving Appwrite's API on custom domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} domain - Domain name. @@ -175,48 +195,45 @@ export class Proxy { */ createAPIRule(domain: string): Promise; createAPIRule( - paramsOrFirst: { domain: string } | string + paramsOrFirst: { domain: string } | string, ): Promise { let params: { domain: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { domain: string }; } else { params = { - domain: paramsOrFirst as string + domain: paramsOrFirst as string, }; } - - const domain = params.domain; + const domain = params.domain; if (typeof domain === 'undefined') { throw new AppwriteException('Missing required parameter: "domain"'); } - const apiPath = '/proxy/rules/api'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof domain !== 'undefined') { - payload['domain'] = domain; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Create a new proxy rule for executing Appwrite Function on custom domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} params.domain - Domain name. @@ -225,10 +242,14 @@ export class Proxy { * @throws {AppwriteException} * @returns {Promise} */ - createFunctionRule(params: { domain: string, functionId: string, branch?: string }): Promise; + createFunctionRule(params: { + domain: string; + functionId: string; + branch?: string; + }): Promise; /** * Create a new proxy rule for executing Appwrite Function on custom domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} domain - Domain name. @@ -238,64 +259,72 @@ export class Proxy { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFunctionRule(domain: string, functionId: string, branch?: string): Promise; createFunctionRule( - paramsOrFirst: { domain: string, functionId: string, branch?: string } | string, - ...rest: [(string)?, (string)?] + domain: string, + functionId: string, + branch?: string, + ): Promise; + createFunctionRule( + paramsOrFirst: + { domain: string; functionId: string; branch?: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { domain: string, functionId: string, branch?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domain: string, functionId: string, branch?: string }; + let params: { domain: string; functionId: string; branch?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domain: string; + functionId: string; + branch?: string; + }; } else { params = { domain: paramsOrFirst as string, functionId: rest[0] as string, - branch: rest[1] as string + branch: rest[1] as string, }; } - + const domain = params.domain; const functionId = params.functionId; const branch = params.branch; - if (typeof domain === 'undefined') { throw new AppwriteException('Missing required parameter: "domain"'); } if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); + throw new AppwriteException( + 'Missing required parameter: "functionId"', + ); } - const apiPath = '/proxy/rules/function'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof domain !== 'undefined') { - payload['domain'] = domain; + apiPayload['domain'] = domain; } if (typeof functionId !== 'undefined') { - payload['functionId'] = functionId; + apiPayload['functionId'] = functionId; } if (typeof branch !== 'undefined') { - payload['branch'] = branch; + apiPayload['branch'] = branch; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Create a new proxy rule for to redirect from custom domain to another domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} params.domain - Domain name. @@ -306,10 +335,16 @@ export class Proxy { * @throws {AppwriteException} * @returns {Promise} */ - createRedirectRule(params: { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType }): Promise; + createRedirectRule(params: { + domain: string; + url: string; + statusCode: StatusCode; + resourceId: string; + resourceType: ProxyResourceType; + }): Promise; /** * Create a new proxy rule for to redirect from custom domain to another domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} domain - Domain name. @@ -321,31 +356,60 @@ export class Proxy { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRedirectRule(domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType): Promise; createRedirectRule( - paramsOrFirst: { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType } | string, - ...rest: [(string)?, (StatusCode)?, (string)?, (ProxyResourceType)?] + domain: string, + url: string, + statusCode: StatusCode, + resourceId: string, + resourceType: ProxyResourceType, + ): Promise; + createRedirectRule( + paramsOrFirst: + | { + domain: string; + url: string; + statusCode: StatusCode; + resourceId: string; + resourceType: ProxyResourceType; + } + | string, + ...rest: [string?, StatusCode?, string?, ProxyResourceType?] ): Promise { - let params: { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType }; + let params: { + domain: string; + url: string; + statusCode: StatusCode; + resourceId: string; + resourceType: ProxyResourceType; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domain: string; + url: string; + statusCode: StatusCode; + resourceId: string; + resourceType: ProxyResourceType; + }; } else { params = { domain: paramsOrFirst as string, url: rest[0] as string, statusCode: rest[1] as StatusCode, resourceId: rest[2] as string, - resourceType: rest[3] as ProxyResourceType + resourceType: rest[3] as ProxyResourceType, }; } - + const domain = params.domain; const url = params.url; const statusCode = params.statusCode; const resourceId = params.resourceId; const resourceType = params.resourceType; - if (typeof domain === 'undefined') { throw new AppwriteException('Missing required parameter: "domain"'); } @@ -353,51 +417,51 @@ export class Proxy { throw new AppwriteException('Missing required parameter: "url"'); } if (typeof statusCode === 'undefined') { - throw new AppwriteException('Missing required parameter: "statusCode"'); + throw new AppwriteException( + 'Missing required parameter: "statusCode"', + ); } if (typeof resourceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "resourceId"'); + throw new AppwriteException( + 'Missing required parameter: "resourceId"', + ); } if (typeof resourceType === 'undefined') { - throw new AppwriteException('Missing required parameter: "resourceType"'); + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); } - const apiPath = '/proxy/rules/redirect'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof domain !== 'undefined') { - payload['domain'] = domain; + apiPayload['domain'] = domain; } if (typeof url !== 'undefined') { - payload['url'] = url; + apiPayload['url'] = url; } if (typeof statusCode !== 'undefined') { - payload['statusCode'] = statusCode; + apiPayload['statusCode'] = statusCode; } if (typeof resourceId !== 'undefined') { - payload['resourceId'] = resourceId; + apiPayload['resourceId'] = resourceId; } if (typeof resourceType !== 'undefined') { - payload['resourceType'] = resourceType; + apiPayload['resourceType'] = resourceType; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Create a new proxy rule for serving Appwrite Site on custom domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} params.domain - Domain name. @@ -406,10 +470,14 @@ export class Proxy { * @throws {AppwriteException} * @returns {Promise} */ - createSiteRule(params: { domain: string, siteId: string, branch?: string }): Promise; + createSiteRule(params: { + domain: string; + siteId: string; + branch?: string; + }): Promise; /** * Create a new proxy rule for serving Appwrite Site on custom domain. - * + * * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. * * @param {string} domain - Domain name. @@ -419,59 +487,65 @@ export class Proxy { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSiteRule(domain: string, siteId: string, branch?: string): Promise; createSiteRule( - paramsOrFirst: { domain: string, siteId: string, branch?: string } | string, - ...rest: [(string)?, (string)?] + domain: string, + siteId: string, + branch?: string, + ): Promise; + createSiteRule( + paramsOrFirst: + { domain: string; siteId: string; branch?: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { domain: string, siteId: string, branch?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domain: string, siteId: string, branch?: string }; + let params: { domain: string; siteId: string; branch?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + domain: string; + siteId: string; + branch?: string; + }; } else { params = { domain: paramsOrFirst as string, siteId: rest[0] as string, - branch: rest[1] as string + branch: rest[1] as string, }; } - + const domain = params.domain; const siteId = params.siteId; const branch = params.branch; - if (typeof domain === 'undefined') { throw new AppwriteException('Missing required parameter: "domain"'); } if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } - const apiPath = '/proxy/rules/site'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof domain !== 'undefined') { - payload['domain'] = domain; + apiPayload['domain'] = domain; } if (typeof siteId !== 'undefined') { - payload['siteId'] = siteId; + apiPayload['siteId'] = siteId; } if (typeof branch !== 'undefined') { - payload['branch'] = branch; + apiPayload['branch'] = branch; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -492,39 +566,39 @@ export class Proxy { */ getRule(ruleId: string): Promise; getRule( - paramsOrFirst: { ruleId: string } | string + paramsOrFirst: { ruleId: string } | string, ): Promise { let params: { ruleId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { ruleId: string }; } else { params = { - ruleId: paramsOrFirst as string + ruleId: paramsOrFirst as string, }; } - - const ruleId = params.ruleId; + const ruleId = params.ruleId; if (typeof ruleId === 'undefined') { throw new AppwriteException('Missing required parameter: "ruleId"'); } - - const apiPath = '/proxy/rules/{ruleId}'.replace('{ruleId}', encodeURIComponent(String(ruleId))); - const payload: Payload = {}; + const apiPath = '/proxy/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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -544,40 +618,38 @@ export class Proxy { * @deprecated Use the object parameter style method for a better developer experience. */ deleteRule(ruleId: string): Promise<{}>; - deleteRule( - paramsOrFirst: { ruleId: string } | string - ): Promise<{}> { + deleteRule(paramsOrFirst: { ruleId: string } | string): Promise<{}> { let params: { ruleId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { ruleId: string }; } else { params = { - ruleId: paramsOrFirst as string + ruleId: paramsOrFirst as string, }; } - - const ruleId = params.ruleId; + const ruleId = params.ruleId; if (typeof ruleId === 'undefined') { throw new AppwriteException('Missing required parameter: "ruleId"'); } - - const apiPath = '/proxy/rules/{ruleId}'.replace('{ruleId}', encodeURIComponent(String(ruleId))); - const payload: Payload = {}; + const apiPath = '/proxy/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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -598,39 +670,39 @@ export class Proxy { */ updateRuleStatus(ruleId: string): Promise; updateRuleStatus( - paramsOrFirst: { ruleId: string } | string + paramsOrFirst: { ruleId: string } | string, ): Promise { let params: { ruleId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { ruleId: string }; } else { params = { - ruleId: paramsOrFirst as string + ruleId: paramsOrFirst as string, }; } - - const ruleId = params.ruleId; + const ruleId = params.ruleId; if (typeof ruleId === 'undefined') { throw new AppwriteException('Missing required parameter: "ruleId"'); } - - const apiPath = '/proxy/rules/{ruleId}/status'.replace('{ruleId}', encodeURIComponent(String(ruleId))); - const payload: Payload = {}; + const apiPath = '/proxy/rules/{ruleId}/status'.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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } } diff --git a/src/services/sites.ts b/src/services/sites.ts index f74f2dd0..d6845214 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -1,15 +1,19 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { + AppwriteException, + Client, + type Payload, + UploadProgress, +} from '../client'; import type { Models } from '../models'; - import { InputFile } from '../inputFile'; import { Framework } from '../enums/framework'; import { BuildRuntime } from '../enums/build-runtime'; import { Adapter } from '../enums/adapter'; +import { ProjectKeyScopes } from '../enums/project-key-scopes'; import { TemplateReferenceType } from '../enums/template-reference-type'; import { VCSReferenceType } from '../enums/vcs-reference-type'; import { DeploymentDownloadType } from '../enums/deployment-download-type'; - export class Sites { client: Client; @@ -26,7 +30,11 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + list(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all the project's sites. You can use the query params to filter your results. * @@ -37,52 +45,59 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string, total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + list( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - - const apiPath = '/sites'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -111,10 +126,36 @@ export class Sites { * @param {string} params.buildSpecification - Build specification for the site deployments. * @param {string} params.runtimeSpecification - Runtime specification for the SSR executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {ProjectKeyScopes[]} params.scopes - List of scopes allowed for API key auto-generated for every site build and SSR execution. Maximum of 200 scopes are allowed. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; + create(params: { + siteId: string; + name: string; + framework: Framework; + buildRuntime: BuildRuntime; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + adapter?: Adapter; + installationId?: string; + fallbackFile?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + }): Promise; /** * Create a new site. * @@ -141,19 +182,150 @@ export class Sites { * @param {string} buildSpecification - Build specification for the site deployments. * @param {string} runtimeSpecification - Runtime specification for the SSR executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {ProjectKeyScopes[]} scopes - List of scopes allowed for API key auto-generated for every site build and SSR execution. Maximum of 200 scopes are allowed. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; create( - paramsOrFirst: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, - ...rest: [(string)?, (Framework)?, (BuildRuntime)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (string)?, (Adapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (number)?] + siteId: string, + name: string, + framework: Framework, + buildRuntime: BuildRuntime, + enabled?: boolean, + logging?: boolean, + timeout?: number, + installCommand?: string, + buildCommand?: string, + startCommand?: string, + outputDirectory?: string, + adapter?: Adapter, + installationId?: string, + fallbackFile?: string, + providerRepositoryId?: string, + providerBranch?: string, + providerSilentMode?: boolean, + providerRootDirectory?: string, + providerBranches?: string[], + providerPaths?: string[], + buildSpecification?: string, + runtimeSpecification?: string, + deploymentRetention?: number, + scopes?: ProjectKeyScopes[], + ): Promise; + create( + paramsOrFirst: + | { + siteId: string; + name: string; + framework: Framework; + buildRuntime: BuildRuntime; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + adapter?: Adapter; + installationId?: string; + fallbackFile?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + } + | string, + ...rest: [ + string?, + Framework?, + BuildRuntime?, + boolean?, + boolean?, + number?, + string?, + string?, + string?, + string?, + Adapter?, + string?, + string?, + string?, + string?, + boolean?, + string?, + string[]?, + string[]?, + string?, + string?, + number?, + ProjectKeyScopes[]?, + ] ): Promise { - let params: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + let params: { + siteId: string; + name: string; + framework: Framework; + buildRuntime: BuildRuntime; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + adapter?: Adapter; + installationId?: string; + fallbackFile?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + name: string; + framework: Framework; + buildRuntime: BuildRuntime; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + adapter?: Adapter; + installationId?: string; + fallbackFile?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + }; } else { params = { siteId: paramsOrFirst as string, @@ -178,10 +350,11 @@ export class Sites { providerPaths: rest[18] as string[], buildSpecification: rest[19] as string, runtimeSpecification: rest[20] as string, - deploymentRetention: rest[21] as number + deploymentRetention: rest[21] as number, + scopes: rest[22] as ProjectKeyScopes[], }; } - + const siteId = params.siteId; const name = params.name; const framework = params.framework; @@ -205,7 +378,7 @@ export class Sites { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; - + const scopes = params.scopes; if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } @@ -213,97 +386,98 @@ export class Sites { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof framework === 'undefined') { - throw new AppwriteException('Missing required parameter: "framework"'); + throw new AppwriteException( + 'Missing required parameter: "framework"', + ); } if (typeof buildRuntime === 'undefined') { - throw new AppwriteException('Missing required parameter: "buildRuntime"'); + throw new AppwriteException( + 'Missing required parameter: "buildRuntime"', + ); } - const apiPath = '/sites'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof siteId !== 'undefined') { - payload['siteId'] = siteId; + apiPayload['siteId'] = siteId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof framework !== 'undefined') { - payload['framework'] = framework; + apiPayload['framework'] = framework; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof logging !== 'undefined') { - payload['logging'] = logging; + apiPayload['logging'] = logging; } if (typeof timeout !== 'undefined') { - payload['timeout'] = timeout; + apiPayload['timeout'] = timeout; } if (typeof installCommand !== 'undefined') { - payload['installCommand'] = installCommand; + apiPayload['installCommand'] = installCommand; } if (typeof buildCommand !== 'undefined') { - payload['buildCommand'] = buildCommand; + apiPayload['buildCommand'] = buildCommand; } if (typeof startCommand !== 'undefined') { - payload['startCommand'] = startCommand; + apiPayload['startCommand'] = startCommand; } if (typeof outputDirectory !== 'undefined') { - payload['outputDirectory'] = outputDirectory; + apiPayload['outputDirectory'] = outputDirectory; } if (typeof buildRuntime !== 'undefined') { - payload['buildRuntime'] = buildRuntime; + apiPayload['buildRuntime'] = buildRuntime; } if (typeof adapter !== 'undefined') { - payload['adapter'] = adapter; + apiPayload['adapter'] = adapter; } if (typeof installationId !== 'undefined') { - payload['installationId'] = installationId; + apiPayload['installationId'] = installationId; } if (typeof fallbackFile !== 'undefined') { - payload['fallbackFile'] = fallbackFile; + apiPayload['fallbackFile'] = fallbackFile; } if (typeof providerRepositoryId !== 'undefined') { - payload['providerRepositoryId'] = providerRepositoryId; + apiPayload['providerRepositoryId'] = providerRepositoryId; } if (typeof providerBranch !== 'undefined') { - payload['providerBranch'] = providerBranch; + apiPayload['providerBranch'] = providerBranch; } if (typeof providerSilentMode !== 'undefined') { - payload['providerSilentMode'] = providerSilentMode; + apiPayload['providerSilentMode'] = providerSilentMode; } if (typeof providerRootDirectory !== 'undefined') { - payload['providerRootDirectory'] = providerRootDirectory; + apiPayload['providerRootDirectory'] = providerRootDirectory; } if (typeof providerBranches !== 'undefined') { - payload['providerBranches'] = providerBranches; + apiPayload['providerBranches'] = providerBranches; } if (typeof providerPaths !== 'undefined') { - payload['providerPaths'] = providerPaths; + apiPayload['providerPaths'] = providerPaths; } if (typeof buildSpecification !== 'undefined') { - payload['buildSpecification'] = buildSpecification; + apiPayload['buildSpecification'] = buildSpecification; } if (typeof runtimeSpecification !== 'undefined') { - payload['runtimeSpecification'] = runtimeSpecification; + apiPayload['runtimeSpecification'] = runtimeSpecification; } if (typeof deploymentRetention !== 'undefined') { - payload['deploymentRetention'] = deploymentRetention; + apiPayload['deploymentRetention'] = deploymentRetention; + } + if (typeof scopes !== 'undefined') { + apiPayload['scopes'] = scopes; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -313,22 +487,16 @@ export class Sites { * @returns {Promise} */ listFrameworks(): Promise { - const apiPath = '/sites/frameworks'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -338,7 +506,9 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - listSpecifications(params?: { type?: string }): Promise; + listSpecifications(params?: { + type?: string; + }): Promise; /** * List allowed site specifications for this instance. * @@ -349,39 +519,37 @@ export class Sites { */ listSpecifications(type?: string): Promise; listSpecifications( - paramsOrFirst?: { type?: string } | string + paramsOrFirst?: { type?: string } | string, ): Promise { let params: { type?: string }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { type?: string }; } else { params = { - type: paramsOrFirst as string + type: paramsOrFirst as string, }; } - - const type = params.type; - + const type = params.type; const apiPath = '/sites/specifications'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof type !== 'undefined') { - payload['type'] = type; + apiPayload['type'] = type; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -401,40 +569,38 @@ export class Sites { * @deprecated Use the object parameter style method for a better developer experience. */ get(siteId: string): Promise; - get( - paramsOrFirst: { siteId: string } | string - ): Promise { + get(paramsOrFirst: { siteId: string } | string): Promise { let params: { siteId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { siteId: string }; } else { params = { - siteId: paramsOrFirst as string + siteId: paramsOrFirst as string, }; } - - const siteId = params.siteId; + const siteId = params.siteId; if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } - - const apiPath = '/sites/{siteId}'.replace('{siteId}', encodeURIComponent(String(siteId))); - const payload: Payload = {}; + const apiPath = '/sites/{siteId}'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -463,10 +629,36 @@ export class Sites { * @param {string} params.buildSpecification - Build specification for the site deployments. * @param {string} params.runtimeSpecification - Runtime specification for the SSR executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {ProjectKeyScopes[]} params.scopes - List of scopes allowed for API key auto-generated for every site build and SSR execution. Maximum of 200 scopes are allowed. * @throws {AppwriteException} * @returns {Promise} */ - update(params: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; + update(params: { + siteId: string; + name: string; + framework: Framework; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + buildRuntime?: BuildRuntime; + adapter?: Adapter; + fallbackFile?: string; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + }): Promise; /** * Update site by its unique ID. * @@ -493,19 +685,150 @@ export class Sites { * @param {string} buildSpecification - Build specification for the site deployments. * @param {string} runtimeSpecification - Runtime specification for the SSR executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {ProjectKeyScopes[]} scopes - List of scopes allowed for API key auto-generated for every site build and SSR execution. Maximum of 200 scopes are allowed. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; update( - paramsOrFirst: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, - ...rest: [(string)?, (Framework)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (string)?, (BuildRuntime)?, (Adapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (number)?] + siteId: string, + name: string, + framework: Framework, + enabled?: boolean, + logging?: boolean, + timeout?: number, + installCommand?: string, + buildCommand?: string, + startCommand?: string, + outputDirectory?: string, + buildRuntime?: BuildRuntime, + adapter?: Adapter, + fallbackFile?: string, + installationId?: string, + providerRepositoryId?: string, + providerBranch?: string, + providerSilentMode?: boolean, + providerRootDirectory?: string, + providerBranches?: string[], + providerPaths?: string[], + buildSpecification?: string, + runtimeSpecification?: string, + deploymentRetention?: number, + scopes?: ProjectKeyScopes[], + ): Promise; + update( + paramsOrFirst: + | { + siteId: string; + name: string; + framework: Framework; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + buildRuntime?: BuildRuntime; + adapter?: Adapter; + fallbackFile?: string; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + } + | string, + ...rest: [ + string?, + Framework?, + boolean?, + boolean?, + number?, + string?, + string?, + string?, + string?, + BuildRuntime?, + Adapter?, + string?, + string?, + string?, + string?, + boolean?, + string?, + string[]?, + string[]?, + string?, + string?, + number?, + ProjectKeyScopes[]?, + ] ): Promise { - let params: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + let params: { + siteId: string; + name: string; + framework: Framework; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + buildRuntime?: BuildRuntime; + adapter?: Adapter; + fallbackFile?: string; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + name: string; + framework: Framework; + enabled?: boolean; + logging?: boolean; + timeout?: number; + installCommand?: string; + buildCommand?: string; + startCommand?: string; + outputDirectory?: string; + buildRuntime?: BuildRuntime; + adapter?: Adapter; + fallbackFile?: string; + installationId?: string; + providerRepositoryId?: string; + providerBranch?: string; + providerSilentMode?: boolean; + providerRootDirectory?: string; + providerBranches?: string[]; + providerPaths?: string[]; + buildSpecification?: string; + runtimeSpecification?: string; + deploymentRetention?: number; + scopes?: ProjectKeyScopes[]; + }; } else { params = { siteId: paramsOrFirst as string, @@ -530,10 +853,11 @@ export class Sites { providerPaths: rest[18] as string[], buildSpecification: rest[19] as string, runtimeSpecification: rest[20] as string, - deploymentRetention: rest[21] as number + deploymentRetention: rest[21] as number, + scopes: rest[22] as ProjectKeyScopes[], }; } - + const siteId = params.siteId; const name = params.name; const framework = params.framework; @@ -557,7 +881,7 @@ export class Sites { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; - + const scopes = params.scopes; if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } @@ -565,91 +889,93 @@ export class Sites { throw new AppwriteException('Missing required parameter: "name"'); } if (typeof framework === 'undefined') { - throw new AppwriteException('Missing required parameter: "framework"'); + throw new AppwriteException( + 'Missing required parameter: "framework"', + ); } - - const apiPath = '/sites/{siteId}'.replace('{siteId}', encodeURIComponent(String(siteId))); - const payload: Payload = {}; + const apiPath = '/sites/{siteId}'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof framework !== 'undefined') { - payload['framework'] = framework; + apiPayload['framework'] = framework; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof logging !== 'undefined') { - payload['logging'] = logging; + apiPayload['logging'] = logging; } if (typeof timeout !== 'undefined') { - payload['timeout'] = timeout; + apiPayload['timeout'] = timeout; } if (typeof installCommand !== 'undefined') { - payload['installCommand'] = installCommand; + apiPayload['installCommand'] = installCommand; } if (typeof buildCommand !== 'undefined') { - payload['buildCommand'] = buildCommand; + apiPayload['buildCommand'] = buildCommand; } if (typeof startCommand !== 'undefined') { - payload['startCommand'] = startCommand; + apiPayload['startCommand'] = startCommand; } if (typeof outputDirectory !== 'undefined') { - payload['outputDirectory'] = outputDirectory; + apiPayload['outputDirectory'] = outputDirectory; } if (typeof buildRuntime !== 'undefined') { - payload['buildRuntime'] = buildRuntime; + apiPayload['buildRuntime'] = buildRuntime; } if (typeof adapter !== 'undefined') { - payload['adapter'] = adapter; + apiPayload['adapter'] = adapter; } if (typeof fallbackFile !== 'undefined') { - payload['fallbackFile'] = fallbackFile; + apiPayload['fallbackFile'] = fallbackFile; } if (typeof installationId !== 'undefined') { - payload['installationId'] = installationId; + apiPayload['installationId'] = installationId; } if (typeof providerRepositoryId !== 'undefined') { - payload['providerRepositoryId'] = providerRepositoryId; + apiPayload['providerRepositoryId'] = providerRepositoryId; } if (typeof providerBranch !== 'undefined') { - payload['providerBranch'] = providerBranch; + apiPayload['providerBranch'] = providerBranch; } if (typeof providerSilentMode !== 'undefined') { - payload['providerSilentMode'] = providerSilentMode; + apiPayload['providerSilentMode'] = providerSilentMode; } if (typeof providerRootDirectory !== 'undefined') { - payload['providerRootDirectory'] = providerRootDirectory; + apiPayload['providerRootDirectory'] = providerRootDirectory; } if (typeof providerBranches !== 'undefined') { - payload['providerBranches'] = providerBranches; + apiPayload['providerBranches'] = providerBranches; } if (typeof providerPaths !== 'undefined') { - payload['providerPaths'] = providerPaths; + apiPayload['providerPaths'] = providerPaths; } if (typeof buildSpecification !== 'undefined') { - payload['buildSpecification'] = buildSpecification; + apiPayload['buildSpecification'] = buildSpecification; } if (typeof runtimeSpecification !== 'undefined') { - payload['runtimeSpecification'] = runtimeSpecification; + apiPayload['runtimeSpecification'] = runtimeSpecification; } if (typeof deploymentRetention !== 'undefined') { - payload['deploymentRetention'] = deploymentRetention; + apiPayload['deploymentRetention'] = deploymentRetention; + } + if (typeof scopes !== 'undefined') { + apiPayload['scopes'] = scopes; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -669,40 +995,38 @@ export class Sites { * @deprecated Use the object parameter style method for a better developer experience. */ delete(siteId: string): Promise<{}>; - delete( - paramsOrFirst: { siteId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { siteId: string } | string): Promise<{}> { let params: { siteId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { siteId: string }; } else { params = { - siteId: paramsOrFirst as string + siteId: paramsOrFirst as string, }; } - - const siteId = params.siteId; + const siteId = params.siteId; if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } - - const apiPath = '/sites/{siteId}'.replace('{siteId}', encodeURIComponent(String(siteId))); - const payload: Payload = {}; + const apiPath = '/sites/{siteId}'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -713,7 +1037,10 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - updateSiteDeployment(params: { siteId: string, deploymentId: string }): Promise; + updateSiteDeployment(params: { + siteId: string; + deploymentId: string; + }): Promise; /** * Update the site active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your site. * @@ -723,51 +1050,59 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSiteDeployment(siteId: string, deploymentId: string): Promise; updateSiteDeployment( - paramsOrFirst: { siteId: string, deploymentId: string } | string, - ...rest: [(string)?] + siteId: string, + deploymentId: string, + ): Promise; + updateSiteDeployment( + paramsOrFirst: { siteId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise { - let params: { siteId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + let params: { siteId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + deploymentId: string; + }; } else { params = { siteId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const siteId = params.siteId; const deploymentId = params.deploymentId; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); } - - const apiPath = '/sites/{siteId}/deployment'.replace('{siteId}', encodeURIComponent(String(siteId))); - const payload: Payload = {}; + const apiPath = '/sites/{siteId}/deployment'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); + const apiPayload: Payload = {}; if (typeof deploymentId !== 'undefined') { - payload['deploymentId'] = deploymentId; + apiPayload['deploymentId'] = deploymentId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -780,7 +1115,12 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - listDeployments(params: { siteId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listDeployments(params: { + siteId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all the site's code deployments. You can use the query params to filter your results. * @@ -792,57 +1132,79 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listDeployments(siteId: string, queries?: string[], search?: string, total?: boolean): Promise; listDeployments( - paramsOrFirst: { siteId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + siteId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listDeployments( + paramsOrFirst: + | { + siteId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { siteId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + siteId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { siteId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const siteId = params.siteId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } - - const apiPath = '/sites/{siteId}/deployments'.replace('{siteId}', encodeURIComponent(String(siteId))); - const payload: Payload = {}; + const apiPath = '/sites/{siteId}/deployments'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -857,7 +1219,15 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - createDeployment(params: { siteId: string, code: File | InputFile, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean, onProgress?: (progress: UploadProgress) => void }): Promise; + createDeployment(params: { + siteId: string; + code: File | InputFile; + installCommand?: string; + buildCommand?: string; + outputDirectory?: string; + activate?: boolean; + onProgress?: (progress: UploadProgress) => void; + }): Promise; /** * Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the site's deployment to use your new deployment ID. * @@ -871,17 +1241,62 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDeployment(siteId: string, code: File | InputFile, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean, onProgress?: (progress: UploadProgress) => void): Promise; createDeployment( - paramsOrFirst: { siteId: string, code: File | InputFile, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean, onProgress?: (progress: UploadProgress) => void } | string, - ...rest: [(File | InputFile)?, (string)?, (string)?, (string)?, (boolean)?,((progress: UploadProgress) => void)?] + siteId: string, + code: File | InputFile, + installCommand?: string, + buildCommand?: string, + outputDirectory?: string, + activate?: boolean, + onProgress?: (progress: UploadProgress) => void, + ): Promise; + createDeployment( + paramsOrFirst: + | { + siteId: string; + code: File | InputFile; + installCommand?: string; + buildCommand?: string; + outputDirectory?: string; + activate?: boolean; + onProgress?: (progress: UploadProgress) => void; + } + | string, + ...rest: [ + (File | InputFile)?, + string?, + string?, + string?, + boolean?, + ((progress: UploadProgress) => void)?, + ] ): Promise { - let params: { siteId: string, code: File | InputFile, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean }; - let onProgress: ((progress: UploadProgress) => void); - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, code: File | InputFile, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean }; - onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void); + let params: { + siteId: string; + code: File | InputFile; + installCommand?: string; + buildCommand?: string; + outputDirectory?: string; + activate?: boolean; + }; + let onProgress: (progress: UploadProgress) => void; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + code: File | InputFile; + installCommand?: string; + buildCommand?: string; + outputDirectory?: string; + activate?: boolean; + }; + onProgress = paramsOrFirst?.onProgress as ( + progress: UploadProgress, + ) => void; } else { params = { siteId: paramsOrFirst as string, @@ -889,56 +1304,57 @@ export class Sites { installCommand: rest[1] as string, buildCommand: rest[2] as string, outputDirectory: rest[3] as string, - activate: rest[4] as boolean + activate: rest[4] as boolean, }; - onProgress = rest[5] as ((progress: UploadProgress) => void); + onProgress = rest[5] as (progress: UploadProgress) => void; } - + const siteId = params.siteId; const code = params.code; const installCommand = params.installCommand; const buildCommand = params.buildCommand; const outputDirectory = params.outputDirectory; const activate = params.activate; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } - - const apiPath = '/sites/{siteId}/deployments'.replace('{siteId}', encodeURIComponent(String(siteId))); - const payload: Payload = {}; + const apiPath = '/sites/{siteId}/deployments'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); + const apiPayload: Payload = {}; if (typeof installCommand !== 'undefined') { - payload['installCommand'] = installCommand; + apiPayload['installCommand'] = installCommand; } if (typeof buildCommand !== 'undefined') { - payload['buildCommand'] = buildCommand; + apiPayload['buildCommand'] = buildCommand; } if (typeof outputDirectory !== 'undefined') { - payload['outputDirectory'] = outputDirectory; + apiPayload['outputDirectory'] = outputDirectory; } if (typeof code !== 'undefined') { - payload['code'] = code; + apiPayload['code'] = code; } if (typeof activate !== 'undefined') { - payload['activate'] = activate; + apiPayload['activate'] = activate; } 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', - } + accept: 'application/json', + }; return this.client.chunkedUpload( 'post', uri, apiHeaders, - payload, - onProgress + apiPayload, + onProgress, ); } @@ -950,7 +1366,10 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - createDuplicateDeployment(params: { siteId: string, deploymentId: string }): Promise; + createDuplicateDeployment(params: { + siteId: string; + deploymentId: string; + }): Promise; /** * Create a new build for an existing site deployment. This endpoint allows you to rebuild a deployment with the updated site configuration, including its commands and output directory if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. * @@ -960,56 +1379,64 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDuplicateDeployment(siteId: string, deploymentId: string): Promise; createDuplicateDeployment( - paramsOrFirst: { siteId: string, deploymentId: string } | string, - ...rest: [(string)?] + siteId: string, + deploymentId: string, + ): Promise; + createDuplicateDeployment( + paramsOrFirst: { siteId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise { - let params: { siteId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + let params: { siteId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + deploymentId: string; + }; } else { params = { siteId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const siteId = params.siteId; const deploymentId = params.deploymentId; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); } - - const apiPath = '/sites/{siteId}/deployments/duplicate'.replace('{siteId}', encodeURIComponent(String(siteId))); - const payload: Payload = {}; + const apiPath = '/sites/{siteId}/deployments/duplicate'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); + const apiPayload: Payload = {}; if (typeof deploymentId !== 'undefined') { - payload['deploymentId'] = deploymentId; + apiPayload['deploymentId'] = deploymentId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Create a deployment based on a template. - * + * * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/sites/templates) to find the template details. * * @param {string} params.siteId - Site ID. @@ -1022,10 +1449,18 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - createTemplateDeployment(params: { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }): Promise; + createTemplateDeployment(params: { + siteId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + }): Promise; /** * Create a deployment based on a template. - * + * * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/sites/templates) to find the template details. * * @param {string} siteId - Site ID. @@ -1039,15 +1474,60 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTemplateDeployment(siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean): Promise; createTemplateDeployment( - paramsOrFirst: { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (TemplateReferenceType)?, (string)?, (boolean)?] + siteId: string, + repository: string, + owner: string, + rootDirectory: string, + type: TemplateReferenceType, + reference: string, + activate?: boolean, + ): Promise; + createTemplateDeployment( + paramsOrFirst: + | { + siteId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + } + | string, + ...rest: [ + string?, + string?, + string?, + TemplateReferenceType?, + string?, + boolean?, + ] ): Promise { - let params: { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; + let params: { + siteId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + repository: string; + owner: string; + rootDirectory: string; + type: TemplateReferenceType; + reference: string; + activate?: boolean; + }; } else { params = { siteId: paramsOrFirst as string, @@ -1056,10 +1536,10 @@ export class Sites { rootDirectory: rest[2] as string, type: rest[3] as TemplateReferenceType, reference: rest[4] as string, - activate: rest[5] as boolean + activate: rest[5] as boolean, }; } - + const siteId = params.siteId; const repository = params.repository; const owner = params.owner; @@ -1067,65 +1547,67 @@ export class Sites { const type = params.type; const reference = params.reference; const activate = params.activate; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof repository === 'undefined') { - throw new AppwriteException('Missing required parameter: "repository"'); + throw new AppwriteException( + 'Missing required parameter: "repository"', + ); } if (typeof owner === 'undefined') { throw new AppwriteException('Missing required parameter: "owner"'); } if (typeof rootDirectory === 'undefined') { - throw new AppwriteException('Missing required parameter: "rootDirectory"'); + throw new AppwriteException( + 'Missing required parameter: "rootDirectory"', + ); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof reference === 'undefined') { - throw new AppwriteException('Missing required parameter: "reference"'); + throw new AppwriteException( + 'Missing required parameter: "reference"', + ); } - - const apiPath = '/sites/{siteId}/deployments/template'.replace('{siteId}', encodeURIComponent(String(siteId))); - const payload: Payload = {}; + const apiPath = '/sites/{siteId}/deployments/template'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); + const apiPayload: Payload = {}; if (typeof repository !== 'undefined') { - payload['repository'] = repository; + apiPayload['repository'] = repository; } if (typeof owner !== 'undefined') { - payload['owner'] = owner; + apiPayload['owner'] = owner; } if (typeof rootDirectory !== 'undefined') { - payload['rootDirectory'] = rootDirectory; + apiPayload['rootDirectory'] = rootDirectory; } if (typeof type !== 'undefined') { - payload['type'] = type; + apiPayload['type'] = type; } if (typeof reference !== 'undefined') { - payload['reference'] = reference; + apiPayload['reference'] = reference; } if (typeof activate !== 'undefined') { - payload['activate'] = activate; + apiPayload['activate'] = activate; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Create a deployment when a site is connected to VCS. - * + * * This endpoint lets you create deployment from a branch, commit, or a tag. * * @param {string} params.siteId - Site ID. @@ -1135,10 +1617,15 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - createVcsDeployment(params: { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean }): Promise; + createVcsDeployment(params: { + siteId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + }): Promise; /** * Create a deployment when a site is connected to VCS. - * + * * This endpoint lets you create deployment from a branch, commit, or a tag. * * @param {string} siteId - Site ID. @@ -1149,29 +1636,54 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVcsDeployment(siteId: string, type: VCSReferenceType, reference: string, activate?: boolean): Promise; createVcsDeployment( - paramsOrFirst: { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean } | string, - ...rest: [(VCSReferenceType)?, (string)?, (boolean)?] + siteId: string, + type: VCSReferenceType, + reference: string, + activate?: boolean, + ): Promise; + createVcsDeployment( + paramsOrFirst: + | { + siteId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + } + | string, + ...rest: [VCSReferenceType?, string?, boolean?] ): Promise { - let params: { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean }; + let params: { + siteId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + type: VCSReferenceType; + reference: string; + activate?: boolean; + }; } else { params = { siteId: paramsOrFirst as string, type: rest[0] as VCSReferenceType, reference: rest[1] as string, - activate: rest[2] as boolean + activate: rest[2] as boolean, }; } - + const siteId = params.siteId; const type = params.type; const reference = params.reference; const activate = params.activate; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } @@ -1179,34 +1691,33 @@ export class Sites { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof reference === 'undefined') { - throw new AppwriteException('Missing required parameter: "reference"'); + throw new AppwriteException( + 'Missing required parameter: "reference"', + ); } - - const apiPath = '/sites/{siteId}/deployments/vcs'.replace('{siteId}', encodeURIComponent(String(siteId))); - const payload: Payload = {}; + const apiPath = '/sites/{siteId}/deployments/vcs'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); + const apiPayload: Payload = {}; if (typeof type !== 'undefined') { - payload['type'] = type; + apiPayload['type'] = type; } if (typeof reference !== 'undefined') { - payload['reference'] = reference; + apiPayload['reference'] = reference; } if (typeof activate !== 'undefined') { - payload['activate'] = activate; + apiPayload['activate'] = activate; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1217,7 +1728,10 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - getDeployment(params: { siteId: string, deploymentId: string }): Promise; + getDeployment(params: { + siteId: string; + deploymentId: string; + }): Promise; /** * Get a site deployment by its unique ID. * @@ -1227,47 +1741,57 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getDeployment(siteId: string, deploymentId: string): Promise; getDeployment( - paramsOrFirst: { siteId: string, deploymentId: string } | string, - ...rest: [(string)?] + siteId: string, + deploymentId: string, + ): Promise; + getDeployment( + paramsOrFirst: { siteId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise { - let params: { siteId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + let params: { siteId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + deploymentId: string; + }; } else { params = { siteId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const siteId = params.siteId; const deploymentId = params.deploymentId; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/sites/{siteId}/deployments/{deploymentId}'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = '/sites/{siteId}/deployments/{deploymentId}' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1278,7 +1802,10 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteDeployment(params: { siteId: string, deploymentId: string }): Promise<{}>; + deleteDeployment(params: { + siteId: string; + deploymentId: string; + }): Promise<{}>; /** * Delete a site deployment by its unique ID. * @@ -1290,45 +1817,52 @@ export class Sites { */ deleteDeployment(siteId: string, deploymentId: string): Promise<{}>; deleteDeployment( - paramsOrFirst: { siteId: string, deploymentId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { siteId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { siteId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + let params: { siteId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + deploymentId: string; + }; } else { params = { siteId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const siteId = params.siteId; const deploymentId = params.deploymentId; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/sites/{siteId}/deployments/{deploymentId}'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = '/sites/{siteId}/deployments/{deploymentId}' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1341,7 +1875,12 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - getDeploymentDownload(params: { siteId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string }): Promise; + getDeploymentDownload(params: { + siteId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + }): Promise; /** * Get a site deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. * @@ -1353,57 +1892,88 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getDeploymentDownload(siteId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string): Promise; getDeploymentDownload( - paramsOrFirst: { siteId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string } | string, - ...rest: [(string)?, (DeploymentDownloadType)?, (string)?] + siteId: string, + deploymentId: string, + type?: DeploymentDownloadType, + token?: string, + ): Promise; + getDeploymentDownload( + paramsOrFirst: + | { + siteId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + } + | string, + ...rest: [string?, DeploymentDownloadType?, string?] ): Promise { - let params: { siteId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string }; + let params: { + siteId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + deploymentId: string; + type?: DeploymentDownloadType; + token?: string; + }; } else { params = { siteId: paramsOrFirst as string, deploymentId: rest[0] as string, type: rest[1] as DeploymentDownloadType, - token: rest[2] as string + token: rest[2] as string, }; } - + const siteId = params.siteId; const deploymentId = params.deploymentId; const type = params.type; const token = params.token; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/sites/{siteId}/deployments/{deploymentId}/download'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = '/sites/{siteId}/deployments/{deploymentId}/download' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); + const apiPayload: Payload = {}; if (typeof type !== 'undefined') { - payload['type'] = type; + apiPayload['type'] = type; } if (typeof token !== 'undefined') { - payload['token'] = token; + apiPayload['token'] = token; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': '*/*', - } + accept: '*/*', + }; return this.client.call( 'get', uri, apiHeaders, - payload, - 'arrayBuffer' + apiPayload, + 'arrayBuffer', ); } @@ -1415,7 +1985,10 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - updateDeploymentStatus(params: { siteId: string, deploymentId: string }): Promise; + updateDeploymentStatus(params: { + siteId: string; + deploymentId: string; + }): Promise; /** * Cancel an ongoing site deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. * @@ -1425,48 +1998,58 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDeploymentStatus(siteId: string, deploymentId: string): Promise; updateDeploymentStatus( - paramsOrFirst: { siteId: string, deploymentId: string } | string, - ...rest: [(string)?] + siteId: string, + deploymentId: string, + ): Promise; + updateDeploymentStatus( + paramsOrFirst: { siteId: string; deploymentId: string } | string, + ...rest: [string?] ): Promise { - let params: { siteId: string, deploymentId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + let params: { siteId: string; deploymentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + deploymentId: string; + }; } else { params = { siteId: paramsOrFirst as string, - deploymentId: rest[0] as string + deploymentId: rest[0] as string, }; } - + const siteId = params.siteId; const deploymentId = params.deploymentId; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - - const apiPath = '/sites/{siteId}/deployments/{deploymentId}/status'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{deploymentId}', encodeURIComponent(String(deploymentId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "deploymentId"', + ); + } + const apiPath = '/sites/{siteId}/deployments/{deploymentId}/status' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace( + '{deploymentId}', + encodeURIComponent(String(deploymentId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1478,7 +2061,11 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - listLogs(params: { siteId: string, queries?: string[], total?: boolean }): Promise; + listLogs(params: { + siteId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all site logs. You can use the query params to filter your results. * @@ -1489,52 +2076,61 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listLogs(siteId: string, queries?: string[], total?: boolean): Promise; listLogs( - paramsOrFirst: { siteId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + siteId: string, + queries?: string[], + total?: boolean, + ): Promise; + listLogs( + paramsOrFirst: + { siteId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { siteId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, queries?: string[], total?: boolean }; + let params: { siteId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { siteId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const siteId = params.siteId; const queries = params.queries; const total = params.total; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } - - const apiPath = '/sites/{siteId}/logs'.replace('{siteId}', encodeURIComponent(String(siteId))); - const payload: Payload = {}; + const apiPath = '/sites/{siteId}/logs'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1545,7 +2141,10 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - getLog(params: { siteId: string, logId: string }): Promise; + getLog(params: { + siteId: string; + logId: string; + }): Promise; /** * Get a site request log by its unique ID. * @@ -1557,45 +2156,44 @@ export class Sites { */ getLog(siteId: string, logId: string): Promise; getLog( - paramsOrFirst: { siteId: string, logId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { siteId: string; logId: string } | string, + ...rest: [string?] ): Promise { - let params: { siteId: string, logId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, logId: string }; + let params: { siteId: string; logId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { siteId: string; logId: string }; } else { params = { siteId: paramsOrFirst as string, - logId: rest[0] as string + logId: rest[0] as string, }; } - + const siteId = params.siteId; const logId = params.logId; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof logId === 'undefined') { throw new AppwriteException('Missing required parameter: "logId"'); } - - const apiPath = '/sites/{siteId}/logs/{logId}'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{logId}', encodeURIComponent(String(logId))); - const payload: Payload = {}; + const apiPath = '/sites/{siteId}/logs/{logId}' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace('{logId}', encodeURIComponent(String(logId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1606,7 +2204,7 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteLog(params: { siteId: string, logId: string }): Promise<{}>; + deleteLog(params: { siteId: string; logId: string }): Promise<{}>; /** * Delete a site log by its unique ID. * @@ -1618,46 +2216,45 @@ export class Sites { */ deleteLog(siteId: string, logId: string): Promise<{}>; deleteLog( - paramsOrFirst: { siteId: string, logId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { siteId: string; logId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { siteId: string, logId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, logId: string }; + let params: { siteId: string; logId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { siteId: string; logId: string }; } else { params = { siteId: paramsOrFirst as string, - logId: rest[0] as string + logId: rest[0] as string, }; } - + const siteId = params.siteId; const logId = params.logId; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof logId === 'undefined') { throw new AppwriteException('Missing required parameter: "logId"'); } - - const apiPath = '/sites/{siteId}/logs/{logId}'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{logId}', encodeURIComponent(String(logId))); - const payload: Payload = {}; + const apiPath = '/sites/{siteId}/logs/{logId}' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace('{logId}', encodeURIComponent(String(logId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1669,7 +2266,11 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - listVariables(params: { siteId: string, queries?: string[], total?: boolean }): Promise; + listVariables(params: { + siteId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all variables of a specific site. * @@ -1680,52 +2281,61 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listVariables(siteId: string, queries?: string[], total?: boolean): Promise; listVariables( - paramsOrFirst: { siteId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + siteId: string, + queries?: string[], + total?: boolean, + ): Promise; + listVariables( + paramsOrFirst: + { siteId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { siteId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, queries?: string[], total?: boolean }; + let params: { siteId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { siteId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const siteId = params.siteId; const queries = params.queries; const total = params.total; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } - - const apiPath = '/sites/{siteId}/variables'.replace('{siteId}', encodeURIComponent(String(siteId))); - const payload: Payload = {}; + const apiPath = '/sites/{siteId}/variables'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1733,55 +2343,92 @@ export class Sites { * * @param {string} params.siteId - Site unique ID. * @param {string} params.variableId - Variable 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.key - Variable key. Max length: 255 chars. + * @param {string} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} */ - createVariable(params: { siteId: string, variableId: string, key: string, value: string, secret?: boolean }): Promise; + createVariable(params: { + siteId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + }): Promise; /** * Create a new site variable. These variables can be accessed during build and runtime (server-side rendering) as environment variables. * * @param {string} siteId - Site unique ID. * @param {string} variableId - Variable 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} key - Variable key. Max length: 255 chars. + * @param {string} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVariable(siteId: string, variableId: string, key: string, value: string, secret?: boolean): Promise; createVariable( - paramsOrFirst: { siteId: string, variableId: string, key: string, value: string, secret?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?] + siteId: string, + variableId: string, + key: string, + value: string, + secret?: boolean, + ): Promise; + createVariable( + paramsOrFirst: + | { + siteId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + } + | string, + ...rest: [string?, string?, string?, boolean?] ): Promise { - let params: { siteId: string, variableId: string, key: string, value: string, secret?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, variableId: string, key: string, value: string, secret?: boolean }; + let params: { + siteId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + variableId: string; + key: string; + value: string; + secret?: boolean; + }; } else { params = { siteId: paramsOrFirst as string, variableId: rest[0] as string, key: rest[1] as string, value: rest[2] as string, - secret: rest[3] as boolean + secret: rest[3] as boolean, }; } - + const siteId = params.siteId; const variableId = params.variableId; const key = params.key; const value = params.value; const secret = params.secret; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -1789,35 +2436,32 @@ export class Sites { if (typeof value === 'undefined') { throw new AppwriteException('Missing required parameter: "value"'); } - - const apiPath = '/sites/{siteId}/variables'.replace('{siteId}', encodeURIComponent(String(siteId))); - const payload: Payload = {}; + const apiPath = '/sites/{siteId}/variables'.replace( + '{siteId}', + encodeURIComponent(String(siteId)), + ); + const apiPayload: Payload = {}; if (typeof variableId !== 'undefined') { - payload['variableId'] = variableId; + apiPayload['variableId'] = variableId; } if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof value !== 'undefined') { - payload['value'] = value; + apiPayload['value'] = value; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1828,7 +2472,10 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - getVariable(params: { siteId: string, variableId: string }): Promise; + getVariable(params: { + siteId: string; + variableId: string; + }): Promise; /** * Get a variable by its unique ID. * @@ -1840,45 +2487,49 @@ export class Sites { */ getVariable(siteId: string, variableId: string): Promise; getVariable( - paramsOrFirst: { siteId: string, variableId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { siteId: string; variableId: string } | string, + ...rest: [string?] ): Promise { - let params: { siteId: string, variableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, variableId: string }; + let params: { siteId: string; variableId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + variableId: string; + }; } else { params = { siteId: paramsOrFirst as string, - variableId: rest[0] as string + variableId: rest[0] as string, }; } - + const siteId = params.siteId; const variableId = params.variableId; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); - } - - const apiPath = '/sites/{siteId}/variables/{variableId}'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{variableId}', encodeURIComponent(String(variableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); + } + const apiPath = '/sites/{siteId}/variables/{variableId}' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace('{variableId}', encodeURIComponent(String(variableId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1886,82 +2537,115 @@ export class Sites { * * @param {string} params.siteId - Site unique ID. * @param {string} params.variableId - Variable unique ID. - * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} */ - updateVariable(params: { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean }): Promise; + updateVariable(params: { + siteId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }): Promise; /** * Update variable by its unique ID. * * @param {string} siteId - Site unique ID. * @param {string} variableId - Variable unique ID. - * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateVariable(siteId: string, variableId: string, key?: string, value?: string, secret?: boolean): Promise; updateVariable( - paramsOrFirst: { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (boolean)?] + siteId: string, + variableId: string, + key?: string, + value?: string, + secret?: boolean, + ): Promise; + updateVariable( + paramsOrFirst: + | { + siteId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + } + | string, + ...rest: [string?, string?, string?, boolean?] ): Promise { - let params: { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean }; + let params: { + siteId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + variableId: string; + key?: string; + value?: string; + secret?: boolean; + }; } else { params = { siteId: paramsOrFirst as string, variableId: rest[0] as string, key: rest[1] as string, value: rest[2] as string, - secret: rest[3] as boolean + secret: rest[3] as boolean, }; } - + const siteId = params.siteId; const variableId = params.variableId; const key = params.key; const value = params.value; const secret = params.secret; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); - } - - const apiPath = '/sites/{siteId}/variables/{variableId}'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{variableId}', encodeURIComponent(String(variableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); + } + const apiPath = '/sites/{siteId}/variables/{variableId}' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace('{variableId}', encodeURIComponent(String(variableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof value !== 'undefined') { - payload['value'] = value; + apiPayload['value'] = value; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1972,7 +2656,7 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteVariable(params: { siteId: string, variableId: string }): Promise<{}>; + deleteVariable(params: { siteId: string; variableId: string }): Promise<{}>; /** * Delete a variable by its unique ID. * @@ -1984,44 +2668,48 @@ export class Sites { */ deleteVariable(siteId: string, variableId: string): Promise<{}>; deleteVariable( - paramsOrFirst: { siteId: string, variableId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { siteId: string; variableId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { siteId: string, variableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, variableId: string }; + let params: { siteId: string; variableId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + siteId: string; + variableId: string; + }; } else { params = { siteId: paramsOrFirst as string, - variableId: rest[0] as string + variableId: rest[0] as string, }; } - + const siteId = params.siteId; const variableId = params.variableId; - if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof variableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "variableId"'); - } - - const apiPath = '/sites/{siteId}/variables/{variableId}'.replace('{siteId}', encodeURIComponent(String(siteId))).replace('{variableId}', encodeURIComponent(String(variableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "variableId"', + ); + } + const apiPath = '/sites/{siteId}/variables/{variableId}' + .replace('{siteId}', encodeURIComponent(String(siteId))) + .replace('{variableId}', encodeURIComponent(String(variableId))); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } } diff --git a/src/services/storage.ts b/src/services/storage.ts index 8424bfac..6d1d65f2 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -1,12 +1,15 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { + AppwriteException, + Client, + type Payload, + UploadProgress, +} from '../client'; import type { Models } from '../models'; - import { InputFile } from '../inputFile'; import { Compression } from '../enums/compression'; import { ImageGravity } from '../enums/image-gravity'; import { ImageFormat } from '../enums/image-format'; - export class Storage { client: Client; @@ -23,7 +26,11 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - listBuckets(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listBuckets(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all the storage buckets. You can use the query params to filter your results. * @@ -34,52 +41,59 @@ export class Storage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listBuckets(queries?: string[], search?: string, total?: boolean): Promise; listBuckets( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listBuckets( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - - const apiPath = '/storage/buckets'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -99,7 +113,19 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - createBucket(params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }): Promise; + createBucket(params: { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + }): Promise; /** * Create a new storage bucket. * @@ -118,15 +144,80 @@ export class Storage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean): Promise; createBucket( - paramsOrFirst: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?, (boolean)?, (number)?, (string[])?, (Compression)?, (boolean)?, (boolean)?, (boolean)?] + bucketId: string, + name: string, + permissions?: string[], + fileSecurity?: boolean, + enabled?: boolean, + maximumFileSize?: number, + allowedFileExtensions?: string[], + compression?: Compression, + encryption?: boolean, + antivirus?: boolean, + transformations?: boolean, + ): Promise; + createBucket( + paramsOrFirst: + | { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + } + | string, + ...rest: [ + string?, + string[]?, + boolean?, + boolean?, + number?, + string[]?, + Compression?, + boolean?, + boolean?, + boolean?, + ] ): Promise { - let params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; + let params: { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + }; } else { params = { bucketId: paramsOrFirst as string, @@ -139,10 +230,10 @@ export class Storage { compression: rest[6] as Compression, encryption: rest[7] as boolean, antivirus: rest[8] as boolean, - transformations: rest[9] as boolean + transformations: rest[9] as boolean, }; } - + const bucketId = params.bucketId; const name = params.name; const permissions = params.permissions; @@ -154,63 +245,58 @@ export class Storage { const encryption = params.encryption; const antivirus = params.antivirus; const transformations = params.transformations; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/storage/buckets'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof bucketId !== 'undefined') { - payload['bucketId'] = bucketId; + apiPayload['bucketId'] = bucketId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof fileSecurity !== 'undefined') { - payload['fileSecurity'] = fileSecurity; + apiPayload['fileSecurity'] = fileSecurity; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof maximumFileSize !== 'undefined') { - payload['maximumFileSize'] = maximumFileSize; + apiPayload['maximumFileSize'] = maximumFileSize; } if (typeof allowedFileExtensions !== 'undefined') { - payload['allowedFileExtensions'] = allowedFileExtensions; + apiPayload['allowedFileExtensions'] = allowedFileExtensions; } if (typeof compression !== 'undefined') { - payload['compression'] = compression; + apiPayload['compression'] = compression; } if (typeof encryption !== 'undefined') { - payload['encryption'] = encryption; + apiPayload['encryption'] = encryption; } if (typeof antivirus !== 'undefined') { - payload['antivirus'] = antivirus; + apiPayload['antivirus'] = antivirus; } if (typeof transformations !== 'undefined') { - payload['transformations'] = transformations; + apiPayload['transformations'] = transformations; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -231,39 +317,41 @@ export class Storage { */ getBucket(bucketId: string): Promise; getBucket( - paramsOrFirst: { bucketId: string } | string + paramsOrFirst: { bucketId: string } | string, ): Promise { let params: { bucketId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { bucketId: string }; } else { params = { - bucketId: paramsOrFirst as string + bucketId: paramsOrFirst as string, }; } - - const bucketId = params.bucketId; + const bucketId = params.bucketId; if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } - - const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))); - const payload: Payload = {}; + const apiPath = '/storage/buckets/{bucketId}'.replace( + '{bucketId}', + encodeURIComponent(String(bucketId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -283,7 +371,19 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - updateBucket(params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }): Promise; + updateBucket(params: { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + }): Promise; /** * Update a storage bucket by its unique ID. * @@ -302,15 +402,80 @@ export class Storage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean): Promise; updateBucket( - paramsOrFirst: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?, (boolean)?, (number)?, (string[])?, (Compression)?, (boolean)?, (boolean)?, (boolean)?] + bucketId: string, + name: string, + permissions?: string[], + fileSecurity?: boolean, + enabled?: boolean, + maximumFileSize?: number, + allowedFileExtensions?: string[], + compression?: Compression, + encryption?: boolean, + antivirus?: boolean, + transformations?: boolean, + ): Promise; + updateBucket( + paramsOrFirst: + | { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + } + | string, + ...rest: [ + string?, + string[]?, + boolean?, + boolean?, + number?, + string[]?, + Compression?, + boolean?, + boolean?, + boolean?, + ] ): Promise { - let params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; + let params: { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + name: string; + permissions?: string[]; + fileSecurity?: boolean; + enabled?: boolean; + maximumFileSize?: number; + allowedFileExtensions?: string[]; + compression?: Compression; + encryption?: boolean; + antivirus?: boolean; + transformations?: boolean; + }; } else { params = { bucketId: paramsOrFirst as string, @@ -323,10 +488,10 @@ export class Storage { compression: rest[6] as Compression, encryption: rest[7] as boolean, antivirus: rest[8] as boolean, - transformations: rest[9] as boolean + transformations: rest[9] as boolean, }; } - + const bucketId = params.bucketId; const name = params.name; const permissions = params.permissions; @@ -338,60 +503,58 @@ export class Storage { const encryption = params.encryption; const antivirus = params.antivirus; const transformations = params.transformations; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))); - const payload: Payload = {}; + const apiPath = '/storage/buckets/{bucketId}'.replace( + '{bucketId}', + encodeURIComponent(String(bucketId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof fileSecurity !== 'undefined') { - payload['fileSecurity'] = fileSecurity; + apiPayload['fileSecurity'] = fileSecurity; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof maximumFileSize !== 'undefined') { - payload['maximumFileSize'] = maximumFileSize; + apiPayload['maximumFileSize'] = maximumFileSize; } if (typeof allowedFileExtensions !== 'undefined') { - payload['allowedFileExtensions'] = allowedFileExtensions; + apiPayload['allowedFileExtensions'] = allowedFileExtensions; } if (typeof compression !== 'undefined') { - payload['compression'] = compression; + apiPayload['compression'] = compression; } if (typeof encryption !== 'undefined') { - payload['encryption'] = encryption; + apiPayload['encryption'] = encryption; } if (typeof antivirus !== 'undefined') { - payload['antivirus'] = antivirus; + apiPayload['antivirus'] = antivirus; } if (typeof transformations !== 'undefined') { - payload['transformations'] = transformations; + apiPayload['transformations'] = transformations; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -411,40 +574,40 @@ export class Storage { * @deprecated Use the object parameter style method for a better developer experience. */ deleteBucket(bucketId: string): Promise<{}>; - deleteBucket( - paramsOrFirst: { bucketId: string } | string - ): Promise<{}> { + deleteBucket(paramsOrFirst: { bucketId: string } | string): Promise<{}> { let params: { bucketId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { bucketId: string }; } else { params = { - bucketId: paramsOrFirst as string + bucketId: paramsOrFirst as string, }; } - - const bucketId = params.bucketId; + const bucketId = params.bucketId; if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } - - const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))); - const payload: Payload = {}; + const apiPath = '/storage/buckets/{bucketId}'.replace( + '{bucketId}', + encodeURIComponent(String(bucketId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -457,7 +620,12 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - listFiles(params: { bucketId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listFiles(params: { + bucketId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all the user files. You can use the query params to filter your results. * @@ -469,68 +637,92 @@ export class Storage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listFiles(bucketId: string, queries?: string[], search?: string, total?: boolean): Promise; listFiles( - paramsOrFirst: { bucketId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + bucketId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listFiles( + paramsOrFirst: + | { + bucketId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { bucketId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + bucketId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { bucketId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const bucketId = params.bucketId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } - - const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', encodeURIComponent(String(bucketId))); - const payload: Payload = {}; + const apiPath = '/storage/buckets/{bucketId}/files'.replace( + '{bucketId}', + encodeURIComponent(String(bucketId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. - * + * * Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of `5MB`. The `content-range` header values should always be in bytes. - * + * * When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in `x-appwrite-id` header to allow the server to know that the partial upload is for the existing file and not for a new one. - * + * * If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally. - * + * * * @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param {string} params.fileId - File 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. @@ -540,16 +732,23 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - createFile(params: { bucketId: string, fileId: string, file: File | InputFile, permissions?: string[], folder?: string, onProgress?: (progress: UploadProgress) => void }): Promise; + createFile(params: { + bucketId: string; + fileId: string; + file: File | InputFile; + permissions?: string[]; + folder?: string; + onProgress?: (progress: UploadProgress) => void; + }): Promise; /** * Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. - * + * * Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of `5MB`. The `content-range` header values should always be in bytes. - * + * * When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in `x-appwrite-id` header to allow the server to know that the partial upload is for the existing file and not for a new one. - * + * * If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally. - * + * * * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param {string} fileId - File 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. @@ -560,36 +759,77 @@ export class Storage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFile(bucketId: string, fileId: string, file: File | InputFile, permissions?: string[], folder?: string, onProgress?: (progress: UploadProgress) => void): Promise; createFile( - paramsOrFirst: { bucketId: string, fileId: string, file: File | InputFile, permissions?: string[], folder?: string, onProgress?: (progress: UploadProgress) => void } | string, - ...rest: [(string)?, (File | InputFile)?, (string[])?, (string)?,((progress: UploadProgress) => void)?] + bucketId: string, + fileId: string, + file: File | InputFile, + permissions?: string[], + folder?: string, + onProgress?: (progress: UploadProgress) => void, + ): Promise; + createFile( + paramsOrFirst: + | { + bucketId: string; + fileId: string; + file: File | InputFile; + permissions?: string[]; + folder?: string; + onProgress?: (progress: UploadProgress) => void; + } + | string, + ...rest: [ + string?, + (File | InputFile)?, + string[]?, + string?, + ((progress: UploadProgress) => void)?, + ] ): Promise { - let params: { bucketId: string, fileId: string, file: File | InputFile, permissions?: string[], folder?: string }; - let onProgress: ((progress: UploadProgress) => void); - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, file: File | InputFile, permissions?: string[], folder?: string }; - onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void); + let params: { + bucketId: string; + fileId: string; + file: File | InputFile; + permissions?: string[]; + folder?: string; + }; + let onProgress: (progress: UploadProgress) => void; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + file: File | InputFile; + permissions?: string[]; + folder?: string; + }; + onProgress = paramsOrFirst?.onProgress as ( + progress: UploadProgress, + ) => void; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, file: rest[1] as File | InputFile, permissions: rest[2] as string[], - folder: rest[3] as string + folder: rest[3] as string, }; - onProgress = rest[4] as ((progress: UploadProgress) => void); + onProgress = rest[4] as (progress: UploadProgress) => void; } - + const bucketId = params.bucketId; const fileId = params.fileId; const file = params.file; const permissions = params.permissions; const folder = params.folder; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); @@ -597,35 +837,37 @@ export class Storage { if (typeof file === 'undefined') { throw new AppwriteException('Missing required parameter: "file"'); } - - const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', encodeURIComponent(String(bucketId))); - const payload: Payload = {}; + const apiPath = '/storage/buckets/{bucketId}/files'.replace( + '{bucketId}', + encodeURIComponent(String(bucketId)), + ); + const apiPayload: Payload = {}; if (typeof fileId !== 'undefined') { - payload['fileId'] = fileId; + apiPayload['fileId'] = fileId; } if (typeof file !== 'undefined') { - payload['file'] = file; + apiPayload['file'] = file; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof folder !== 'undefined') { - payload['folder'] = folder; + apiPayload['folder'] = folder; } 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', - } + accept: 'application/json', + }; return this.client.chunkedUpload( 'post', uri, apiHeaders, - payload, - onProgress + apiPayload, + onProgress, ); } @@ -637,7 +879,7 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - getFile(params: { bucketId: string, fileId: string }): Promise; + getFile(params: { bucketId: string; fileId: string }): Promise; /** * Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata. * @@ -649,45 +891,49 @@ export class Storage { */ getFile(bucketId: string, fileId: string): Promise; getFile( - paramsOrFirst: { bucketId: string, fileId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { bucketId: string; fileId: string } | string, + ...rest: [string?] ): Promise { - let params: { bucketId: string, fileId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string }; + let params: { bucketId: string; fileId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + }; } else { params = { bucketId: paramsOrFirst as string, - fileId: rest[0] as string + fileId: rest[0] as string, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); - const payload: Payload = {}; + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -700,7 +946,12 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - updateFile(params: { bucketId: string, fileId: string, name?: string, permissions?: string[] }): Promise; + updateFile(params: { + bucketId: string; + fileId: string; + name?: string; + permissions?: string[]; + }): Promise; /** * Update a file by its unique ID. Only users with write permissions have access to update this resource. * @@ -712,58 +963,81 @@ export class Storage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateFile(bucketId: string, fileId: string, name?: string, permissions?: string[]): Promise; updateFile( - paramsOrFirst: { bucketId: string, fileId: string, name?: string, permissions?: string[] } | string, - ...rest: [(string)?, (string)?, (string[])?] + bucketId: string, + fileId: string, + name?: string, + permissions?: string[], + ): Promise; + updateFile( + paramsOrFirst: + | { + bucketId: string; + fileId: string; + name?: string; + permissions?: string[]; + } + | string, + ...rest: [string?, string?, string[]?] ): Promise { - let params: { bucketId: string, fileId: string, name?: string, permissions?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, name?: string, permissions?: string[] }; + let params: { + bucketId: string; + fileId: string; + name?: string; + permissions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + name?: string; + permissions?: string[]; + }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[] + permissions: rest[2] as string[], }; } - + const bucketId = params.bucketId; const fileId = params.fileId; const name = params.name; const permissions = params.permissions; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); - const payload: Payload = {}; + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -774,7 +1048,7 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteFile(params: { bucketId: string, fileId: string }): Promise<{}>; + deleteFile(params: { bucketId: string; fileId: string }): Promise<{}>; /** * Delete a file by its unique ID. Only users with write permissions have access to delete this resource. * @@ -786,45 +1060,49 @@ export class Storage { */ deleteFile(bucketId: string, fileId: string): Promise<{}>; deleteFile( - paramsOrFirst: { bucketId: string, fileId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { bucketId: string; fileId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { bucketId: string, fileId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string }; + let params: { bucketId: string; fileId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + }; } else { params = { bucketId: paramsOrFirst as string, - fileId: rest[0] as string + fileId: rest[0] as string, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); - const payload: Payload = {}; + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -836,7 +1114,11 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - getFileDownload(params: { bucketId: string, fileId: string, token?: string }): Promise; + getFileDownload(params: { + bucketId: string; + fileId: string; + token?: string; + }): Promise; /** * Get a file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. * @@ -847,52 +1129,67 @@ export class Storage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getFileDownload(bucketId: string, fileId: string, token?: string): Promise; getFileDownload( - paramsOrFirst: { bucketId: string, fileId: string, token?: string } | string, - ...rest: [(string)?, (string)?] + bucketId: string, + fileId: string, + token?: string, + ): Promise; + getFileDownload( + paramsOrFirst: + { bucketId: string; fileId: string; token?: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { bucketId: string, fileId: string, token?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, token?: string }; + let params: { bucketId: string; fileId: string; token?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + token?: string; + }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, - token: rest[1] as string + token: rest[1] as string, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; const token = params.token; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); - const payload: Payload = {}; + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); + const apiPayload: Payload = {}; if (typeof token !== 'undefined') { - payload['token'] = token; + apiPayload['token'] = token; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': '*/*', - } + accept: '*/*', + }; return this.client.call( 'get', uri, apiHeaders, - payload, - 'arrayBuffer' + apiPayload, + 'arrayBuffer', ); } @@ -916,7 +1213,22 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - getFilePreview(params: { bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string }): Promise; + getFilePreview(params: { + bucketId: string; + fileId: string; + width?: number; + height?: number; + gravity?: ImageGravity; + quality?: number; + borderWidth?: number; + borderColor?: string; + borderRadius?: number; + opacity?: number; + rotation?: number; + background?: string; + output?: ImageFormat; + token?: string; + }): Promise; /** * Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB. * @@ -938,15 +1250,95 @@ export class Storage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getFilePreview(bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string): Promise; getFilePreview( - paramsOrFirst: { bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string } | string, - ...rest: [(string)?, (number)?, (number)?, (ImageGravity)?, (number)?, (number)?, (string)?, (number)?, (number)?, (number)?, (string)?, (ImageFormat)?, (string)?] + bucketId: string, + fileId: string, + width?: number, + height?: number, + gravity?: ImageGravity, + quality?: number, + borderWidth?: number, + borderColor?: string, + borderRadius?: number, + opacity?: number, + rotation?: number, + background?: string, + output?: ImageFormat, + token?: string, + ): Promise; + getFilePreview( + paramsOrFirst: + | { + bucketId: string; + fileId: string; + width?: number; + height?: number; + gravity?: ImageGravity; + quality?: number; + borderWidth?: number; + borderColor?: string; + borderRadius?: number; + opacity?: number; + rotation?: number; + background?: string; + output?: ImageFormat; + token?: string; + } + | string, + ...rest: [ + string?, + number?, + number?, + ImageGravity?, + number?, + number?, + string?, + number?, + number?, + number?, + string?, + ImageFormat?, + string?, + ] ): Promise { - let params: { bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string }; + let params: { + bucketId: string; + fileId: string; + width?: number; + height?: number; + gravity?: ImageGravity; + quality?: number; + borderWidth?: number; + borderColor?: string; + borderRadius?: number; + opacity?: number; + rotation?: number; + background?: string; + output?: ImageFormat; + token?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + width?: number; + height?: number; + gravity?: ImageGravity; + quality?: number; + borderWidth?: number; + borderColor?: string; + borderRadius?: number; + opacity?: number; + rotation?: number; + background?: string; + output?: ImageFormat; + token?: string; + }; } else { params = { bucketId: paramsOrFirst as string, @@ -962,10 +1354,10 @@ export class Storage { rotation: rest[9] as number, background: rest[10] as string, output: rest[11] as ImageFormat, - token: rest[12] as string + token: rest[12] as string, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; const width = params.width; @@ -980,65 +1372,67 @@ export class Storage { const background = params.background; const output = params.output; const token = params.token; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); - const payload: Payload = {}; + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); + const apiPayload: Payload = {}; if (typeof width !== 'undefined') { - payload['width'] = width; + apiPayload['width'] = width; } if (typeof height !== 'undefined') { - payload['height'] = height; + apiPayload['height'] = height; } if (typeof gravity !== 'undefined') { - payload['gravity'] = gravity; + apiPayload['gravity'] = gravity; } if (typeof quality !== 'undefined') { - payload['quality'] = quality; + apiPayload['quality'] = quality; } if (typeof borderWidth !== 'undefined') { - payload['borderWidth'] = borderWidth; + apiPayload['borderWidth'] = borderWidth; } if (typeof borderColor !== 'undefined') { - payload['borderColor'] = borderColor; + apiPayload['borderColor'] = borderColor; } if (typeof borderRadius !== 'undefined') { - payload['borderRadius'] = borderRadius; + apiPayload['borderRadius'] = borderRadius; } if (typeof opacity !== 'undefined') { - payload['opacity'] = opacity; + apiPayload['opacity'] = opacity; } if (typeof rotation !== 'undefined') { - payload['rotation'] = rotation; + apiPayload['rotation'] = rotation; } if (typeof background !== 'undefined') { - payload['background'] = background; + apiPayload['background'] = background; } if (typeof output !== 'undefined') { - payload['output'] = output; + apiPayload['output'] = output; } if (typeof token !== 'undefined') { - payload['token'] = token; + apiPayload['token'] = token; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'image/*', - } + accept: 'image/*', + }; return this.client.call( 'get', uri, apiHeaders, - payload, - 'arrayBuffer' + apiPayload, + 'arrayBuffer', ); } @@ -1051,7 +1445,11 @@ export class Storage { * @throws {AppwriteException} * @returns {Promise} */ - getFileView(params: { bucketId: string, fileId: string, token?: string }): Promise; + getFileView(params: { + bucketId: string; + fileId: string; + token?: string; + }): Promise; /** * Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header. * @@ -1062,52 +1460,67 @@ export class Storage { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getFileView(bucketId: string, fileId: string, token?: string): Promise; getFileView( - paramsOrFirst: { bucketId: string, fileId: string, token?: string } | string, - ...rest: [(string)?, (string)?] + bucketId: string, + fileId: string, + token?: string, + ): Promise; + getFileView( + paramsOrFirst: + { bucketId: string; fileId: string; token?: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { bucketId: string, fileId: string, token?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, token?: string }; + let params: { bucketId: string; fileId: string; token?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + token?: string; + }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, - token: rest[1] as string + token: rest[1] as string, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; const token = params.token; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); - const payload: Payload = {}; + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); + const apiPayload: Payload = {}; if (typeof token !== 'undefined') { - payload['token'] = token; + apiPayload['token'] = token; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': '*/*', - } + accept: '*/*', + }; return this.client.call( 'get', uri, apiHeaders, - payload, - 'arrayBuffer' + apiPayload, + 'arrayBuffer', ); } } diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index ab832a42..c24744d0 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -1,12 +1,10 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - import { RelationshipType } from '../enums/relationship-type'; import { RelationMutate } from '../enums/relation-mutate'; import { TablesDBIndexType } from '../enums/tables-db-index-type'; import { OrderBy } from '../enums/order-by'; - export class TablesDB { client: Client; @@ -23,7 +21,11 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + list(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. * @@ -34,57 +36,64 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string, total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + list( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - - const apiPath = '/tablesdb'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Create a new Database. - * + * * * @param {string} params.databaseId - Unique 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 - Database name. Max length: 128 chars. @@ -95,10 +104,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - create(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }): Promise; + create(params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }): Promise; /** * Create a new Database. - * + * * * @param {string} databaseId - Unique 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 - Database name. Max length: 128 chars. @@ -110,15 +126,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string): Promise; create( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + name: string, + enabled?: boolean, + specification?: string, + replicas?: number, + syncMode?: string, + ): Promise; + create( + paramsOrFirst: + | { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + } + | string, + ...rest: [string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; + let params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -126,58 +176,53 @@ export class TablesDB { enabled: rest[1] as boolean, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string + syncMode: rest[4] as string, }; } - + const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; const specification = params.specification; const replicas = params.replicas; const syncMode = params.syncMode; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/tablesdb'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof databaseId !== 'undefined') { - payload['databaseId'] = databaseId; + apiPayload['databaseId'] = databaseId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof specification !== 'undefined') { - payload['specification'] = specification; + apiPayload['specification'] = specification; } if (typeof replicas !== 'undefined') { - payload['replicas'] = replicas; + apiPayload['replicas'] = replicas; } if (typeof syncMode !== 'undefined') { - payload['syncMode'] = syncMode; + apiPayload['syncMode'] = syncMode; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -187,22 +232,16 @@ export class TablesDB { * @returns {Promise} */ listSpecifications(): Promise { - const apiPath = '/tablesdb/specifications'; - const payload: Payload = {}; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -212,7 +251,9 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - listTransactions(params?: { queries?: string[] }): Promise; + listTransactions(params?: { + queries?: string[]; + }): Promise; /** * List transactions across all databases. * @@ -223,39 +264,37 @@ export class TablesDB { */ listTransactions(queries?: string[]): Promise; listTransactions( - paramsOrFirst?: { queries?: string[] } | string[] + paramsOrFirst?: { queries?: string[] } | string[], ): Promise { let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { queries?: string[] }; } else { params = { - queries: paramsOrFirst as string[] + queries: paramsOrFirst as string[], }; } - - const queries = params.queries; - + const queries = params.queries; const apiPath = '/tablesdb/transactions'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -276,40 +315,38 @@ export class TablesDB { */ createTransaction(ttl?: number): Promise; createTransaction( - paramsOrFirst?: { ttl?: number } | number + paramsOrFirst?: { ttl?: number } | number, ): Promise { let params: { ttl?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { params = (paramsOrFirst || {}) as { ttl?: number }; } else { params = { - ttl: paramsOrFirst as number + ttl: paramsOrFirst as number, }; } - - const ttl = params.ttl; - + const ttl = params.ttl; const apiPath = '/tablesdb/transactions'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof ttl !== 'undefined') { - payload['ttl'] = ttl; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -319,7 +356,9 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - getTransaction(params: { transactionId: string }): Promise; + getTransaction(params: { + transactionId: string; + }): Promise; /** * Get a transaction by its unique ID. * @@ -330,39 +369,41 @@ export class TablesDB { */ getTransaction(transactionId: string): Promise; getTransaction( - paramsOrFirst: { transactionId: string } | string + paramsOrFirst: { transactionId: string } | string, ): Promise { let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { transactionId: string }; } else { params = { - transactionId: paramsOrFirst as string + transactionId: paramsOrFirst as string, }; } - - const transactionId = params.transactionId; + const transactionId = params.transactionId; if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/tablesdb/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -374,7 +415,11 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateTransaction(params: { transactionId: string, commit?: boolean, rollback?: boolean }): Promise; + updateTransaction(params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }): Promise; /** * Update a transaction, to either commit or roll back its operations. * @@ -385,53 +430,69 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTransaction(transactionId: string, commit?: boolean, rollback?: boolean): Promise; updateTransaction( - paramsOrFirst: { transactionId: string, commit?: boolean, rollback?: boolean } | string, - ...rest: [(boolean)?, (boolean)?] + transactionId: string, + commit?: boolean, + rollback?: boolean, + ): Promise; + updateTransaction( + paramsOrFirst: + | { transactionId: string; commit?: boolean; rollback?: boolean } + | string, + ...rest: [boolean?, boolean?] ): Promise { - let params: { transactionId: string, commit?: boolean, rollback?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, commit?: boolean, rollback?: boolean }; + let params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; } else { params = { transactionId: paramsOrFirst as string, commit: rest[0] as boolean, - rollback: rest[1] as boolean + rollback: rest[1] as boolean, }; } - + const transactionId = params.transactionId; const commit = params.commit; const rollback = params.rollback; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/tablesdb/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + const apiPayload: Payload = {}; if (typeof commit !== 'undefined') { - payload['commit'] = commit; + apiPayload['commit'] = commit; } if (typeof rollback !== 'undefined') { - payload['rollback'] = rollback; + apiPayload['rollback'] = rollback; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -452,39 +513,41 @@ export class TablesDB { */ deleteTransaction(transactionId: string): Promise<{}>; deleteTransaction( - paramsOrFirst: { transactionId: string } | string + paramsOrFirst: { transactionId: string } | string, ): Promise<{}> { let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { transactionId: string }; } else { params = { - transactionId: paramsOrFirst as string + transactionId: paramsOrFirst as string, }; } - - const transactionId = params.transactionId; + const transactionId = params.transactionId; if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); } - - const apiPath = '/tablesdb/transactions/{transactionId}'.replace('{transactionId}', encodeURIComponent(String(transactionId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -495,7 +558,10 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createOperations(params: { transactionId: string, operations?: object[] }): Promise; + createOperations(params: { + transactionId: string; + operations?: object[]; + }): Promise; /** * Create multiple operations in a single transaction. * @@ -505,48 +571,58 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createOperations(transactionId: string, operations?: object[]): Promise; createOperations( - paramsOrFirst: { transactionId: string, operations?: object[] } | string, - ...rest: [(object[])?] + transactionId: string, + operations?: object[], + ): Promise; + createOperations( + paramsOrFirst: + { transactionId: string; operations?: object[] } | string, + ...rest: [object[]?] ): Promise { - let params: { transactionId: string, operations?: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, operations?: object[] }; + let params: { transactionId: string; operations?: object[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + transactionId: string; + operations?: object[]; + }; } else { params = { transactionId: paramsOrFirst as string, - operations: rest[0] as object[] + operations: rest[0] as object[], }; } - + const transactionId = params.transactionId; const operations = params.operations; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); - } - - const apiPath = '/tablesdb/transactions/{transactionId}/operations'.replace('{transactionId}', encodeURIComponent(String(transactionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); + } + const apiPath = + '/tablesdb/transactions/{transactionId}/operations'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + const apiPayload: Payload = {}; if (typeof operations !== 'undefined') { - payload['operations'] = operations; + apiPayload['operations'] = operations; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -567,39 +643,41 @@ export class TablesDB { */ get(databaseId: string): Promise; get( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - - const databaseId = params.databaseId; + const databaseId = params.databaseId; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -614,7 +692,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }): Promise; + update(params: { + databaseId: string; + name?: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }): Promise; /** * Update a database by its unique ID. * @@ -628,15 +713,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string): Promise; update( - paramsOrFirst: { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + name?: string, + enabled?: boolean, + specification?: string, + replicas?: number, + syncMode?: string, + ): Promise; + update( + paramsOrFirst: + | { + databaseId: string; + name?: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + } + | string, + ...rest: [string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name?: string, enabled?: boolean, specification?: string, replicas?: number, syncMode?: string }; + let params: { + databaseId: string; + name?: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name?: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -644,52 +763,50 @@ export class TablesDB { enabled: rest[1] as boolean, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string + syncMode: rest[4] as string, }; } - + const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; const specification = params.specification; const replicas = params.replicas; const syncMode = params.syncMode; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof specification !== 'undefined') { - payload['specification'] = specification; + apiPayload['specification'] = specification; } if (typeof replicas !== 'undefined') { - payload['replicas'] = replicas; + apiPayload['replicas'] = replicas; } if (typeof syncMode !== 'undefined') { - payload['syncMode'] = syncMode; + apiPayload['syncMode'] = syncMode; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -709,53 +826,56 @@ export class TablesDB { * @deprecated Use the object parameter style method for a better developer experience. */ delete(databaseId: string): Promise<{}>; - delete( - paramsOrFirst: { databaseId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { databaseId: string } | string): Promise<{}> { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - - const databaseId = params.databaseId; + const databaseId = params.databaseId; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. * * @param {string} params.databaseId - Database ID. * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise} */ - createFailover(params: { databaseId: string, targetReplicaId?: string }): Promise; + createFailover(params: { + databaseId: string; + targetReplicaId?: string; + }): Promise; /** - * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. * * @param {string} databaseId - Database ID. * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. @@ -763,48 +883,57 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFailover(databaseId: string, targetReplicaId?: string): Promise; createFailover( - paramsOrFirst: { databaseId: string, targetReplicaId?: string } | string, - ...rest: [(string)?] + databaseId: string, + targetReplicaId?: string, + ): Promise; + createFailover( + paramsOrFirst: + { databaseId: string; targetReplicaId?: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, targetReplicaId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetReplicaId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string + targetReplicaId: rest[0] as string, }; } - + const databaseId = params.databaseId; const targetReplicaId = params.targetReplicaId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/failovers'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/failovers'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; if (typeof targetReplicaId !== 'undefined') { - payload['targetReplicaId'] = targetReplicaId; + apiPayload['targetReplicaId'] = targetReplicaId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -814,7 +943,9 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - listMigrations(params: { databaseId: string }): Promise; + listMigrations(params: { + databaseId: string; + }): Promise; /** * List the dedicated migrations for a TablesDB database. A database has at most one in-flight migration. * @@ -825,39 +956,41 @@ export class TablesDB { */ listMigrations(databaseId: string): Promise; listMigrations( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - - const databaseId = params.databaseId; + const databaseId = params.databaseId; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/migrations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/migrations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -869,7 +1002,11 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createMigration(params: { databaseId: string, specification: string, autoCutover?: boolean }): Promise; + createMigration(params: { + databaseId: string; + specification: string; + autoCutover?: boolean; + }): Promise; /** * Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live, with a brief read-only window during cutover. * @@ -880,56 +1017,78 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMigration(databaseId: string, specification: string, autoCutover?: boolean): Promise; createMigration( - paramsOrFirst: { databaseId: string, specification: string, autoCutover?: boolean } | string, - ...rest: [(string)?, (boolean)?] + databaseId: string, + specification: string, + autoCutover?: boolean, + ): Promise; + createMigration( + paramsOrFirst: + | { + databaseId: string; + specification: string; + autoCutover?: boolean; + } + | string, + ...rest: [string?, boolean?] ): Promise { - let params: { databaseId: string, specification: string, autoCutover?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, specification: string, autoCutover?: boolean }; + let params: { + databaseId: string; + specification: string; + autoCutover?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + specification: string; + autoCutover?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, specification: rest[0] as string, - autoCutover: rest[1] as boolean + autoCutover: rest[1] as boolean, }; } - + const databaseId = params.databaseId; const specification = params.specification; const autoCutover = params.autoCutover; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof specification === 'undefined') { - throw new AppwriteException('Missing required parameter: "specification"'); + throw new AppwriteException( + 'Missing required parameter: "specification"', + ); } - - const apiPath = '/tablesdb/{databaseId}/migrations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/migrations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; if (typeof specification !== 'undefined') { - payload['specification'] = specification; + apiPayload['specification'] = specification; } if (typeof autoCutover !== 'undefined') { - payload['autoCutover'] = autoCutover; + apiPayload['autoCutover'] = autoCutover; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -940,7 +1099,10 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - getMigration(params: { databaseId: string, migrationId: string }): Promise; + getMigration(params: { + databaseId: string; + migrationId: string; + }): Promise; /** * Get a single dedicated migration for a TablesDB database by its ID. * @@ -950,47 +1112,56 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getMigration(databaseId: string, migrationId: string): Promise; getMigration( - paramsOrFirst: { databaseId: string, migrationId: string } | string, - ...rest: [(string)?] + databaseId: string, + migrationId: string, + ): Promise; + getMigration( + paramsOrFirst: { databaseId: string; migrationId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, migrationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, migrationId: string }; + let params: { databaseId: string; migrationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + migrationId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - migrationId: rest[0] as string + migrationId: rest[0] as string, }; } - + const databaseId = params.databaseId; const migrationId = params.migrationId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof migrationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "migrationId"'); - } - - const apiPath = '/tablesdb/{databaseId}/migrations/{migrationId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{migrationId}', encodeURIComponent(String(migrationId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "migrationId"', + ); + } + const apiPath = '/tablesdb/{databaseId}/migrations/{migrationId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{migrationId}', encodeURIComponent(String(migrationId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1001,7 +1172,10 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteMigration(params: { databaseId: string, migrationId: string }): Promise<{}>; + deleteMigration(params: { + databaseId: string; + migrationId: string; + }): Promise<{}>; /** * Abort an in-flight TablesDB dedicated migration. Only allowed before cutover; once the migration has cut over it cannot be aborted. * @@ -1013,46 +1187,52 @@ export class TablesDB { */ deleteMigration(databaseId: string, migrationId: string): Promise<{}>; deleteMigration( - paramsOrFirst: { databaseId: string, migrationId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; migrationId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { databaseId: string, migrationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, migrationId: string }; + let params: { databaseId: string; migrationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + migrationId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - migrationId: rest[0] as string + migrationId: rest[0] as string, }; } - + const databaseId = params.databaseId; const migrationId = params.migrationId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof migrationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "migrationId"'); - } - - const apiPath = '/tablesdb/{databaseId}/migrations/{migrationId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{migrationId}', encodeURIComponent(String(migrationId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "migrationId"', + ); + } + const apiPath = '/tablesdb/{databaseId}/migrations/{migrationId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{migrationId}', encodeURIComponent(String(migrationId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1063,7 +1243,10 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - cutoverMigration(params: { databaseId: string, migrationId: string }): Promise; + cutoverMigration(params: { + databaseId: string; + migrationId: string; + }): Promise; /** * Cut a verified TablesDB migration over to its dedicated compute. Only applies to a migration created with `autoCutover` disabled, which waits at `ready_to_cutover` until this is called. The routing flip happens shortly after this returns, with a brief read-only window. One call buys one attempt: a cutover that fails a check returns the migration to `verifying` and parks it again, so call this once more to retry. * @@ -1073,48 +1256,61 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - cutoverMigration(databaseId: string, migrationId: string): Promise; cutoverMigration( - paramsOrFirst: { databaseId: string, migrationId: string } | string, - ...rest: [(string)?] + databaseId: string, + migrationId: string, + ): Promise; + cutoverMigration( + paramsOrFirst: { databaseId: string; migrationId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, migrationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, migrationId: string }; + let params: { databaseId: string; migrationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + migrationId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - migrationId: rest[0] as string + migrationId: rest[0] as string, }; } - + const databaseId = params.databaseId; const migrationId = params.migrationId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof migrationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "migrationId"'); - } - - const apiPath = '/tablesdb/{databaseId}/migrations/{migrationId}/cutover'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{migrationId}', encodeURIComponent(String(migrationId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "migrationId"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/migrations/{migrationId}/cutover' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{migrationId}', + encodeURIComponent(String(migrationId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1127,7 +1323,12 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - listOperations(params: { databaseId: string, status?: string, limit?: number, offset?: number }): Promise; + listOperations(params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }): Promise; /** * List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. * @@ -1139,57 +1340,81 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listOperations(databaseId: string, status?: string, limit?: number, offset?: number): Promise; listOperations( - paramsOrFirst: { databaseId: string, status?: string, limit?: number, offset?: number } | string, - ...rest: [(string)?, (number)?, (number)?] + databaseId: string, + status?: string, + limit?: number, + offset?: number, + ): Promise; + listOperations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, number?, number?] ): Promise { - let params: { databaseId: string, status?: string, limit?: number, offset?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, status?: string, limit?: number, offset?: number }; + let params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; } else { params = { databaseId: paramsOrFirst as string, status: rest[0] as string, limit: rest[1] as number, - offset: rest[2] as number + offset: rest[2] as number, }; } - + const databaseId = params.databaseId; const status = params.status; const limit = params.limit; const offset = params.offset; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/operations'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/operations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; if (typeof status !== 'undefined') { - payload['status'] = status; + apiPayload['status'] = status; } if (typeof limit !== 'undefined') { - payload['limit'] = limit; + apiPayload['limit'] = limit; } if (typeof offset !== 'undefined') { - payload['offset'] = offset; + apiPayload['offset'] = offset; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1199,7 +1424,9 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - getReplicas(params: { databaseId: string }): Promise; + getReplicas(params: { + databaseId: string; + }): Promise; /** * Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. * @@ -1210,39 +1437,41 @@ export class TablesDB { */ getReplicas(databaseId: string): Promise; getReplicas( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - - const databaseId = params.databaseId; + const databaseId = params.databaseId; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/replicas'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/replicas'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1263,39 +1492,41 @@ export class TablesDB { */ getStatus(databaseId: string): Promise; getStatus( - paramsOrFirst: { databaseId: string } | string + paramsOrFirst: { databaseId: string } | string, ): Promise { let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { databaseId: string }; } else { params = { - databaseId: paramsOrFirst as string + databaseId: paramsOrFirst as string, }; } - - const databaseId = params.databaseId; + const databaseId = params.databaseId; if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/status'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/status'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1308,7 +1539,12 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - listTables(params: { databaseId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listTables(params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get a list of all tables that belong to the provided databaseId. You can use the search parameter to filter your results. * @@ -1320,57 +1556,81 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTables(databaseId: string, queries?: string[], search?: string, total?: boolean): Promise; listTables( - paramsOrFirst: { databaseId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + databaseId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listTables( + paramsOrFirst: + | { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { databaseId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } - - const apiPath = '/tablesdb/{databaseId}/tables'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/tables'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1387,7 +1647,16 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createTable(params: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, columns?: object[], indexes?: object[] }): Promise; + createTable(params: { + databaseId: string; + tableId: string; + name: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + columns?: object[]; + indexes?: object[]; + }): Promise; /** * Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * @@ -1403,15 +1672,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTable(databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, columns?: object[], indexes?: object[]): Promise; createTable( - paramsOrFirst: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, columns?: object[], indexes?: object[] } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (object[])?, (object[])?] + databaseId: string, + tableId: string, + name: string, + permissions?: string[], + rowSecurity?: boolean, + enabled?: boolean, + columns?: object[], + indexes?: object[], + ): Promise; + createTable( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + name: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + columns?: object[]; + indexes?: object[]; + } + | string, + ...rest: [ + string?, + string?, + string[]?, + boolean?, + boolean?, + object[]?, + object[]?, + ] ): Promise { - let params: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, columns?: object[], indexes?: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, columns?: object[], indexes?: object[] }; + let params: { + databaseId: string; + tableId: string; + name: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + columns?: object[]; + indexes?: object[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + name: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + columns?: object[]; + indexes?: object[]; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1421,10 +1740,10 @@ export class TablesDB { rowSecurity: rest[3] as boolean, enabled: rest[4] as boolean, columns: rest[5] as object[], - indexes: rest[6] as object[] + indexes: rest[6] as object[], }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const name = params.name; @@ -1433,54 +1752,54 @@ export class TablesDB { const enabled = params.enabled; const columns = params.columns; const indexes = params.indexes; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/tablesdb/{databaseId}/tables'.replace('{databaseId}', encodeURIComponent(String(databaseId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/tables'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; if (typeof tableId !== 'undefined') { - payload['tableId'] = tableId; + apiPayload['tableId'] = tableId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof rowSecurity !== 'undefined') { - payload['rowSecurity'] = rowSecurity; + apiPayload['rowSecurity'] = rowSecurity; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof columns !== 'undefined') { - payload['columns'] = columns; + apiPayload['columns'] = columns; } if (typeof indexes !== 'undefined') { - payload['indexes'] = indexes; + apiPayload['indexes'] = indexes; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1491,7 +1810,10 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - getTable(params: { databaseId: string, tableId: string }): Promise; + getTable(params: { + databaseId: string; + tableId: string; + }): Promise; /** * Get a table by its unique ID. This endpoint response returns a JSON object with the table metadata. * @@ -1503,45 +1825,51 @@ export class TablesDB { */ getTable(databaseId: string, tableId: string): Promise; getTable( - paramsOrFirst: { databaseId: string, tableId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; tableId: string } | string, + ...rest: [string?] ): Promise { - let params: { databaseId: string, tableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string }; + let params: { databaseId: string; tableId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - tableId: rest[0] as string + tableId: rest[0] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1557,7 +1885,15 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateTable(params: { databaseId: string, tableId: string, name?: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, purge?: boolean }): Promise; + updateTable(params: { + databaseId: string; + tableId: string; + name?: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }): Promise; /** * Update a table by its unique ID. * @@ -1572,15 +1908,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTable(databaseId: string, tableId: string, name?: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, purge?: boolean): Promise; updateTable( - paramsOrFirst: { databaseId: string, tableId: string, name?: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, purge?: boolean } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (boolean)?] + databaseId: string, + tableId: string, + name?: string, + permissions?: string[], + rowSecurity?: boolean, + enabled?: boolean, + purge?: boolean, + ): Promise; + updateTable( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + name?: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + } + | string, + ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, name?: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, purge?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, name?: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, purge?: boolean }; + let params: { + databaseId: string; + tableId: string; + name?: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + name?: string; + permissions?: string[]; + rowSecurity?: boolean; + enabled?: boolean; + purge?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1589,10 +1963,10 @@ export class TablesDB { permissions: rest[2] as string[], rowSecurity: rest[3] as boolean, enabled: rest[4] as boolean, - purge: rest[5] as boolean + purge: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const name = params.name; @@ -1600,45 +1974,44 @@ export class TablesDB { const rowSecurity = params.rowSecurity; const enabled = params.enabled; const purge = params.purge; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof rowSecurity !== 'undefined') { - payload['rowSecurity'] = rowSecurity; + apiPayload['rowSecurity'] = rowSecurity; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof purge !== 'undefined') { - payload['purge'] = purge; + apiPayload['purge'] = purge; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1649,7 +2022,7 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteTable(params: { databaseId: string, tableId: string }): Promise<{}>; + deleteTable(params: { databaseId: string; tableId: string }): Promise<{}>; /** * Delete a table by its unique ID. Only users with write permissions have access to delete this resource. * @@ -1661,45 +2034,51 @@ export class TablesDB { */ deleteTable(databaseId: string, tableId: string): Promise<{}>; deleteTable( - paramsOrFirst: { databaseId: string, tableId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { databaseId: string; tableId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { databaseId: string, tableId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string }; + let params: { databaseId: string; tableId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + }; } else { params = { databaseId: paramsOrFirst as string, - tableId: rest[0] as string + tableId: rest[0] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1712,7 +2091,12 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - listColumns(params: { databaseId: string, tableId: string, queries?: string[], total?: boolean }): Promise; + listColumns(params: { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List columns in the table. * @@ -1724,62 +2108,87 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listColumns(databaseId: string, tableId: string, queries?: string[], total?: boolean): Promise; listColumns( - paramsOrFirst: { databaseId: string, tableId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?] + databaseId: string, + tableId: string, + queries?: string[], + total?: boolean, + ): Promise; + listColumns( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + } + | string, + ...rest: [string?, string[]?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[], total?: boolean }; + let params: { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, queries: rest[1] as string[], - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const queries = params.queries; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Create a bigint column. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -1792,10 +2201,19 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createBigIntColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise; + createBigIntColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }): Promise; /** * Create a bigint column. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -1809,15 +2227,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBigIntColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise; createBigIntColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + min?: number | bigint, + max?: number | bigint, + xdefault?: number | bigint, + array?: boolean, + ): Promise; + createBigIntColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + boolean?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1827,10 +2295,10 @@ export class TablesDB { min: rest[3] as number | bigint, max: rest[4] as number | bigint, xdefault: rest[5] as number | bigint, - array: rest[6] as boolean + array: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -1839,59 +2307,60 @@ export class TablesDB { const max = params.max; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof min !== 'undefined') { - payload['min'] = min; + apiPayload['min'] = min; } if (typeof max !== 'undefined') { - payload['max'] = max; + apiPayload['max'] = max; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update a bigint column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -1904,10 +2373,19 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateBigIntColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise; + updateBigIntColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }): Promise; /** * Update a bigint column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -1921,15 +2399,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBigIntColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise; updateBigIntColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: number | bigint, + min?: number | bigint, + max?: number | bigint, + newKey?: string, + ): Promise; + updateBigIntColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + string?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -1939,10 +2467,10 @@ export class TablesDB { xdefault: rest[3] as number | bigint, min: rest[4] as number | bigint, max: rest[5] as number | bigint, - newKey: rest[6] as string + newKey: rest[6] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -1951,59 +2479,64 @@ export class TablesDB { const min = params.min; const max = params.max; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof min !== 'undefined') { - payload['min'] = min; + apiPayload['min'] = min; } if (typeof max !== 'undefined') { - payload['max'] = max; + apiPayload['max'] = max; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create a boolean column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -2014,10 +2547,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createBooleanColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }): Promise; + createBooleanColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + }): Promise; /** * Create a boolean column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -2029,15 +2569,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBooleanColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise; createBooleanColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: boolean, + array?: boolean, + ): Promise; + createBooleanColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2045,58 +2619,60 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as boolean, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2111,7 +2687,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateBooleanColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }): Promise; + updateBooleanColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + }): Promise; /** * Update a boolean column. Changing the `default` value will not update already existing rows. * @@ -2125,15 +2708,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateBooleanColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise; updateBooleanColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: boolean, + newKey?: string, + ): Promise; + updateBooleanColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, boolean?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: boolean; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2141,58 +2758,63 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as boolean, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2207,7 +2829,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createDatetimeColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createDatetimeColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create a date time column according to the ISO 8601 standard. * @@ -2221,15 +2850,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDatetimeColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createDatetimeColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createDatetimeColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2237,58 +2900,60 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2303,7 +2968,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateDatetimeColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateDatetimeColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a date time column. Changing the `default` value will not update already existing rows. * @@ -2317,15 +2989,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDatetimeColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateDatetimeColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateDatetimeColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2333,63 +3039,68 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create an email column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -2400,10 +3111,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createEmailColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createEmailColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create an email column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -2415,15 +3133,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEmailColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createEmailColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createEmailColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2431,63 +3183,64 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/email'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/email' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update an email column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -2498,10 +3251,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateEmailColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateEmailColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an email column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -2513,15 +3273,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmailColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateEmailColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateEmailColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2529,58 +3323,63 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2596,7 +3395,15 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createEnumColumn(params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }): Promise; + createEnumColumn(params: { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create an enumeration column. The `elements` param acts as a white-list of accepted values for this column. * @@ -2611,15 +3418,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createEnumColumn(databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise; createEnumColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + elements: string[], + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createEnumColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, string[]?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2628,10 +3473,10 @@ export class TablesDB { elements: rest[2] as string[], required: rest[3] as boolean, xdefault: rest[4] as string, - array: rest[5] as boolean + array: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -2639,59 +3484,62 @@ export class TablesDB { const required = params.required; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof elements === 'undefined') { - throw new AppwriteException('Missing required parameter: "elements"'); + throw new AppwriteException( + 'Missing required parameter: "elements"', + ); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof elements !== 'undefined') { - payload['elements'] = elements; + apiPayload['elements'] = elements; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update an enum column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -2703,10 +3551,18 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateEnumColumn(params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }): Promise; + updateEnumColumn(params: { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an enum column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -2719,15 +3575,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEnumColumn(databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise; updateEnumColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + elements: string[], + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateEnumColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, string[]?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + elements: string[]; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2736,10 +3630,10 @@ export class TablesDB { elements: rest[2] as string[], required: rest[3] as boolean, xdefault: rest[4] as string, - newKey: rest[5] as string + newKey: rest[5] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -2747,59 +3641,66 @@ export class TablesDB { const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof elements === 'undefined') { - throw new AppwriteException('Missing required parameter: "elements"'); + throw new AppwriteException( + 'Missing required parameter: "elements"', + ); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof elements !== 'undefined') { - payload['elements'] = elements; + apiPayload['elements'] = elements; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create a float column. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -2812,10 +3713,19 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createFloatColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }): Promise; + createFloatColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + }): Promise; /** * Create a float column. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -2829,15 +3739,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFloatColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise; createFloatColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + min?: number, + max?: number, + xdefault?: number, + array?: boolean, + ): Promise; + createFloatColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + number?, + number?, + number?, + boolean?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number; + max?: number; + xdefault?: number; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2847,10 +3807,10 @@ export class TablesDB { min: rest[3] as number, max: rest[4] as number, xdefault: rest[5] as number, - array: rest[6] as boolean + array: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -2859,59 +3819,60 @@ export class TablesDB { const max = params.max; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/float'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/float' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof min !== 'undefined') { - payload['min'] = min; + apiPayload['min'] = min; } if (typeof max !== 'undefined') { - payload['max'] = max; + apiPayload['max'] = max; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update a float column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -2924,10 +3885,19 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateFloatColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }): Promise; + updateFloatColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + }): Promise; /** * Update a float column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -2941,15 +3911,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateFloatColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise; updateFloatColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: number, + min?: number, + max?: number, + newKey?: string, + ): Promise; + updateFloatColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + number?, + number?, + number?, + string?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number; + min?: number; + max?: number; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -2959,10 +3979,10 @@ export class TablesDB { xdefault: rest[3] as number, min: rest[4] as number, max: rest[5] as number, - newKey: rest[6] as string + newKey: rest[6] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -2971,59 +3991,64 @@ export class TablesDB { const min = params.min; const max = params.max; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof min !== 'undefined') { - payload['min'] = min; + apiPayload['min'] = min; } if (typeof max !== 'undefined') { - payload['max'] = max; + apiPayload['max'] = max; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create an integer column. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -3036,10 +4061,19 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createIntegerColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise; + createIntegerColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }): Promise; /** * Create an integer column. Optionally, minimum and maximum values can be provided. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -3053,15 +4087,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise; createIntegerColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + min?: number | bigint, + max?: number | bigint, + xdefault?: number | bigint, + array?: boolean, + ): Promise; + createIntegerColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + boolean?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + min?: number | bigint; + max?: number | bigint; + xdefault?: number | bigint; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3071,10 +4155,10 @@ export class TablesDB { min: rest[3] as number | bigint, max: rest[4] as number | bigint, xdefault: rest[5] as number | bigint, - array: rest[6] as boolean + array: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -3083,59 +4167,61 @@ export class TablesDB { const max = params.max; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/integer' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof min !== 'undefined') { - payload['min'] = min; + apiPayload['min'] = min; } if (typeof max !== 'undefined') { - payload['max'] = max; + apiPayload['max'] = max; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update an integer column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -3148,10 +4234,19 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateIntegerColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise; + updateIntegerColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }): Promise; /** * Update an integer column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -3165,15 +4260,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise; updateIntegerColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: number | bigint, + min?: number | bigint, + max?: number | bigint, + newKey?: string, + ): Promise; + updateIntegerColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + } + | string, + ...rest: [ + string?, + string?, + boolean?, + (number | bigint)?, + (number | bigint)?, + (number | bigint)?, + string?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number | bigint; + min?: number | bigint; + max?: number | bigint; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3183,10 +4328,10 @@ export class TablesDB { xdefault: rest[3] as number | bigint, min: rest[4] as number | bigint, max: rest[5] as number | bigint, - newKey: rest[6] as string + newKey: rest[6] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -3195,59 +4340,64 @@ export class TablesDB { const min = params.min; const max = params.max; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof min !== 'undefined') { - payload['min'] = min; + apiPayload['min'] = min; } if (typeof max !== 'undefined') { - payload['max'] = max; + apiPayload['max'] = max; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create IP address column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -3258,10 +4408,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createIpColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createIpColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create IP address column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -3273,15 +4430,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIpColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createIpColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createIpColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3289,63 +4480,64 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update an ip column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -3356,10 +4548,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateIpColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateIpColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an ip column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -3371,15 +4570,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateIpColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateIpColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateIpColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3387,58 +4620,63 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3452,7 +4690,13 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createLineColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] }): Promise; + createLineColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }): Promise; /** * Create a geometric line column. * @@ -3465,69 +4709,100 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createLineColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][]): Promise; createLineColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: any[][], + ): Promise; + createLineColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][] + xdefault: rest[3] as any[][], }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/line'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/line' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3542,7 +4817,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateLineColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }): Promise; + updateLineColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }): Promise; /** * Update a line column. Changing the `default` value will not update already existing rows. * @@ -3556,15 +4838,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateLineColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string): Promise; updateLineColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: any[][], + newKey?: string, + ): Promise; + updateLineColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3572,60 +4888,63 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as any[][], - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create a longtext column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3637,10 +4956,18 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createLongtextColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createLongtextColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a longtext column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3653,15 +4980,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createLongtextColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createLongtextColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createLongtextColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3670,10 +5035,10 @@ export class TablesDB { required: rest[2] as boolean, xdefault: rest[3] as string, array: rest[4] as boolean, - encrypt: rest[5] as boolean + encrypt: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -3681,56 +5046,58 @@ export class TablesDB { const xdefault = params.xdefault; const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } if (typeof encrypt !== 'undefined') { - payload['encrypt'] = encrypt; + apiPayload['encrypt'] = encrypt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update a longtext column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3741,10 +5108,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateLongtextColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateLongtextColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a longtext column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3756,15 +5130,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateLongtextColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateLongtextColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateLongtextColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3772,63 +5180,68 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create a mediumtext column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3840,10 +5253,18 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createMediumtextColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createMediumtextColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a mediumtext column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3856,15 +5277,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMediumtextColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createMediumtextColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createMediumtextColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3873,10 +5332,10 @@ export class TablesDB { required: rest[2] as boolean, xdefault: rest[3] as string, array: rest[4] as boolean, - encrypt: rest[5] as boolean + encrypt: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -3884,56 +5343,58 @@ export class TablesDB { const xdefault = params.xdefault; const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } if (typeof encrypt !== 'undefined') { - payload['encrypt'] = encrypt; + apiPayload['encrypt'] = encrypt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update a mediumtext column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3944,10 +5405,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateMediumtextColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateMediumtextColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a mediumtext column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3959,15 +5427,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMediumtextColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateMediumtextColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateMediumtextColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -3975,58 +5477,63 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4040,7 +5547,13 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createPointColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[] }): Promise; + createPointColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + }): Promise; /** * Create a geometric point column. * @@ -4053,69 +5566,100 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPointColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[]): Promise; createPointColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[] } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number[])?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: number[], + ): Promise; + createPointColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + } + | string, + ...rest: [string?, string?, boolean?, number[]?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[] }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number[] + xdefault: rest[3] as number[], }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/point'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/point' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4130,7 +5674,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updatePointColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[], newKey?: string }): Promise; + updatePointColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + }): Promise; /** * Update a point column. Changing the `default` value will not update already existing rows. * @@ -4144,15 +5695,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePointColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[], newKey?: string): Promise; updatePointColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[], newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number[])?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: number[], + newKey?: string, + ): Promise; + updatePointColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, number[]?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[], newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number[], newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: number[]; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4160,55 +5745,58 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as number[], - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4222,7 +5810,13 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createPolygonColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] }): Promise; + createPolygonColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }): Promise; /** * Create a geometric polygon column. * @@ -4235,69 +5829,101 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createPolygonColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][]): Promise; createPolygonColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: any[][], + ): Promise; + createPolygonColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][] }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][] + xdefault: rest[3] as any[][], }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4312,7 +5938,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updatePolygonColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }): Promise; + updatePolygonColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }): Promise; /** * Update a polygon column. Changing the `default` value will not update already existing rows. * @@ -4326,15 +5959,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePolygonColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string): Promise; updatePolygonColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (any[][])?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: any[][], + newKey?: string, + ): Promise; + updatePolygonColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, any[][]?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[][], newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: any[][]; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4342,60 +6009,63 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as any[][], - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -4408,10 +6078,19 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createRelationshipColumn(params: { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }): Promise; + createRelationshipColumn(params: { + databaseId: string; + tableId: string; + relatedTableId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + }): Promise; /** * Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -4425,15 +6104,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRelationshipColumn(databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise; createRelationshipColumn( - paramsOrFirst: { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate } | string, - ...rest: [(string)?, (string)?, (RelationshipType)?, (boolean)?, (string)?, (string)?, (RelationMutate)?] + databaseId: string, + tableId: string, + relatedTableId: string, + type: RelationshipType, + twoWay?: boolean, + key?: string, + twoWayKey?: string, + onDelete?: RelationMutate, + ): Promise; + createRelationshipColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + relatedTableId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + } + | string, + ...rest: [ + string?, + string?, + RelationshipType?, + boolean?, + string?, + string?, + RelationMutate?, + ] ): Promise { - let params: { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; + let params: { + databaseId: string; + tableId: string; + relatedTableId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + relatedTableId: string; + type: RelationshipType; + twoWay?: boolean; + key?: string; + twoWayKey?: string; + onDelete?: RelationMutate; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4443,10 +6172,10 @@ export class TablesDB { twoWay: rest[3] as boolean, key: rest[4] as string, twoWayKey: rest[5] as string, - onDelete: rest[6] as RelationMutate + onDelete: rest[6] as RelationMutate, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const relatedTableId = params.relatedTableId; @@ -4455,59 +6184,61 @@ export class TablesDB { const key = params.key; const twoWayKey = params.twoWayKey; const onDelete = params.onDelete; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof relatedTableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "relatedTableId"'); + throw new AppwriteException( + 'Missing required parameter: "relatedTableId"', + ); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof relatedTableId !== 'undefined') { - payload['relatedTableId'] = relatedTableId; + apiPayload['relatedTableId'] = relatedTableId; } if (typeof type !== 'undefined') { - payload['type'] = type; + apiPayload['type'] = type; } if (typeof twoWay !== 'undefined') { - payload['twoWay'] = twoWay; + apiPayload['twoWay'] = twoWay; } if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof twoWayKey !== 'undefined') { - payload['twoWayKey'] = twoWayKey; + apiPayload['twoWayKey'] = twoWayKey; } if (typeof onDelete !== 'undefined') { - payload['onDelete'] = onDelete; + apiPayload['onDelete'] = onDelete; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Create a string column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4521,10 +6252,19 @@ export class TablesDB { * @returns {Promise} * @deprecated This API has been deprecated since 1.9.0. Please use `TablesDB.createTextColumn` instead. */ - createStringColumn(params: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createStringColumn(params: { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a string column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4538,15 +6278,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createStringColumn(databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createStringColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + size: number, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createStringColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + boolean?, + string?, + boolean?, + boolean?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4556,10 +6346,10 @@ export class TablesDB { required: rest[3] as boolean, xdefault: rest[4] as string, array: rest[5] as boolean, - encrypt: rest[6] as boolean + encrypt: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -4568,12 +6358,15 @@ export class TablesDB { const xdefault = params.xdefault; const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -4582,48 +6375,46 @@ export class TablesDB { throw new AppwriteException('Missing required parameter: "size"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/string'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/string' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof size !== 'undefined') { - payload['size'] = size; + apiPayload['size'] = size; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } if (typeof encrypt !== 'undefined') { - payload['encrypt'] = encrypt; + apiPayload['encrypt'] = encrypt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update a string column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4636,10 +6427,18 @@ export class TablesDB { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. */ - updateStringColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }): Promise; + updateStringColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }): Promise; /** * Update a string column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4652,15 +6451,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateStringColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise; updateStringColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + size?: number, + newKey?: string, + ): Promise; + updateStringColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4669,10 +6506,10 @@ export class TablesDB { required: rest[2] as boolean, xdefault: rest[3] as string, size: rest[4] as number, - newKey: rest[5] as string + newKey: rest[5] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -4680,56 +6517,61 @@ export class TablesDB { const xdefault = params.xdefault; const size = params.size; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof size !== 'undefined') { - payload['size'] = size; + apiPayload['size'] = size; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create a text column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4741,10 +6583,18 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createTextColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createTextColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a text column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4757,15 +6607,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTextColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createTextColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createTextColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4774,10 +6662,10 @@ export class TablesDB { required: rest[2] as boolean, xdefault: rest[3] as string, array: rest[4] as boolean, - encrypt: rest[5] as boolean + encrypt: rest[5] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -4785,56 +6673,57 @@ export class TablesDB { const xdefault = params.xdefault; const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/text'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/text' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } if (typeof encrypt !== 'undefined') { - payload['encrypt'] = encrypt; + apiPayload['encrypt'] = encrypt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update a text column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4845,10 +6734,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateTextColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateTextColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update a text column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -4860,15 +6756,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTextColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateTextColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateTextColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4876,63 +6806,68 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create a URL column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -4943,10 +6878,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createUrlColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise; + createUrlColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }): Promise; /** * Create a URL column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -4958,15 +6900,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createUrlColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise; createUrlColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + array?: boolean, + ): Promise; + createUrlColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + } + | string, + ...rest: [string?, string?, boolean?, string?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + array?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -4974,63 +6950,64 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - array: rest[4] as boolean + array: rest[4] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const array = params.array; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/url'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/url' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update an url column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -5041,10 +7018,17 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateUrlColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise; + updateUrlColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }): Promise; /** * Update an url column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -5056,15 +7040,49 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateUrlColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise; updateUrlColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + newKey?: string, + ): Promise; + updateUrlColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5072,63 +7090,68 @@ export class TablesDB { key: rest[1] as string, required: rest[2] as boolean, xdefault: rest[3] as string, - newKey: rest[4] as string + newKey: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const required = params.required; const xdefault = params.xdefault; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Create a varchar column. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -5141,10 +7164,19 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createVarcharColumn(params: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise; + createVarcharColumn(params: { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }): Promise; /** * Create a varchar column. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -5158,15 +7190,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVarcharColumn(databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise; createVarcharColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + databaseId: string, + tableId: string, + key: string, + size: number, + required: boolean, + xdefault?: string, + array?: boolean, + encrypt?: boolean, + ): Promise; + createVarcharColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + } + | string, + ...rest: [ + string?, + string?, + number?, + boolean?, + string?, + boolean?, + boolean?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + let params: { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + size: number; + required: boolean; + xdefault?: string; + array?: boolean; + encrypt?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5176,10 +7258,10 @@ export class TablesDB { required: rest[3] as boolean, xdefault: rest[4] as string, array: rest[5] as boolean, - encrypt: rest[6] as boolean + encrypt: rest[6] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -5188,12 +7270,15 @@ export class TablesDB { const xdefault = params.xdefault; const array = params.array; const encrypt = params.encrypt; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -5202,48 +7287,47 @@ export class TablesDB { throw new AppwriteException('Missing required parameter: "size"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "required"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof size !== 'undefined') { - payload['size'] = size; + apiPayload['size'] = size; } if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof array !== 'undefined') { - payload['array'] = array; + apiPayload['array'] = array; } if (typeof encrypt !== 'undefined') { - payload['encrypt'] = encrypt; + apiPayload['encrypt'] = encrypt; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Update a varchar column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -5255,10 +7339,18 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateVarcharColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }): Promise; + updateVarcharColumn(params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }): Promise; /** * Update a varchar column. Changing the `default` value will not update already existing rows. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -5271,15 +7363,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateVarcharColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise; updateVarcharColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (string)?, (number)?, (string)?] + databaseId: string, + tableId: string, + key: string, + required: boolean, + xdefault?: string, + size?: number, + newKey?: string, + ): Promise; + updateVarcharColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + } + | string, + ...rest: [string?, string?, boolean?, string?, number?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + required: boolean; + xdefault?: string; + size?: number; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5288,10 +7418,10 @@ export class TablesDB { required: rest[2] as boolean, xdefault: rest[3] as string, size: rest[4] as number, - newKey: rest[5] as string + newKey: rest[5] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -5299,51 +7429,56 @@ export class TablesDB { const xdefault = params.xdefault; const size = params.size; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); + throw new AppwriteException( + 'Missing required parameter: "required"', + ); } if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "xdefault"', + ); + } + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof required !== 'undefined') { - payload['required'] = required; + apiPayload['required'] = required; } if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; + apiPayload['default'] = xdefault; } if (typeof size !== 'undefined') { - payload['size'] = size; + apiPayload['size'] = size; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5355,7 +7490,22 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - getColumn(params: { databaseId: string, tableId: string, key: string }): Promise; + getColumn(params: { + databaseId: string; + tableId: string; + key: string; + }): Promise< + | Models.ColumnBoolean + | Models.ColumnInteger + | Models.ColumnFloat + | Models.ColumnEmail + | Models.ColumnEnum + | Models.ColumnUrl + | Models.ColumnIp + | Models.ColumnDatetime + | Models.ColumnRelationship + | Models.ColumnString + >; /** * Get column by ID. * @@ -5366,52 +7516,87 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getColumn(databaseId: string, tableId: string, key: string): Promise; getColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { databaseId: string, tableId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; + databaseId: string, + tableId: string, + key: string, + ): Promise< + | Models.ColumnBoolean + | Models.ColumnInteger + | Models.ColumnFloat + | Models.ColumnEmail + | Models.ColumnEnum + | Models.ColumnUrl + | Models.ColumnIp + | Models.ColumnDatetime + | Models.ColumnRelationship + | Models.ColumnString + >; + getColumn( + paramsOrFirst: + { databaseId: string; tableId: string; key: string } | string, + ...rest: [string?, string?] + ): Promise< + | Models.ColumnBoolean + | Models.ColumnInteger + | Models.ColumnFloat + | Models.ColumnEmail + | Models.ColumnEnum + | Models.ColumnUrl + | Models.ColumnIp + | Models.ColumnDatetime + | Models.ColumnRelationship + | Models.ColumnString + > { + let params: { databaseId: string; tableId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -5423,7 +7608,11 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteColumn(params: { databaseId: string, tableId: string, key: string }): Promise<{}>; + deleteColumn(params: { + databaseId: string; + tableId: string; + key: string; + }): Promise<{}>; /** * Deletes a column. * @@ -5436,55 +7625,64 @@ export class TablesDB { */ deleteColumn(databaseId: string, tableId: string, key: string): Promise<{}>; deleteColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, - ...rest: [(string)?, (string)?] + paramsOrFirst: + { databaseId: string; tableId: string; key: string } | string, + ...rest: [string?, string?] ): Promise<{}> { - let params: { databaseId: string, tableId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; + let params: { databaseId: string; tableId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -5494,10 +7692,16 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateRelationshipColumn(params: { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string }): Promise; + updateRelationshipColumn(params: { + databaseId: string; + tableId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + }): Promise; /** * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -5508,63 +7712,94 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRelationshipColumn(databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise; updateRelationshipColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string } | string, - ...rest: [(string)?, (string)?, (RelationMutate)?, (string)?] + databaseId: string, + tableId: string, + key: string, + onDelete?: RelationMutate, + newKey?: string, + ): Promise; + updateRelationshipColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + } + | string, + ...rest: [string?, string?, RelationMutate?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string }; + let params: { + databaseId: string; + tableId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + onDelete?: RelationMutate; + newKey?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, key: rest[1] as string, onDelete: rest[2] as RelationMutate, - newKey: rest[3] as string + newKey: rest[3] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; const onDelete = params.onDelete; const newKey = params.newKey; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + const apiPayload: Payload = {}; if (typeof onDelete !== 'undefined') { - payload['onDelete'] = onDelete; + apiPayload['onDelete'] = onDelete; } if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; + apiPayload['newKey'] = newKey; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5577,7 +7812,12 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - listIndexes(params: { databaseId: string, tableId: string, queries?: string[], total?: boolean }): Promise; + listIndexes(params: { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List indexes on the table. * @@ -5589,57 +7829,82 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listIndexes(databaseId: string, tableId: string, queries?: string[], total?: boolean): Promise; listIndexes( - paramsOrFirst: { databaseId: string, tableId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?] + databaseId: string, + tableId: string, + queries?: string[], + total?: boolean, + ): Promise; + listIndexes( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + } + | string, + ...rest: [string?, string[]?, boolean?] ): Promise { - let params: { databaseId: string, tableId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[], total?: boolean }; + let params: { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, queries: rest[1] as string[], - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const queries = params.queries; const total = params.total; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -5656,7 +7921,15 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createIndex(params: { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }): Promise; + createIndex(params: { + databaseId: string; + tableId: string; + key: string; + type: TablesDBIndexType; + columns: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }): Promise; /** * Creates an index on the columns listed. Your index should include all the columns you will query in a single request. * Type can be `key`, `fulltext`, or `unique`. @@ -5672,15 +7945,60 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIndex(databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[]): Promise; createIndex( - paramsOrFirst: { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] } | string, - ...rest: [(string)?, (string)?, (TablesDBIndexType)?, (string[])?, (OrderBy[])?, (number[])?] + databaseId: string, + tableId: string, + key: string, + type: TablesDBIndexType, + columns: string[], + orders?: OrderBy[], + lengths?: number[], + ): Promise; + createIndex( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + key: string; + type: TablesDBIndexType; + columns: string[]; + orders?: OrderBy[]; + lengths?: number[]; + } + | string, + ...rest: [ + string?, + string?, + TablesDBIndexType?, + string[]?, + OrderBy[]?, + number[]?, + ] ): Promise { - let params: { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }; + let params: { + databaseId: string; + tableId: string; + key: string; + type: TablesDBIndexType; + columns: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + type: TablesDBIndexType; + columns: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5689,10 +8007,10 @@ export class TablesDB { type: rest[2] as TablesDBIndexType, columns: rest[3] as string[], orders: rest[4] as OrderBy[], - lengths: rest[5] as number[] + lengths: rest[5] as number[], }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; @@ -5700,12 +8018,15 @@ export class TablesDB { const columns = params.columns; const orders = params.orders; const lengths = params.lengths; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); @@ -5714,40 +8035,38 @@ export class TablesDB { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof columns === 'undefined') { - throw new AppwriteException('Missing required parameter: "columns"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "columns"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof key !== 'undefined') { - payload['key'] = key; + apiPayload['key'] = key; } if (typeof type !== 'undefined') { - payload['type'] = type; + apiPayload['type'] = type; } if (typeof columns !== 'undefined') { - payload['columns'] = columns; + apiPayload['columns'] = columns; } if (typeof orders !== 'undefined') { - payload['orders'] = orders; + apiPayload['orders'] = orders; } if (typeof lengths !== 'undefined') { - payload['lengths'] = lengths; + apiPayload['lengths'] = lengths; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5759,7 +8078,11 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - getIndex(params: { databaseId: string, tableId: string, key: string }): Promise; + getIndex(params: { + databaseId: string; + tableId: string; + key: string; + }): Promise; /** * Get index by ID. * @@ -5770,52 +8093,65 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getIndex(databaseId: string, tableId: string, key: string): Promise; getIndex( - paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, - ...rest: [(string)?, (string)?] + databaseId: string, + tableId: string, + key: string, + ): Promise; + getIndex( + paramsOrFirst: + { databaseId: string; tableId: string; key: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { databaseId: string, tableId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; + let params: { databaseId: string; tableId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -5827,7 +8163,11 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteIndex(params: { databaseId: string, tableId: string, key: string }): Promise<{}>; + deleteIndex(params: { + databaseId: string; + tableId: string; + key: string; + }): Promise<{}>; /** * Delete an index. * @@ -5840,50 +8180,59 @@ export class TablesDB { */ deleteIndex(databaseId: string, tableId: string, key: string): Promise<{}>; deleteIndex( - paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, - ...rest: [(string)?, (string)?] + paramsOrFirst: + { databaseId: string; tableId: string; key: string } | string, + ...rest: [string?, string?] ): Promise<{}> { - let params: { databaseId: string, tableId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; + let params: { databaseId: string; tableId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + key: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, - key: rest[1] as string + key: rest[1] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const key = params.key; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{key}', encodeURIComponent(String(key))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{key}', encodeURIComponent(String(key))); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -5898,7 +8247,14 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise>} */ - listRows(params: { databaseId: string, tableId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }): Promise>; + listRows(params: { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }): Promise>; /** * Get a list of all the user's rows in a given table. You can use the query params to filter your results. * @@ -5912,15 +8268,49 @@ export class TablesDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - listRows(databaseId: string, tableId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number): Promise>; listRows( - paramsOrFirst: { databaseId: string, tableId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number } | string, - ...rest: [(string)?, (string[])?, (string)?, (boolean)?, (number)?] + databaseId: string, + tableId: string, + queries?: string[], + transactionId?: string, + total?: boolean, + ttl?: number, + ): Promise>; + listRows( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + } + | string, + ...rest: [string?, string[]?, string?, boolean?, number?] ): Promise> { - let params: { databaseId: string, tableId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; + let params: { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -5928,51 +8318,50 @@ export class TablesDB { queries: rest[1] as string[], transactionId: rest[2] as string, total: rest[3] as boolean, - ttl: rest[4] as number + ttl: rest[4] as number, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const queries = params.queries; const transactionId = params.transactionId; const total = params.total; const ttl = params.ttl; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } if (typeof total !== 'undefined') { - payload['total'] = total; + apiPayload['total'] = total; } if (typeof ttl !== 'undefined') { - payload['ttl'] = ttl; + apiPayload['ttl'] = ttl; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -5987,7 +8376,16 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - createRow(params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }): Promise; + createRow(params: { + databaseId: string; + tableId: string; + rowId: string; + data: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Omit; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * @@ -6001,38 +8399,93 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRow(databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string): Promise; createRow( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial & Record : Partial & Omit)?, (string[])?, (string)?] + databaseId: string, + tableId: string, + rowId: string, + data: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Omit, + permissions?: string[], + transactionId?: string, + ): Promise; + createRow( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rowId: string; + data: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Omit; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Row extends Models.DefaultRow + ? Partial & Record + : Partial & Omit)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rowId: string; + data: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Omit; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rowId: string; + data: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Omit; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rowId: rest[1] as string, - data: rest[2] as Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, + data: rest[2] as Row extends Models.DefaultRow + ? Partial & Record + : Partial & Omit, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rowId = params.rowId; const data = params.data; const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof rowId === 'undefined') { throw new AppwriteException('Missing required parameter: "rowId"'); @@ -6040,35 +8493,31 @@ export class TablesDB { if (typeof data === 'undefined') { throw new AppwriteException('Missing required parameter: "data"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof rowId !== 'undefined') { - payload['rowId'] = rowId; + apiPayload['rowId'] = rowId; } if (typeof data !== 'undefined') { - payload['data'] = data; + apiPayload['data'] = data; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -6081,7 +8530,12 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise>} */ - createRows(params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }): Promise>; + createRows(params: { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + }): Promise>; /** * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * @@ -6093,66 +8547,91 @@ export class TablesDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createRows(databaseId: string, tableId: string, rows: object[], transactionId?: string): Promise>; createRows( - paramsOrFirst: { databaseId: string, tableId: string, rows: object[], transactionId?: string } | string, - ...rest: [(string)?, (object[])?, (string)?] + databaseId: string, + tableId: string, + rows: object[], + transactionId?: string, + ): Promise>; + createRows( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + } + | string, + ...rest: [string?, object[]?, string?] ): Promise> { - let params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rows: object[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rows: rest[1] as object[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rows = params.rows; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof rows === 'undefined') { throw new AppwriteException('Missing required parameter: "rows"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof rows !== 'undefined') { - payload['rows'] = rows; + apiPayload['rows'] = rows; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** * Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. - * + * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -6161,10 +8640,15 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise>} */ - upsertRows(params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }): Promise>; + upsertRows(params: { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + }): Promise>; /** * Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. - * + * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -6174,61 +8658,86 @@ export class TablesDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - upsertRows(databaseId: string, tableId: string, rows: object[], transactionId?: string): Promise>; upsertRows( - paramsOrFirst: { databaseId: string, tableId: string, rows: object[], transactionId?: string } | string, - ...rest: [(string)?, (object[])?, (string)?] + databaseId: string, + tableId: string, + rows: object[], + transactionId?: string, + ): Promise>; + upsertRows( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + } + | string, + ...rest: [string?, object[]?, string?] ): Promise> { - let params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rows: object[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rows: object[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rows: rest[1] as object[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rows = params.rows; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof rows === 'undefined') { throw new AppwriteException('Missing required parameter: "rows"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof rows !== 'undefined') { - payload['rows'] = rows; + apiPayload['rows'] = rows; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -6242,7 +8751,13 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise>} */ - updateRows(params: { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string }): Promise>; + updateRows(params: { + databaseId: string; + tableId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }): Promise>; /** * Update all rows that match your queries, if no queries are submitted then all rows are updated. You can pass only specific fields to be updated. * @@ -6255,63 +8770,92 @@ export class TablesDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRows(databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string): Promise>; updateRows( - paramsOrFirst: { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (object)?, (string[])?, (string)?] + databaseId: string, + tableId: string, + data?: object, + queries?: string[], + transactionId?: string, + ): Promise>; + updateRows( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + data?: object; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, object?, string[]?, string?] ): Promise> { - let params: { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, data: rest[1] as object, queries: rest[2] as string[], - transactionId: rest[3] as string + transactionId: rest[3] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const data = params.data; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof data !== 'undefined') { - payload['data'] = data; + apiPayload['data'] = data; } if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6324,7 +8868,12 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise>} */ - deleteRows(params: { databaseId: string, tableId: string, queries?: string[], transactionId?: string }): Promise>; + deleteRows(params: { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + }): Promise>; /** * Bulk delete rows using queries, if no queries are passed then all rows are deleted. * @@ -6336,58 +8885,83 @@ export class TablesDB { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteRows(databaseId: string, tableId: string, queries?: string[], transactionId?: string): Promise>; deleteRows( - paramsOrFirst: { databaseId: string, tableId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string[])?, (string)?] + databaseId: string, + tableId: string, + queries?: string[], + transactionId?: string, + ): Promise>; + deleteRows( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string[]?, string?] ): Promise> { - let params: { databaseId: string, tableId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, queries: rest[1] as string[], - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); + } + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -6401,7 +8975,13 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - getRow(params: { databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string }): Promise; + getRow(params: { + databaseId: string; + tableId: string; + rowId: string; + queries?: string[]; + transactionId?: string; + }): Promise; /** * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. * @@ -6414,62 +8994,92 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getRow(databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string): Promise; getRow( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (string)?] + databaseId: string, + tableId: string, + rowId: string, + queries?: string[], + transactionId?: string, + ): Promise; + getRow( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rowId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string[]?, string?] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rowId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rowId: string; + queries?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rowId: rest[1] as string, queries: rest[2] as string[], - transactionId: rest[3] as string + transactionId: rest[3] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rowId = params.rowId; const queries = params.queries; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof rowId === 'undefined') { throw new AppwriteException('Missing required parameter: "rowId"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{rowId}', encodeURIComponent(String(rowId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{rowId}', encodeURIComponent(String(rowId))); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'X-Appwrite-Project': this.client.config.project, - 'accept': 'application/json', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -6484,7 +9094,16 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - upsertRow(params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + upsertRow(params: { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * @@ -6498,68 +9117,123 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - upsertRow(databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; upsertRow( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + databaseId: string, + tableId: string, + rowId: string, + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + upsertRow( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rowId: rest[1] as string, - data: rest[2] as Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, + data: rest[2] as Row extends Models.DefaultRow + ? Partial & Record + : Partial & + Partial>, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rowId = params.rowId; const data = params.data; const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof rowId === 'undefined') { throw new AppwriteException('Missing required parameter: "rowId"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{rowId}', encodeURIComponent(String(rowId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{rowId}', encodeURIComponent(String(rowId))); + const apiPayload: Payload = {}; if (typeof data !== 'undefined') { - payload['data'] = data; + apiPayload['data'] = data; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -6574,7 +9248,16 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - updateRow(params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + updateRow(params: { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; /** * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. * @@ -6588,68 +9271,123 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRow(databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; updateRow( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + databaseId: string, + tableId: string, + rowId: string, + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + updateRow( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>)?, + string[]?, + string?, + ] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rowId: string; + data?: Row extends Models.DefaultRow + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rowId: rest[1] as string, - data: rest[2] as Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, + data: rest[2] as Row extends Models.DefaultRow + ? Partial & Record + : Partial & + Partial>, permissions: rest[3] as string[], - transactionId: rest[4] as string + transactionId: rest[4] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rowId = params.rowId; const data = params.data; const permissions = params.permissions; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof rowId === 'undefined') { throw new AppwriteException('Missing required parameter: "rowId"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{rowId}', encodeURIComponent(String(rowId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{rowId}', encodeURIComponent(String(rowId))); + const apiPayload: Payload = {}; if (typeof data !== 'undefined') { - payload['data'] = data; + apiPayload['data'] = data; } if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + apiPayload['permissions'] = permissions; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6662,7 +9400,12 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteRow(params: { databaseId: string, tableId: string, rowId: string, transactionId?: string }): Promise<{}>; + deleteRow(params: { + databaseId: string; + tableId: string; + rowId: string; + transactionId?: string; + }): Promise<{}>; /** * Delete a row by its unique ID. * @@ -6674,57 +9417,83 @@ export class TablesDB { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteRow(databaseId: string, tableId: string, rowId: string, transactionId?: string): Promise<{}>; deleteRow( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + databaseId: string, + tableId: string, + rowId: string, + transactionId?: string, + ): Promise<{}>; + deleteRow( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rowId: string; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?] ): Promise<{}> { - let params: { databaseId: string, tableId: string, rowId: string, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rowId: string; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rowId: string; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rowId: rest[1] as string, - transactionId: rest[2] as string + transactionId: rest[2] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rowId = params.rowId; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof rowId === 'undefined') { throw new AppwriteException('Missing required parameter: "rowId"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{rowId}', encodeURIComponent(String(rowId))); - const payload: Payload = {}; + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{rowId}', encodeURIComponent(String(rowId))); + const apiPayload: Payload = {}; if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -6740,7 +9509,15 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - decrementRowColumn(params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string }): Promise; + decrementRowColumn(params: { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + min?: number; + transactionId?: string; + }): Promise; /** * Decrement a specific column of a row by a given value. * @@ -6755,15 +9532,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - decrementRowColumn(databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string): Promise; decrementRowColumn( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] + databaseId: string, + tableId: string, + rowId: string, + column: string, + value?: number, + min?: number, + transactionId?: string, + ): Promise; + decrementRowColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + min?: number; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?, number?, number?, string?] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + min?: number; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + min?: number; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -6772,10 +9587,10 @@ export class TablesDB { column: rest[2] as string, value: rest[3] as number, min: rest[4] as number, - transactionId: rest[5] as string + transactionId: rest[5] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rowId = params.rowId; @@ -6783,12 +9598,15 @@ export class TablesDB { const value = params.value; const min = params.min; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof rowId === 'undefined') { throw new AppwriteException('Missing required parameter: "rowId"'); @@ -6796,32 +9614,31 @@ export class TablesDB { if (typeof column === 'undefined') { throw new AppwriteException('Missing required parameter: "column"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{rowId}', encodeURIComponent(String(rowId))).replace('{column}', encodeURIComponent(String(column))); - const payload: Payload = {}; + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{rowId}', encodeURIComponent(String(rowId))) + .replace('{column}', encodeURIComponent(String(column))); + const apiPayload: Payload = {}; if (typeof value !== 'undefined') { - payload['value'] = value; + apiPayload['value'] = value; } if (typeof min !== 'undefined') { - payload['min'] = min; + apiPayload['min'] = min; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6837,7 +9654,15 @@ export class TablesDB { * @throws {AppwriteException} * @returns {Promise} */ - incrementRowColumn(params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string }): Promise; + incrementRowColumn(params: { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + max?: number; + transactionId?: string; + }): Promise; /** * Increment a specific column of a row by a given value. * @@ -6852,15 +9677,53 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - incrementRowColumn(databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string): Promise; incrementRowColumn( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] + databaseId: string, + tableId: string, + rowId: string, + column: string, + value?: number, + max?: number, + transactionId?: string, + ): Promise; + incrementRowColumn( + paramsOrFirst: + | { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + max?: number; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?, number?, number?, string?] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string }; + let params: { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + max?: number; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + tableId: string; + rowId: string; + column: string; + value?: number; + max?: number; + transactionId?: string; + }; } else { params = { databaseId: paramsOrFirst as string, @@ -6869,10 +9732,10 @@ export class TablesDB { column: rest[2] as string, value: rest[3] as number, max: rest[4] as number, - transactionId: rest[5] as string + transactionId: rest[5] as string, }; } - + const databaseId = params.databaseId; const tableId = params.tableId; const rowId = params.rowId; @@ -6880,12 +9743,15 @@ export class TablesDB { const value = params.value; const max = params.max; const transactionId = params.transactionId; - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); } if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); + throw new AppwriteException( + 'Missing required parameter: "tableId"', + ); } if (typeof rowId === 'undefined') { throw new AppwriteException('Missing required parameter: "rowId"'); @@ -6893,31 +9759,30 @@ export class TablesDB { if (typeof column === 'undefined') { throw new AppwriteException('Missing required parameter: "column"'); } - - const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replace('{databaseId}', encodeURIComponent(String(databaseId))).replace('{tableId}', encodeURIComponent(String(tableId))).replace('{rowId}', encodeURIComponent(String(rowId))).replace('{column}', encodeURIComponent(String(column))); - const payload: Payload = {}; + const apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace('{tableId}', encodeURIComponent(String(tableId))) + .replace('{rowId}', encodeURIComponent(String(rowId))) + .replace('{column}', encodeURIComponent(String(column))); + const apiPayload: Payload = {}; if (typeof value !== 'undefined') { - payload['value'] = value; + apiPayload['value'] = value; } if (typeof max !== 'undefined') { - payload['max'] = max; + apiPayload['max'] = max; } if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + apiPayload['transactionId'] = transactionId; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } } diff --git a/src/services/teams.ts b/src/services/teams.ts index a194b2a2..f2ea276c 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -1,8 +1,6 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - - export class Teams { client: Client; @@ -19,7 +17,13 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise>} */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise>; + list< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise>; /** * Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. * @@ -30,52 +34,59 @@ export class Teams { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string, total?: boolean): Promise>; list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise>; + list( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise> { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - - const apiPath = '/teams'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -87,7 +98,13 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise>} */ - create(params: { teamId: string, name: string, roles?: string[] }): Promise>; + create< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + teamId: string; + name: string; + roles?: string[]; + }): Promise>; /** * Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team. * @@ -98,59 +115,65 @@ export class Teams { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - create(teamId: string, name: string, roles?: string[]): Promise>; create( - paramsOrFirst: { teamId: string, name: string, roles?: string[] } | string, - ...rest: [(string)?, (string[])?] + teamId: string, + name: string, + roles?: string[], + ): Promise>; + create( + paramsOrFirst: + { teamId: string; name: string; roles?: string[] } | string, + ...rest: [string?, string[]?] ): Promise> { - let params: { teamId: string, name: string, roles?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, name: string, roles?: string[] }; + let params: { teamId: string; name: string; roles?: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + name: string; + roles?: string[]; + }; } else { params = { teamId: paramsOrFirst as string, name: rest[0] as string, - roles: rest[1] as string[] + roles: rest[1] as string[], }; } - + const teamId = params.teamId; const name = params.name; const roles = params.roles; - if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - const apiPath = '/teams'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof teamId !== 'undefined') { - payload['teamId'] = teamId; + apiPayload['teamId'] = teamId; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof roles !== 'undefined') { - payload['roles'] = roles; + apiPayload['roles'] = roles; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -160,7 +183,9 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise>} */ - get(params: { teamId: string }): Promise>; + get< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { teamId: string }): Promise>; /** * Get a team by its ID. All team members have read access for this resource. * @@ -169,41 +194,43 @@ export class Teams { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - get(teamId: string): Promise>; get( - paramsOrFirst: { teamId: string } | string + teamId: string, + ): Promise>; + get( + paramsOrFirst: { teamId: string } | string, ): Promise> { let params: { teamId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { teamId: string }; } else { params = { - teamId: paramsOrFirst as string + teamId: paramsOrFirst as string, }; } - - const teamId = params.teamId; + const teamId = params.teamId; if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } - - const apiPath = '/teams/{teamId}'.replace('{teamId}', encodeURIComponent(String(teamId))); - const payload: Payload = {}; + const apiPath = '/teams/{teamId}'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -214,7 +241,12 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise>} */ - updateName(params: { teamId: string, name: string }): Promise>; + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + teamId: string; + name: string; + }): Promise>; /** * Update the team's name by its unique ID. * @@ -224,51 +256,55 @@ export class Teams { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateName(teamId: string, name: string): Promise>; - updateName( - paramsOrFirst: { teamId: string, name: string } | string, - ...rest: [(string)?] + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(teamId: string, name: string): Promise>; + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { teamId: string; name: string } | string, + ...rest: [string?] ): Promise> { - let params: { teamId: string, name: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, name: string }; + let params: { teamId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { teamId: string; name: string }; } else { params = { teamId: paramsOrFirst as string, - name: rest[0] as string + name: rest[0] as string, }; } - + const teamId = params.teamId; const name = params.name; - if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/teams/{teamId}'.replace('{teamId}', encodeURIComponent(String(teamId))); - const payload: Payload = {}; + const apiPath = '/teams/{teamId}'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -288,40 +324,38 @@ export class Teams { * @deprecated Use the object parameter style method for a better developer experience. */ delete(teamId: string): Promise<{}>; - delete( - paramsOrFirst: { teamId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { teamId: string } | string): Promise<{}> { let params: { teamId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { teamId: string }; } else { params = { - teamId: paramsOrFirst as string + teamId: paramsOrFirst as string, }; } - - const teamId = params.teamId; + const teamId = params.teamId; if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } - - const apiPath = '/teams/{teamId}'.replace('{teamId}', encodeURIComponent(String(teamId))); - const payload: Payload = {}; + const apiPath = '/teams/{teamId}'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -333,7 +367,11 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - listInstallations(params: { teamId: string, queries?: string[], total?: boolean }): Promise; + listInstallations(params: { + teamId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List app installations on a team. Any team member can read installations. * @@ -344,52 +382,61 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listInstallations(teamId: string, queries?: string[], total?: boolean): Promise; listInstallations( - paramsOrFirst: { teamId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + teamId: string, + queries?: string[], + total?: boolean, + ): Promise; + listInstallations( + paramsOrFirst: + { teamId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { teamId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, queries?: string[], total?: boolean }; + let params: { teamId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { teamId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const teamId = params.teamId; const queries = params.queries; const total = params.total; - if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } - - const apiPath = '/teams/{teamId}/installations'.replace('{teamId}', encodeURIComponent(String(teamId))); - const payload: Payload = {}; + const apiPath = '/teams/{teamId}/installations'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -401,7 +448,11 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - createInstallation(params: { teamId: string, appId: string, authorizationDetails?: string }): Promise; + createInstallation(params: { + teamId: string; + appId: string; + authorizationDetails?: string; + }): Promise; /** * Install an app on a team. When authenticated as a user, only team members with the owner role can install apps. Requests using an API key or in admin mode can install apps on any team. The installation is granted the scopes the app currently requests. * @@ -412,56 +463,70 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createInstallation(teamId: string, appId: string, authorizationDetails?: string): Promise; createInstallation( - paramsOrFirst: { teamId: string, appId: string, authorizationDetails?: string } | string, - ...rest: [(string)?, (string)?] + teamId: string, + appId: string, + authorizationDetails?: string, + ): Promise; + createInstallation( + paramsOrFirst: + | { teamId: string; appId: string; authorizationDetails?: string } + | string, + ...rest: [string?, string?] ): Promise { - let params: { teamId: string, appId: string, authorizationDetails?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, appId: string, authorizationDetails?: string }; + let params: { + teamId: string; + appId: string; + authorizationDetails?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + appId: string; + authorizationDetails?: string; + }; } else { params = { teamId: paramsOrFirst as string, appId: rest[0] as string, - authorizationDetails: rest[1] as string + authorizationDetails: rest[1] as string, }; } - + const teamId = params.teamId; const appId = params.appId; const authorizationDetails = params.authorizationDetails; - if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof appId === 'undefined') { throw new AppwriteException('Missing required parameter: "appId"'); } - - const apiPath = '/teams/{teamId}/installations'.replace('{teamId}', encodeURIComponent(String(teamId))); - const payload: Payload = {}; + const apiPath = '/teams/{teamId}/installations'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); + const apiPayload: Payload = {}; if (typeof appId !== 'undefined') { - payload['appId'] = appId; + apiPayload['appId'] = appId; } if (typeof authorizationDetails !== 'undefined') { - payload['authorizationDetails'] = authorizationDetails; + apiPayload['authorizationDetails'] = authorizationDetails; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -472,7 +537,10 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - getInstallation(params: { teamId: string, installationId: string }): Promise; + getInstallation(params: { + teamId: string; + installationId: string; + }): Promise; /** * Get an app installation on a team by its unique ID. Any team member can read installations. * @@ -482,47 +550,57 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getInstallation(teamId: string, installationId: string): Promise; getInstallation( - paramsOrFirst: { teamId: string, installationId: string } | string, - ...rest: [(string)?] + teamId: string, + installationId: string, + ): Promise; + getInstallation( + paramsOrFirst: { teamId: string; installationId: string } | string, + ...rest: [string?] ): Promise { - let params: { teamId: string, installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, installationId: string }; + let params: { teamId: string; installationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + installationId: string; + }; } else { params = { teamId: paramsOrFirst as string, - installationId: rest[0] as string + installationId: rest[0] as string, }; } - + const teamId = params.teamId; const installationId = params.installationId; - if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); - } - - const apiPath = '/teams/{teamId}/installations/{installationId}'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{installationId}', encodeURIComponent(String(installationId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); + } + const apiPath = '/teams/{teamId}/installations/{installationId}' + .replace('{teamId}', encodeURIComponent(String(teamId))) + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -534,7 +612,11 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - updateInstallation(params: { teamId: string, installationId: string, authorizationDetails?: string }): Promise; + updateInstallation(params: { + teamId: string; + installationId: string; + authorizationDetails?: string; + }): Promise; /** * Update an app installation on a team. Only team members with the owner role can update installations. The installation's granted scopes are refreshed to the scopes the app currently requests; previously issued installation access tokens are revoked. * @@ -545,53 +627,75 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateInstallation(teamId: string, installationId: string, authorizationDetails?: string): Promise; updateInstallation( - paramsOrFirst: { teamId: string, installationId: string, authorizationDetails?: string } | string, - ...rest: [(string)?, (string)?] + teamId: string, + installationId: string, + authorizationDetails?: string, + ): Promise; + updateInstallation( + paramsOrFirst: + | { + teamId: string; + installationId: string; + authorizationDetails?: string; + } + | string, + ...rest: [string?, string?] ): Promise { - let params: { teamId: string, installationId: string, authorizationDetails?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, installationId: string, authorizationDetails?: string }; + let params: { + teamId: string; + installationId: string; + authorizationDetails?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + installationId: string; + authorizationDetails?: string; + }; } else { params = { teamId: paramsOrFirst as string, installationId: rest[0] as string, - authorizationDetails: rest[1] as string + authorizationDetails: rest[1] as string, }; } - + const teamId = params.teamId; const installationId = params.installationId; const authorizationDetails = params.authorizationDetails; - if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); - } - - const apiPath = '/teams/{teamId}/installations/{installationId}'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{installationId}', encodeURIComponent(String(installationId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); + } + const apiPath = '/teams/{teamId}/installations/{installationId}' + .replace('{teamId}', encodeURIComponent(String(teamId))) + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); + const apiPayload: Payload = {}; if (typeof authorizationDetails !== 'undefined') { - payload['authorizationDetails'] = authorizationDetails; + apiPayload['authorizationDetails'] = authorizationDetails; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -602,7 +706,10 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteInstallation(params: { teamId: string, installationId: string }): Promise<{}>; + deleteInstallation(params: { + teamId: string; + installationId: string; + }): Promise<{}>; /** * Uninstall an app from a team by its installation ID. Only team members with the owner role can remove installations. Previously issued installation access tokens are revoked. * @@ -614,46 +721,53 @@ export class Teams { */ deleteInstallation(teamId: string, installationId: string): Promise<{}>; deleteInstallation( - paramsOrFirst: { teamId: string, installationId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { teamId: string; installationId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { teamId: string, installationId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, installationId: string }; + let params: { teamId: string; installationId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + installationId: string; + }; } else { params = { teamId: paramsOrFirst as string, - installationId: rest[0] as string + installationId: rest[0] as string, }; } - + const teamId = params.teamId; const installationId = params.installationId; - if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof installationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "installationId"'); - } - - const apiPath = '/teams/{teamId}/installations/{installationId}'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{installationId}', encodeURIComponent(String(installationId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "installationId"', + ); + } + const apiPath = '/teams/{teamId}/installations/{installationId}' + .replace('{teamId}', encodeURIComponent(String(teamId))) + .replace( + '{installationId}', + encodeURIComponent(String(installationId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -666,7 +780,12 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - listMemberships(params: { teamId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listMemberships(params: { + teamId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console. * @@ -678,68 +797,90 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listMemberships(teamId: string, queries?: string[], search?: string, total?: boolean): Promise; listMemberships( - paramsOrFirst: { teamId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + teamId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listMemberships( + paramsOrFirst: + | { + teamId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { teamId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + teamId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { teamId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const teamId = params.teamId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } - - const apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', encodeURIComponent(String(teamId))); - const payload: Payload = {}; + const apiPath = '/teams/{teamId}/memberships'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * 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. - * + * * You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters. - * - * Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) endpoint to allow the user to accept the invitation to the team. - * + * + * Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) endpoint to allow the user to accept the invitation to the team. + * * Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. - * + * * * @param {string} params.teamId - Team ID. * @param {string[]} params.roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long. @@ -751,16 +892,24 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - createMembership(params: { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }): Promise; + createMembership(params: { + teamId: string; + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: 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. - * + * * You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters. - * - * Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) endpoint to allow the user to accept the invitation to the team. - * + * + * Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) endpoint to allow the user to accept the invitation to the team. + * * Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. - * + * * * @param {string} teamId - Team ID. * @param {string[]} roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long. @@ -773,15 +922,53 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createMembership(teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string): Promise; createMembership( - paramsOrFirst: { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string } | string, - ...rest: [(string[])?, (string)?, (string)?, (string)?, (string)?, (string)?] + teamId: string, + roles: string[], + email?: string, + userId?: string, + phone?: string, + url?: string, + name?: string, + ): Promise; + createMembership( + paramsOrFirst: + | { + teamId: string; + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: string; + } + | string, + ...rest: [string[]?, string?, string?, string?, string?, string?] ): Promise { - let params: { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }; + let params: { + teamId: string; + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + roles: string[]; + email?: string; + userId?: string; + phone?: string; + url?: string; + name?: string; + }; } else { params = { teamId: paramsOrFirst as string, @@ -790,10 +977,10 @@ export class Teams { userId: rest[2] as string, phone: rest[3] as string, url: rest[4] as string, - name: rest[5] as string + name: rest[5] as string, }; } - + const teamId = params.teamId; const roles = params.roles; const email = params.email; @@ -801,48 +988,44 @@ export class Teams { const phone = params.phone; const url = params.url; const name = params.name; - if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof roles === 'undefined') { throw new AppwriteException('Missing required parameter: "roles"'); } - - const apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', encodeURIComponent(String(teamId))); - const payload: Payload = {}; + const apiPath = '/teams/{teamId}/memberships'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); + const apiPayload: Payload = {}; if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof phone !== 'undefined') { - payload['phone'] = phone; + apiPayload['phone'] = phone; } if (typeof roles !== 'undefined') { - payload['roles'] = roles; + apiPayload['roles'] = roles; } if (typeof url !== 'undefined') { - payload['url'] = url; + apiPayload['url'] = url; } if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -853,7 +1036,10 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - getMembership(params: { teamId: string, membershipId: string }): Promise; + getMembership(params: { + teamId: string; + membershipId: string; + }): Promise; /** * Get a team member by the membership unique id. All team members have read access for this resource. Hide sensitive attributes from the response by toggling membership privacy in the Console. * @@ -863,52 +1049,62 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getMembership(teamId: string, membershipId: string): Promise; getMembership( - paramsOrFirst: { teamId: string, membershipId: string } | string, - ...rest: [(string)?] + teamId: string, + membershipId: string, + ): Promise; + getMembership( + paramsOrFirst: { teamId: string; membershipId: string } | string, + ...rest: [string?] ): Promise { - let params: { teamId: string, membershipId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, membershipId: string }; + let params: { teamId: string; membershipId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + membershipId: string; + }; } else { params = { teamId: paramsOrFirst as string, - membershipId: rest[0] as string + membershipId: rest[0] as string, }; } - + const teamId = params.teamId; const membershipId = params.membershipId; - if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); - } - - const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{membershipId}', encodeURIComponent(String(membershipId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "membershipId"', + ); + } + const apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replace('{teamId}', encodeURIComponent(String(teamId))) + .replace( + '{membershipId}', + encodeURIComponent(String(membershipId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). - * + * * * @param {string} params.teamId - Team ID. * @param {string} params.membershipId - Membership ID. @@ -916,10 +1112,14 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - updateMembership(params: { teamId: string, membershipId: string, roles: string[] }): Promise; + updateMembership(params: { + teamId: string; + membershipId: string; + roles: string[]; + }): Promise; /** * Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). - * + * * * @param {string} teamId - Team ID. * @param {string} membershipId - Membership ID. @@ -928,56 +1128,69 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMembership(teamId: string, membershipId: string, roles: string[]): Promise; updateMembership( - paramsOrFirst: { teamId: string, membershipId: string, roles: string[] } | string, - ...rest: [(string)?, (string[])?] + teamId: string, + membershipId: string, + roles: string[], + ): Promise; + updateMembership( + paramsOrFirst: + { teamId: string; membershipId: string; roles: string[] } | string, + ...rest: [string?, string[]?] ): Promise { - let params: { teamId: string, membershipId: string, roles: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, membershipId: string, roles: string[] }; + let params: { teamId: string; membershipId: string; roles: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + membershipId: string; + roles: string[]; + }; } else { params = { teamId: paramsOrFirst as string, membershipId: rest[0] as string, - roles: rest[1] as string[] + roles: rest[1] as string[], }; } - + const teamId = params.teamId; const membershipId = params.membershipId; const roles = params.roles; - if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); + throw new AppwriteException( + 'Missing required parameter: "membershipId"', + ); } if (typeof roles === 'undefined') { throw new AppwriteException('Missing required parameter: "roles"'); } - - const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{membershipId}', encodeURIComponent(String(membershipId))); - const payload: Payload = {}; + const apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replace('{teamId}', encodeURIComponent(String(teamId))) + .replace( + '{membershipId}', + encodeURIComponent(String(membershipId)), + ); + const apiPayload: Payload = {}; if (typeof roles !== 'undefined') { - payload['roles'] = roles; + apiPayload['roles'] = roles; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -988,7 +1201,10 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteMembership(params: { teamId: string, membershipId: string }): Promise<{}>; + deleteMembership(params: { + teamId: string; + membershipId: string; + }): Promise<{}>; /** * This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. You can also use this endpoint to delete a user membership even if it is not accepted. * @@ -1000,52 +1216,59 @@ export class Teams { */ deleteMembership(teamId: string, membershipId: string): Promise<{}>; deleteMembership( - paramsOrFirst: { teamId: string, membershipId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { teamId: string; membershipId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { teamId: string, membershipId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, membershipId: string }; + let params: { teamId: string; membershipId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + membershipId: string; + }; } else { params = { teamId: paramsOrFirst as string, - membershipId: rest[0] as string + membershipId: rest[0] as string, }; } - + const teamId = params.teamId; const membershipId = params.membershipId; - if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); - } - - const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{membershipId}', encodeURIComponent(String(membershipId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "membershipId"', + ); + } + const apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replace('{teamId}', encodeURIComponent(String(teamId))) + .replace( + '{membershipId}', + encodeURIComponent(String(membershipId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** * Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user. - * + * * If the request is successful, a session for the user is automatically created. - * + * * * @param {string} params.teamId - Team ID. * @param {string} params.membershipId - Membership ID. @@ -1054,12 +1277,17 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - updateMembershipStatus(params: { teamId: string, membershipId: string, userId: string, secret: string }): Promise; + updateMembershipStatus(params: { + teamId: string; + membershipId: string; + userId: string; + secret: string; + }): Promise; /** * Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user. - * + * * If the request is successful, a session for the user is automatically created. - * + * * * @param {string} teamId - Team ID. * @param {string} membershipId - Membership ID. @@ -1069,34 +1297,61 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMembershipStatus(teamId: string, membershipId: string, userId: string, secret: string): Promise; updateMembershipStatus( - paramsOrFirst: { teamId: string, membershipId: string, userId: string, secret: string } | string, - ...rest: [(string)?, (string)?, (string)?] + teamId: string, + membershipId: string, + userId: string, + secret: string, + ): Promise; + updateMembershipStatus( + paramsOrFirst: + | { + teamId: string; + membershipId: string; + userId: string; + secret: string; + } + | string, + ...rest: [string?, string?, string?] ): Promise { - let params: { teamId: string, membershipId: string, userId: string, secret: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, membershipId: string, userId: string, secret: string }; + let params: { + teamId: string; + membershipId: string; + userId: string; + secret: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + teamId: string; + membershipId: string; + userId: string; + secret: string; + }; } else { params = { teamId: paramsOrFirst as string, membershipId: rest[0] as string, userId: rest[1] as string, - secret: rest[2] as string + secret: rest[2] as string, }; } - + const teamId = params.teamId; const membershipId = params.membershipId; const userId = params.userId; const secret = params.secret; - if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); + throw new AppwriteException( + 'Missing required parameter: "membershipId"', + ); } if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); @@ -1104,29 +1359,28 @@ export class Teams { if (typeof secret === 'undefined') { throw new AppwriteException('Missing required parameter: "secret"'); } - - const apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{membershipId}', encodeURIComponent(String(membershipId))); - const payload: Payload = {}; + const apiPath = '/teams/{teamId}/memberships/{membershipId}/status' + .replace('{teamId}', encodeURIComponent(String(teamId))) + .replace( + '{membershipId}', + encodeURIComponent(String(membershipId)), + ); + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1136,7 +1390,9 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - getPrefs(params: { teamId: string }): Promise; + getPrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { teamId: string }): Promise; /** * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). * @@ -1145,41 +1401,43 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getPrefs(teamId: string): Promise; - getPrefs( - paramsOrFirst: { teamId: string } | string - ): Promise { + getPrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(teamId: string): Promise; + getPrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(paramsOrFirst: { teamId: string } | string): Promise { let params: { teamId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { teamId: string }; } else { params = { - teamId: paramsOrFirst as string + teamId: paramsOrFirst as string, }; } - - const teamId = params.teamId; + const teamId = params.teamId; if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } - - const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', encodeURIComponent(String(teamId))); - const payload: Payload = {}; + const apiPath = '/teams/{teamId}/prefs'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1190,7 +1448,9 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise} */ - updatePrefs(params: { teamId: string, prefs: object }): Promise; + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { teamId: string; prefs: object }): Promise; /** * Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. * @@ -1200,50 +1460,54 @@ export class Teams { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePrefs(teamId: string, prefs: object): Promise; - updatePrefs( - paramsOrFirst: { teamId: string, prefs: object } | string, - ...rest: [(object)?] + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(teamId: string, prefs: object): Promise; + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { teamId: string; prefs: object } | string, + ...rest: [object?] ): Promise { - let params: { teamId: string, prefs: object }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { teamId: string, prefs: object }; + let params: { teamId: string; prefs: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { teamId: string; prefs: object }; } else { params = { teamId: paramsOrFirst as string, - prefs: rest[0] as object + prefs: rest[0] as object, }; } - + const teamId = params.teamId; const prefs = params.prefs; - if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof prefs === 'undefined') { throw new AppwriteException('Missing required parameter: "prefs"'); } - - const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', encodeURIComponent(String(teamId))); - const payload: Payload = {}; + const apiPath = '/teams/{teamId}/prefs'.replace( + '{teamId}', + encodeURIComponent(String(teamId)), + ); + const apiPayload: Payload = {}; if (typeof prefs !== 'undefined') { - payload['prefs'] = prefs; + apiPayload['prefs'] = prefs; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } } diff --git a/src/services/tokens.ts b/src/services/tokens.ts index f5b9cb0c..fcd24db9 100644 --- a/src/services/tokens.ts +++ b/src/services/tokens.ts @@ -1,8 +1,6 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - - export class Tokens { client: Client; @@ -20,7 +18,12 @@ export class Tokens { * @throws {AppwriteException} * @returns {Promise} */ - list(params: { bucketId: string, fileId: string, queries?: string[], total?: boolean }): Promise; + list(params: { + bucketId: string; + fileId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List all the tokens created for a specific file or bucket. You can use the query params to filter your results. * @@ -32,57 +35,80 @@ export class Tokens { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(bucketId: string, fileId: string, queries?: string[], total?: boolean): Promise; list( - paramsOrFirst: { bucketId: string, fileId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?] + bucketId: string, + fileId: string, + queries?: string[], + total?: boolean, + ): Promise; + list( + paramsOrFirst: + | { + bucketId: string; + fileId: string; + queries?: string[]; + total?: boolean; + } + | string, + ...rest: [string?, string[]?, boolean?] ): Promise { - let params: { bucketId: string, fileId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, queries?: string[], total?: boolean }; + let params: { + bucketId: string; + fileId: string; + queries?: string[]; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, queries: rest[1] as string[], - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; const queries = params.queries; const total = params.total; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/tokens/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); - const payload: Payload = {}; + const apiPath = '/tokens/buckets/{bucketId}/files/{fileId}' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -94,7 +120,11 @@ export class Tokens { * @throws {AppwriteException} * @returns {Promise} */ - createFileToken(params: { bucketId: string, fileId: string, expire?: string }): Promise; + createFileToken(params: { + bucketId: string; + fileId: string; + expire?: string; + }): Promise; /** * Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. * @@ -105,53 +135,63 @@ export class Tokens { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFileToken(bucketId: string, fileId: string, expire?: string): Promise; createFileToken( - paramsOrFirst: { bucketId: string, fileId: string, expire?: string } | string, - ...rest: [(string)?, (string)?] + bucketId: string, + fileId: string, + expire?: string, + ): Promise; + createFileToken( + paramsOrFirst: + { bucketId: string; fileId: string; expire?: string } | string, + ...rest: [string?, string?] ): Promise { - let params: { bucketId: string, fileId: string, expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, expire?: string }; + let params: { bucketId: string; fileId: string; expire?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + bucketId: string; + fileId: string; + expire?: string; + }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, - expire: rest[1] as string + expire: rest[1] as string, }; } - + const bucketId = params.bucketId; const fileId = params.fileId; const expire = params.expire; - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); + throw new AppwriteException( + 'Missing required parameter: "bucketId"', + ); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } - - const apiPath = '/tokens/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', encodeURIComponent(String(bucketId))).replace('{fileId}', encodeURIComponent(String(fileId))); - const payload: Payload = {}; + const apiPath = '/tokens/buckets/{bucketId}/files/{fileId}' + .replace('{bucketId}', encodeURIComponent(String(bucketId))) + .replace('{fileId}', encodeURIComponent(String(fileId))); + const apiPayload: Payload = {}; if (typeof expire !== 'undefined') { - payload['expire'] = expire; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -172,39 +212,41 @@ export class Tokens { */ get(tokenId: string): Promise; get( - paramsOrFirst: { tokenId: string } | string + paramsOrFirst: { tokenId: string } | string, ): Promise { let params: { tokenId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { tokenId: string }; } else { params = { - tokenId: paramsOrFirst as string + tokenId: paramsOrFirst as string, }; } - - const tokenId = params.tokenId; + const tokenId = params.tokenId; if (typeof tokenId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tokenId"'); + throw new AppwriteException( + 'Missing required parameter: "tokenId"', + ); } - - const apiPath = '/tokens/{tokenId}'.replace('{tokenId}', encodeURIComponent(String(tokenId))); - const payload: Payload = {}; + const apiPath = '/tokens/{tokenId}'.replace( + '{tokenId}', + encodeURIComponent(String(tokenId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -215,7 +257,10 @@ export class Tokens { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { tokenId: string, expire?: string }): Promise; + update(params: { + tokenId: string; + expire?: string; + }): Promise; /** * Update a token by its unique ID. Use this endpoint to update a token's expiry date. * @@ -227,46 +272,51 @@ export class Tokens { */ update(tokenId: string, expire?: string): Promise; update( - paramsOrFirst: { tokenId: string, expire?: string } | string, - ...rest: [(string)?] + paramsOrFirst: { tokenId: string; expire?: string } | string, + ...rest: [string?] ): Promise { - let params: { tokenId: string, expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { tokenId: string, expire?: string }; + let params: { tokenId: string; expire?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + tokenId: string; + expire?: string; + }; } else { params = { tokenId: paramsOrFirst as string, - expire: rest[0] as string + expire: rest[0] as string, }; } - + const tokenId = params.tokenId; const expire = params.expire; - if (typeof tokenId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tokenId"'); + throw new AppwriteException( + 'Missing required parameter: "tokenId"', + ); } - - const apiPath = '/tokens/{tokenId}'.replace('{tokenId}', encodeURIComponent(String(tokenId))); - const payload: Payload = {}; + const apiPath = '/tokens/{tokenId}'.replace( + '{tokenId}', + encodeURIComponent(String(tokenId)), + ); + const apiPayload: Payload = {}; if (typeof expire !== 'undefined') { - payload['expire'] = expire; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -286,39 +336,39 @@ export class Tokens { * @deprecated Use the object parameter style method for a better developer experience. */ delete(tokenId: string): Promise<{}>; - delete( - paramsOrFirst: { tokenId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { tokenId: string } | string): Promise<{}> { let params: { tokenId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { tokenId: string }; } else { params = { - tokenId: paramsOrFirst as string + tokenId: paramsOrFirst as string, }; } - - const tokenId = params.tokenId; + const tokenId = params.tokenId; if (typeof tokenId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tokenId"'); + throw new AppwriteException( + 'Missing required parameter: "tokenId"', + ); } - - const apiPath = '/tokens/{tokenId}'.replace('{tokenId}', encodeURIComponent(String(tokenId))); - const payload: Payload = {}; + const apiPath = '/tokens/{tokenId}'.replace( + '{tokenId}', + encodeURIComponent(String(tokenId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } } diff --git a/src/services/users.ts b/src/services/users.ts index a79375f4..be306a87 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -1,11 +1,9 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - import { PasswordHash } from '../enums/password-hash'; import { AuthenticatorType } from '../enums/authenticator-type'; import { MessagingProviderType } from '../enums/messaging-provider-type'; - export class Users { client: Client; @@ -22,7 +20,13 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise>; + list< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise>; /** * Get a list of all the project's users. You can use the query params to filter your results. * @@ -33,52 +37,59 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string, total?: boolean): Promise>; list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise>; + list( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise> { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - - const apiPath = '/users'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -92,7 +103,15 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - create(params: { userId: string, email?: string, phone?: string, password?: string, name?: string }): Promise>; + create< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email?: string; + phone?: string; + password?: string; + name?: string; + }): Promise>; /** * Create a new user. * @@ -105,66 +124,89 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - create(userId: string, email?: string, phone?: string, password?: string, name?: string): Promise>; create( - paramsOrFirst: { userId: string, email?: string, phone?: string, password?: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?] + userId: string, + email?: string, + phone?: string, + password?: string, + name?: string, + ): Promise>; + create( + paramsOrFirst: + | { + userId: string; + email?: string; + phone?: string; + password?: string; + name?: string; + } + | string, + ...rest: [string?, string?, string?, string?] ): Promise> { - let params: { userId: string, email?: string, phone?: string, password?: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email?: string, phone?: string, password?: string, name?: string }; + let params: { + userId: string; + email?: string; + phone?: string; + password?: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email?: string; + phone?: string; + password?: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, phone: rest[1] as string, password: rest[2] as string, - name: rest[3] as string + name: rest[3] as string, }; } - + const userId = params.userId; const email = params.email; const phone = params.phone; const password = params.password; const name = params.name; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - const apiPath = '/users'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof phone !== 'undefined') { - payload['phone'] = phone; + apiPayload['phone'] = phone; } if (typeof password !== 'undefined') { - payload['password'] = password; + apiPayload['password'] = password; } if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -177,7 +219,14 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - createArgon2User(params: { userId: string, email: string, password: string, name?: string }): Promise>; + createArgon2User< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + name?: string; + }): Promise>; /** * Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * @@ -189,29 +238,53 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createArgon2User(userId: string, email: string, password: string, name?: string): Promise>; - createArgon2User( - paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + createArgon2User< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + email: string, + password: string, + name?: string, + ): Promise>; + createArgon2User< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { userId: string; email: string; password: string; name?: string } + | string, + ...rest: [string?, string?, string?] ): Promise> { - let params: { userId: string, email: string, password: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + let params: { + userId: string; + email: string; + password: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, password: rest[1] as string, - name: rest[2] as string + name: rest[2] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; const name = params.name; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -219,37 +292,33 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/users/argon2'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof password !== 'undefined') { - payload['password'] = password; + apiPayload['password'] = password; } if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -262,7 +331,14 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - createBcryptUser(params: { userId: string, email: string, password: string, name?: string }): Promise>; + createBcryptUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + name?: string; + }): Promise>; /** * Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * @@ -274,29 +350,53 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createBcryptUser(userId: string, email: string, password: string, name?: string): Promise>; - createBcryptUser( - paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + createBcryptUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + email: string, + password: string, + name?: string, + ): Promise>; + createBcryptUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { userId: string; email: string; password: string; name?: string } + | string, + ...rest: [string?, string?, string?] ): Promise> { - let params: { userId: string, email: string, password: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + let params: { + userId: string; + email: string; + password: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, password: rest[1] as string, - name: rest[2] as string + name: rest[2] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; const name = params.name; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -304,37 +404,33 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/users/bcrypt'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof password !== 'undefined') { - payload['password'] = password; + apiPayload['password'] = password; } if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -346,7 +442,11 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - listIdentities(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + listIdentities(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get identities for all users. * @@ -357,52 +457,59 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listIdentities(queries?: string[], search?: string, total?: boolean): Promise; listIdentities( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listIdentities( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[1] as boolean, }; } - + const queries = params.queries; const search = params.search; const total = params.total; - - const apiPath = '/users/identities'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -423,39 +530,41 @@ export class Users { */ deleteIdentity(identityId: string): Promise<{}>; deleteIdentity( - paramsOrFirst: { identityId: string } | string + paramsOrFirst: { identityId: string } | string, ): Promise<{}> { let params: { identityId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { identityId: string }; } else { params = { - identityId: paramsOrFirst as string + identityId: paramsOrFirst as string, }; } - - const identityId = params.identityId; + const identityId = params.identityId; if (typeof identityId === 'undefined') { - throw new AppwriteException('Missing required parameter: "identityId"'); + throw new AppwriteException( + 'Missing required parameter: "identityId"', + ); } - - const apiPath = '/users/identities/{identityId}'.replace('{identityId}', encodeURIComponent(String(identityId))); - const payload: Payload = {}; + const apiPath = '/users/identities/{identityId}'.replace( + '{identityId}', + encodeURIComponent(String(identityId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -468,7 +577,14 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - createMD5User(params: { userId: string, email: string, password: string, name?: string }): Promise>; + createMD5User< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + name?: string; + }): Promise>; /** * Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * @@ -480,29 +596,53 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createMD5User(userId: string, email: string, password: string, name?: string): Promise>; - createMD5User( - paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + createMD5User< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + email: string, + password: string, + name?: string, + ): Promise>; + createMD5User< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { userId: string; email: string; password: string; name?: string } + | string, + ...rest: [string?, string?, string?] ): Promise> { - let params: { userId: string, email: string, password: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + let params: { + userId: string; + email: string; + password: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, password: rest[1] as string, - name: rest[2] as string + name: rest[2] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; const name = params.name; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -510,37 +650,33 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/users/md5'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof password !== 'undefined') { - payload['password'] = password; + apiPayload['password'] = password; } if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -553,7 +689,14 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - createPHPassUser(params: { userId: string, email: string, password: string, name?: string }): Promise>; + createPHPassUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + name?: string; + }): Promise>; /** * Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * @@ -565,29 +708,53 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createPHPassUser(userId: string, email: string, password: string, name?: string): Promise>; - createPHPassUser( - paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?] + createPHPassUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + email: string, + password: string, + name?: string, + ): Promise>; + createPHPassUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { userId: string; email: string; password: string; name?: string } + | string, + ...rest: [string?, string?, string?] ): Promise> { - let params: { userId: string, email: string, password: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + let params: { + userId: string; + email: string; + password: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, password: rest[1] as string, - name: rest[2] as string + name: rest[2] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; const name = params.name; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -595,37 +762,33 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/users/phpass'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof password !== 'undefined') { - payload['password'] = password; + apiPayload['password'] = password; } if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -643,7 +806,19 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - createScryptUser(params: { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string }): Promise>; + createScryptUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordCpu: number; + passwordMemory: number; + passwordParallel: number; + passwordLength: number; + name?: string; + }): Promise>; /** * Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * @@ -660,15 +835,74 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createScryptUser(userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string): Promise>; - createScryptUser( - paramsOrFirst: { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (number)?, (number)?, (string)?] + createScryptUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + email: string, + password: string, + passwordSalt: string, + passwordCpu: number, + passwordMemory: number, + passwordParallel: number, + passwordLength: number, + name?: string, + ): Promise>; + createScryptUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordCpu: number; + passwordMemory: number; + passwordParallel: number; + passwordLength: number; + name?: string; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + number?, + number?, + number?, + string?, + ] ): Promise> { - let params: { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string }; + let params: { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordCpu: number; + passwordMemory: number; + passwordParallel: number; + passwordLength: number; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordCpu: number; + passwordMemory: number; + passwordParallel: number; + passwordLength: number; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, @@ -679,10 +913,10 @@ export class Users { passwordMemory: rest[4] as number, passwordParallel: rest[5] as number, passwordLength: rest[6] as number, - name: rest[7] as string + name: rest[7] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; @@ -692,7 +926,6 @@ export class Users { const passwordParallel = params.passwordParallel; const passwordLength = params.passwordLength; const name = params.name; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -700,67 +933,73 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } if (typeof passwordSalt === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordSalt"'); + throw new AppwriteException( + 'Missing required parameter: "passwordSalt"', + ); } if (typeof passwordCpu === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordCpu"'); + throw new AppwriteException( + 'Missing required parameter: "passwordCpu"', + ); } if (typeof passwordMemory === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordMemory"'); + throw new AppwriteException( + 'Missing required parameter: "passwordMemory"', + ); } if (typeof passwordParallel === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordParallel"'); + throw new AppwriteException( + 'Missing required parameter: "passwordParallel"', + ); } if (typeof passwordLength === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordLength"'); + throw new AppwriteException( + 'Missing required parameter: "passwordLength"', + ); } - const apiPath = '/users/scrypt'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof password !== 'undefined') { - payload['password'] = password; + apiPayload['password'] = password; } if (typeof passwordSalt !== 'undefined') { - payload['passwordSalt'] = passwordSalt; + apiPayload['passwordSalt'] = passwordSalt; } if (typeof passwordCpu !== 'undefined') { - payload['passwordCpu'] = passwordCpu; + apiPayload['passwordCpu'] = passwordCpu; } if (typeof passwordMemory !== 'undefined') { - payload['passwordMemory'] = passwordMemory; + apiPayload['passwordMemory'] = passwordMemory; } if (typeof passwordParallel !== 'undefined') { - payload['passwordParallel'] = passwordParallel; + apiPayload['passwordParallel'] = passwordParallel; } if (typeof passwordLength !== 'undefined') { - payload['passwordLength'] = passwordLength; + apiPayload['passwordLength'] = passwordLength; } if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -776,7 +1015,17 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - createScryptModifiedUser(params: { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string }): Promise>; + createScryptModifiedUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordSaltSeparator: string; + passwordSignerKey: string; + name?: string; + }): Promise>; /** * Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * @@ -791,15 +1040,57 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createScryptModifiedUser(userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string): Promise>; - createScryptModifiedUser( - paramsOrFirst: { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + createScryptModifiedUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + email: string, + password: string, + passwordSalt: string, + passwordSaltSeparator: string, + passwordSignerKey: string, + name?: string, + ): Promise>; + createScryptModifiedUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordSaltSeparator: string; + passwordSignerKey: string; + name?: string; + } + | string, + ...rest: [string?, string?, string?, string?, string?, string?] ): Promise> { - let params: { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string }; + let params: { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordSaltSeparator: string; + passwordSignerKey: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + passwordSalt: string; + passwordSaltSeparator: string; + passwordSignerKey: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, @@ -808,10 +1099,10 @@ export class Users { passwordSalt: rest[2] as string, passwordSaltSeparator: rest[3] as string, passwordSignerKey: rest[4] as string, - name: rest[5] as string + name: rest[5] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; @@ -819,7 +1110,6 @@ export class Users { const passwordSaltSeparator = params.passwordSaltSeparator; const passwordSignerKey = params.passwordSignerKey; const name = params.name; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -827,55 +1117,57 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } if (typeof passwordSalt === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordSalt"'); + throw new AppwriteException( + 'Missing required parameter: "passwordSalt"', + ); } if (typeof passwordSaltSeparator === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordSaltSeparator"'); + throw new AppwriteException( + 'Missing required parameter: "passwordSaltSeparator"', + ); } if (typeof passwordSignerKey === 'undefined') { - throw new AppwriteException('Missing required parameter: "passwordSignerKey"'); + throw new AppwriteException( + 'Missing required parameter: "passwordSignerKey"', + ); } - const apiPath = '/users/scrypt-modified'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof password !== 'undefined') { - payload['password'] = password; + apiPayload['password'] = password; } if (typeof passwordSalt !== 'undefined') { - payload['passwordSalt'] = passwordSalt; + apiPayload['passwordSalt'] = passwordSalt; } if (typeof passwordSaltSeparator !== 'undefined') { - payload['passwordSaltSeparator'] = passwordSaltSeparator; + apiPayload['passwordSaltSeparator'] = passwordSaltSeparator; } if (typeof passwordSignerKey !== 'undefined') { - payload['passwordSignerKey'] = passwordSignerKey; + apiPayload['passwordSignerKey'] = passwordSignerKey; } if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -889,7 +1181,15 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - createSHAUser(params: { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string }): Promise>; + createSHAUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + password: string; + passwordVersion?: PasswordHash; + name?: string; + }): Promise>; /** * Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * @@ -902,31 +1202,64 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - createSHAUser(userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string): Promise>; - createSHAUser( - paramsOrFirst: { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string } | string, - ...rest: [(string)?, (string)?, (PasswordHash)?, (string)?] + createSHAUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + email: string, + password: string, + passwordVersion?: PasswordHash, + name?: string, + ): Promise>; + createSHAUser< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: + | { + userId: string; + email: string; + password: string; + passwordVersion?: PasswordHash; + name?: string; + } + | string, + ...rest: [string?, string?, PasswordHash?, string?] ): Promise> { - let params: { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string }; + let params: { + userId: string; + email: string; + password: string; + passwordVersion?: PasswordHash; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + email: string; + password: string; + passwordVersion?: PasswordHash; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, email: rest[0] as string, password: rest[1] as string, passwordVersion: rest[2] as PasswordHash, - name: rest[3] as string + name: rest[3] as string, }; } - + const userId = params.userId; const email = params.email; const password = params.password; const passwordVersion = params.passwordVersion; const name = params.name; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -934,40 +1267,36 @@ export class Users { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - const apiPath = '/users/sha'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof userId !== 'undefined') { - payload['userId'] = userId; + apiPayload['userId'] = userId; } if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } if (typeof password !== 'undefined') { - payload['password'] = password; + apiPayload['password'] = password; } if (typeof passwordVersion !== 'undefined') { - payload['passwordVersion'] = passwordVersion; + apiPayload['passwordVersion'] = passwordVersion; } if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -977,7 +1306,9 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - get(params: { userId: string }): Promise>; + get< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { userId: string }): Promise>; /** * Get a user by its unique ID. * @@ -986,41 +1317,43 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - get(userId: string): Promise>; get( - paramsOrFirst: { userId: string } | string + userId: string, + ): Promise>; + get( + paramsOrFirst: { userId: string } | string, ): Promise> { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - - const userId = params.userId; + const userId = params.userId; if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1040,40 +1373,38 @@ export class Users { * @deprecated Use the object parameter style method for a better developer experience. */ delete(userId: string): Promise<{}>; - delete( - paramsOrFirst: { userId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { userId: string } | string): Promise<{}> { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - - const userId = params.userId; + const userId = params.userId; if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1084,7 +1415,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updateEmail(params: { userId: string, email: string }): Promise>; + updateEmail< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + email: string; + }): Promise>; /** * Update the user email by its unique ID. * @@ -1094,66 +1430,75 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmail(userId: string, email: string): Promise>; - updateEmail( - paramsOrFirst: { userId: string, email: string } | string, - ...rest: [(string)?] + updateEmail< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, email: string): Promise>; + updateEmail< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; email: string } | string, + ...rest: [string?] ): Promise> { - let params: { userId: string, email: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, email: string }; + let params: { userId: string; email: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { userId: string; email: string }; } else { params = { userId: paramsOrFirst as string, - email: rest[0] as string + email: rest[0] as string, }; } - + const userId = params.userId; const email = params.email; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } - - const apiPath = '/users/{userId}/email'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/email'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof email !== 'undefined') { - payload['email'] = email; + apiPayload['email'] = email; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. - * + * * * @param {string} params.userId - User ID. * @param {boolean} params.impersonator - Whether the user can impersonate other users. When true, the user can browse project users to choose a target and can pass impersonation headers to act as that user. Internal audit logs still attribute impersonated actions to the original impersonator and store the target user details only in internal audit payload data. * @throws {AppwriteException} * @returns {Promise>} */ - updateImpersonator(params: { userId: string, impersonator: boolean }): Promise>; + updateImpersonator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + impersonator: boolean; + }): Promise>; /** * Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. - * + * * * @param {string} userId - User ID. * @param {boolean} impersonator - Whether the user can impersonate other users. When true, the user can browse project users to choose a target and can pass impersonation headers to act as that user. Internal audit logs still attribute impersonated actions to the original impersonator and store the target user details only in internal audit payload data. @@ -1161,125 +1506,147 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateImpersonator(userId: string, impersonator: boolean): Promise>; - updateImpersonator( - paramsOrFirst: { userId: string, impersonator: boolean } | string, - ...rest: [(boolean)?] + updateImpersonator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, impersonator: boolean): Promise>; + updateImpersonator< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; impersonator: boolean } | string, + ...rest: [boolean?] ): Promise> { - let params: { userId: string, impersonator: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, impersonator: boolean }; + let params: { userId: string; impersonator: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + impersonator: boolean; + }; } else { params = { userId: paramsOrFirst as string, - impersonator: rest[0] as boolean + impersonator: rest[0] as boolean, }; } - + const userId = params.userId; const impersonator = params.impersonator; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof impersonator === 'undefined') { - throw new AppwriteException('Missing required parameter: "impersonator"'); + throw new AppwriteException( + 'Missing required parameter: "impersonator"', + ); } - - const apiPath = '/users/{userId}/impersonator'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/impersonator'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof impersonator !== 'undefined') { - payload['impersonator'] = impersonator; + apiPayload['impersonator'] = impersonator; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. * * @param {string} params.userId - User ID. - * @param {string} params.sessionId - Session ID. Use the string 'recent' to use the most recent session. Defaults to the most recent session. + * @param {string} params.sessionId - Session ID. Use the string 'recent()' to use the most recent session, which is also the default. * @param {number} params.duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. * @throws {AppwriteException} * @returns {Promise} */ - createJWT(params: { userId: string, sessionId?: string, duration?: number }): Promise; + createJWT(params: { + userId: string; + sessionId?: string; + duration?: number; + }): Promise; /** * Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. * * @param {string} userId - User ID. - * @param {string} sessionId - Session ID. Use the string 'recent' to use the most recent session. Defaults to the most recent session. + * @param {string} sessionId - Session ID. Use the string 'recent()' to use the most recent session, which is also the default. * @param {number} duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createJWT(userId: string, sessionId?: string, duration?: number): Promise; createJWT( - paramsOrFirst: { userId: string, sessionId?: string, duration?: number } | string, - ...rest: [(string)?, (number)?] + userId: string, + sessionId?: string, + duration?: number, + ): Promise; + createJWT( + paramsOrFirst: + { userId: string; sessionId?: string; duration?: number } | string, + ...rest: [string?, number?] ): Promise { - let params: { userId: string, sessionId?: string, duration?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, sessionId?: string, duration?: number }; + let params: { userId: string; sessionId?: string; duration?: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + sessionId?: string; + duration?: number; + }; } else { params = { userId: paramsOrFirst as string, sessionId: rest[0] as string, - duration: rest[1] as number + duration: rest[1] as number, }; } - + const userId = params.userId; const sessionId = params.sessionId; const duration = params.duration; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/jwts'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/jwts'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof sessionId !== 'undefined') { - payload['sessionId'] = sessionId; + apiPayload['sessionId'] = sessionId; } if (typeof duration !== 'undefined') { - payload['duration'] = duration; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** - * Update the user labels by its unique ID. - * + * Update the user labels by its unique ID. + * * Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info. * * @param {string} params.userId - User ID. @@ -1287,10 +1654,15 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updateLabels(params: { userId: string, labels: string[] }): Promise>; + updateLabels< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + labels: string[]; + }): Promise>; /** - * Update the user labels by its unique ID. - * + * Update the user labels by its unique ID. + * * Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info. * * @param {string} userId - User ID. @@ -1299,51 +1671,58 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateLabels(userId: string, labels: string[]): Promise>; - updateLabels( - paramsOrFirst: { userId: string, labels: string[] } | string, - ...rest: [(string[])?] + updateLabels< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, labels: string[]): Promise>; + updateLabels< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; labels: string[] } | string, + ...rest: [string[]?] ): Promise> { - let params: { userId: string, labels: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, labels: string[] }; + let params: { userId: string; labels: string[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + labels: string[]; + }; } else { params = { userId: paramsOrFirst as string, - labels: rest[0] as string[] + labels: rest[0] as string[], }; } - + const userId = params.userId; const labels = params.labels; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof labels === 'undefined') { throw new AppwriteException('Missing required parameter: "labels"'); } - - const apiPath = '/users/{userId}/labels'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/labels'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof labels !== 'undefined') { - payload['labels'] = labels; + apiPayload['labels'] = labels; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1355,7 +1734,11 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - listLogs(params: { userId: string, queries?: string[], total?: boolean }): Promise; + listLogs(params: { + userId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * Get the user activity logs list by its unique ID. * @@ -1366,52 +1749,61 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listLogs(userId: string, queries?: string[], total?: boolean): Promise; listLogs( - paramsOrFirst: { userId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + userId: string, + queries?: string[], + total?: boolean, + ): Promise; + listLogs( + paramsOrFirst: + { userId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { userId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, queries?: string[], total?: boolean }; + let params: { userId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { userId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const userId = params.userId; const queries = params.queries; const total = params.total; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/logs'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/logs'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1424,7 +1816,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - listMemberships(params: { userId: string, queries?: string[], search?: string, total?: boolean }): Promise; + listMemberships(params: { + userId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; /** * Get the user membership list by its unique ID. * @@ -1436,57 +1833,79 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listMemberships(userId: string, queries?: string[], search?: string, total?: boolean): Promise; listMemberships( - paramsOrFirst: { userId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] + userId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listMemberships( + paramsOrFirst: + | { + userId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] ): Promise { - let params: { userId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, queries?: string[], search?: string, total?: boolean }; + let params: { + userId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; } else { params = { userId: paramsOrFirst as string, queries: rest[0] as string[], search: rest[1] as string, - total: rest[2] as boolean + total: rest[2] as boolean, }; } - + const userId = params.userId; const queries = params.queries; const search = params.search; const total = params.total; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/memberships'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/memberships'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof search !== 'undefined') { - payload['search'] = search; + apiPayload['search'] = search; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1498,7 +1917,12 @@ export class Users { * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `Users.updateMFA` instead. */ - updateMfa(params: { userId: string, mfa: boolean }): Promise>; + updateMfa< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + mfa: boolean; + }): Promise>; /** * Enable or disable MFA on a user account. * @@ -1508,51 +1932,55 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMfa(userId: string, mfa: boolean): Promise>; - updateMfa( - paramsOrFirst: { userId: string, mfa: boolean } | string, - ...rest: [(boolean)?] + updateMfa< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, mfa: boolean): Promise>; + updateMfa< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; mfa: boolean } | string, + ...rest: [boolean?] ): Promise> { - let params: { userId: string, mfa: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, mfa: boolean }; + let params: { userId: string; mfa: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { userId: string; mfa: boolean }; } else { params = { userId: paramsOrFirst as string, - mfa: rest[0] as boolean + mfa: rest[0] as boolean, }; } - + const userId = params.userId; const mfa = params.mfa; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof mfa === 'undefined') { throw new AppwriteException('Missing required parameter: "mfa"'); } - - const apiPath = '/users/{userId}/mfa'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/mfa'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof mfa !== 'undefined') { - payload['mfa'] = mfa; + apiPayload['mfa'] = mfa; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1563,7 +1991,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updateMFA(params: { userId: string, mfa: boolean }): Promise>; + updateMFA< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + mfa: boolean; + }): Promise>; /** * Enable or disable MFA on a user account. * @@ -1573,51 +2006,55 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateMFA(userId: string, mfa: boolean): Promise>; - updateMFA( - paramsOrFirst: { userId: string, mfa: boolean } | string, - ...rest: [(boolean)?] + updateMFA< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, mfa: boolean): Promise>; + updateMFA< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; mfa: boolean } | string, + ...rest: [boolean?] ): Promise> { - let params: { userId: string, mfa: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, mfa: boolean }; + let params: { userId: string; mfa: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { userId: string; mfa: boolean }; } else { params = { userId: paramsOrFirst as string, - mfa: rest[0] as boolean + mfa: rest[0] as boolean, }; } - + const userId = params.userId; const mfa = params.mfa; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof mfa === 'undefined') { throw new AppwriteException('Missing required parameter: "mfa"'); } - - const apiPath = '/users/{userId}/mfa'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/mfa'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof mfa !== 'undefined') { - payload['mfa'] = mfa; + apiPayload['mfa'] = mfa; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1629,7 +2066,10 @@ export class Users { * @returns {Promise<{}>} * @deprecated This API has been deprecated since 1.8.0. Please use `Users.deleteMFAAuthenticator` instead. */ - deleteMfaAuthenticator(params: { userId: string, type: AuthenticatorType }): Promise<{}>; + deleteMfaAuthenticator(params: { + userId: string; + type: AuthenticatorType; + }): Promise<{}>; /** * Delete an authenticator app. * @@ -1639,47 +2079,52 @@ export class Users { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteMfaAuthenticator(userId: string, type: AuthenticatorType): Promise<{}>; deleteMfaAuthenticator( - paramsOrFirst: { userId: string, type: AuthenticatorType } | string, - ...rest: [(AuthenticatorType)?] + userId: string, + type: AuthenticatorType, + ): Promise<{}>; + deleteMfaAuthenticator( + paramsOrFirst: { userId: string; type: AuthenticatorType } | string, + ...rest: [AuthenticatorType?] ): Promise<{}> { - let params: { userId: string, type: AuthenticatorType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, type: AuthenticatorType }; + let params: { userId: string; type: AuthenticatorType }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + type: AuthenticatorType; + }; } else { params = { userId: paramsOrFirst as string, - type: rest[0] as AuthenticatorType + type: rest[0] as AuthenticatorType, }; } - + const userId = params.userId; const type = params.type; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/users/{userId}/mfa/authenticators/{type}'.replace('{userId}', encodeURIComponent(String(userId))).replace('{type}', encodeURIComponent(String(type))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/mfa/authenticators/{type}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{type}', encodeURIComponent(String(type))); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1690,7 +2135,10 @@ export class Users { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteMFAAuthenticator(params: { userId: string, type: AuthenticatorType }): Promise<{}>; + deleteMFAAuthenticator(params: { + userId: string; + type: AuthenticatorType; + }): Promise<{}>; /** * Delete an authenticator app. * @@ -1700,47 +2148,52 @@ export class Users { * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteMFAAuthenticator(userId: string, type: AuthenticatorType): Promise<{}>; deleteMFAAuthenticator( - paramsOrFirst: { userId: string, type: AuthenticatorType } | string, - ...rest: [(AuthenticatorType)?] + userId: string, + type: AuthenticatorType, + ): Promise<{}>; + deleteMFAAuthenticator( + paramsOrFirst: { userId: string; type: AuthenticatorType } | string, + ...rest: [AuthenticatorType?] ): Promise<{}> { - let params: { userId: string, type: AuthenticatorType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, type: AuthenticatorType }; + let params: { userId: string; type: AuthenticatorType }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + type: AuthenticatorType; + }; } else { params = { userId: paramsOrFirst as string, - type: rest[0] as AuthenticatorType + type: rest[0] as AuthenticatorType, }; } - + const userId = params.userId; const type = params.type; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } - - const apiPath = '/users/{userId}/mfa/authenticators/{type}'.replace('{userId}', encodeURIComponent(String(userId))).replace('{type}', encodeURIComponent(String(type))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/mfa/authenticators/{type}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{type}', encodeURIComponent(String(type))); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -1751,7 +2204,10 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - getMFAChallenge(params: { userId: string, challengeId: string }): Promise; + getMFAChallenge(params: { + userId: string; + challengeId: string; + }): Promise; /** * Get a custom MFA challenge for a user, including the code to be delivered through your own channel. * @@ -1761,47 +2217,54 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getMFAChallenge(userId: string, challengeId: string): Promise; getMFAChallenge( - paramsOrFirst: { userId: string, challengeId: string } | string, - ...rest: [(string)?] + userId: string, + challengeId: string, + ): Promise; + getMFAChallenge( + paramsOrFirst: { userId: string; challengeId: string } | string, + ...rest: [string?] ): Promise { - let params: { userId: string, challengeId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, challengeId: string }; + let params: { userId: string; challengeId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + challengeId: string; + }; } else { params = { userId: paramsOrFirst as string, - challengeId: rest[0] as string + challengeId: rest[0] as string, }; } - + const userId = params.userId; const challengeId = params.challengeId; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof challengeId === 'undefined') { - throw new AppwriteException('Missing required parameter: "challengeId"'); - } - - const apiPath = '/users/{userId}/mfa/challenges/{challengeId}'.replace('{userId}', encodeURIComponent(String(userId))).replace('{challengeId}', encodeURIComponent(String(challengeId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "challengeId"', + ); + } + const apiPath = '/users/{userId}/mfa/challenges/{challengeId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{challengeId}', encodeURIComponent(String(challengeId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1823,39 +2286,39 @@ export class Users { */ listMfaFactors(userId: string): Promise; listMfaFactors( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - - const userId = params.userId; + const userId = params.userId; if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/factors'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/mfa/factors'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1876,39 +2339,39 @@ export class Users { */ listMFAFactors(userId: string): Promise; listMFAFactors( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - - const userId = params.userId; + const userId = params.userId; if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/factors'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/mfa/factors'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1919,7 +2382,9 @@ export class Users { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Users.getMFARecoveryCodes` instead. */ - getMfaRecoveryCodes(params: { userId: string }): Promise; + getMfaRecoveryCodes(params: { + userId: string; + }): Promise; /** * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. * @@ -1930,39 +2395,39 @@ export class Users { */ getMfaRecoveryCodes(userId: string): Promise; getMfaRecoveryCodes( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - - const userId = params.userId; + const userId = params.userId; if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1972,7 +2437,9 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - getMFARecoveryCodes(params: { userId: string }): Promise; + getMFARecoveryCodes(params: { + userId: string; + }): Promise; /** * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. * @@ -1983,39 +2450,39 @@ export class Users { */ getMFARecoveryCodes(userId: string): Promise; getMFARecoveryCodes( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - - const userId = params.userId; + const userId = params.userId; if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2026,7 +2493,9 @@ export class Users { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Users.updateMFARecoveryCodes` instead. */ - updateMfaRecoveryCodes(params: { userId: string }): Promise; + updateMfaRecoveryCodes(params: { + userId: string; + }): Promise; /** * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. * @@ -2037,40 +2506,40 @@ export class Users { */ updateMfaRecoveryCodes(userId: string): Promise; updateMfaRecoveryCodes( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - - const userId = params.userId; + const userId = params.userId; if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2080,7 +2549,9 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - updateMFARecoveryCodes(params: { userId: string }): Promise; + updateMFARecoveryCodes(params: { + userId: string; + }): Promise; /** * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. * @@ -2091,40 +2562,40 @@ export class Users { */ updateMFARecoveryCodes(userId: string): Promise; updateMFARecoveryCodes( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - - const userId = params.userId; + const userId = params.userId; if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2135,7 +2606,9 @@ export class Users { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `Users.createMFARecoveryCodes` instead. */ - createMfaRecoveryCodes(params: { userId: string }): Promise; + createMfaRecoveryCodes(params: { + userId: string; + }): Promise; /** * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. * @@ -2146,40 +2619,40 @@ export class Users { */ createMfaRecoveryCodes(userId: string): Promise; createMfaRecoveryCodes( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - - const userId = params.userId; + const userId = params.userId; if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2189,7 +2662,9 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - createMFARecoveryCodes(params: { userId: string }): Promise; + createMFARecoveryCodes(params: { + userId: string; + }): Promise; /** * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. * @@ -2200,40 +2675,40 @@ export class Users { */ createMFARecoveryCodes(userId: string): Promise; createMFARecoveryCodes( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - - const userId = params.userId; + const userId = params.userId; if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2244,7 +2719,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updateName(params: { userId: string, name: string }): Promise>; + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + name: string; + }): Promise>; /** * Update the user name by its unique ID. * @@ -2254,51 +2734,55 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateName(userId: string, name: string): Promise>; - updateName( - paramsOrFirst: { userId: string, name: string } | string, - ...rest: [(string)?] + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, name: string): Promise>; + updateName< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; name: string } | string, + ...rest: [string?] ): Promise> { - let params: { userId: string, name: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, name: string }; + let params: { userId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { userId: string; name: string }; } else { params = { userId: paramsOrFirst as string, - name: rest[0] as string + name: rest[0] as string, }; } - + const userId = params.userId; const name = params.name; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } - - const apiPath = '/users/{userId}/name'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/name'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2309,7 +2793,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updatePassword(params: { userId: string, password: string }): Promise>; + updatePassword< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + password: string; + }): Promise>; /** * Update the user password by its unique ID. * @@ -2319,51 +2808,60 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePassword(userId: string, password: string): Promise>; - updatePassword( - paramsOrFirst: { userId: string, password: string } | string, - ...rest: [(string)?] + updatePassword< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, password: string): Promise>; + updatePassword< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; password: string } | string, + ...rest: [string?] ): Promise> { - let params: { userId: string, password: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, password: string }; + let params: { userId: string; password: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + password: string; + }; } else { params = { userId: paramsOrFirst as string, - password: rest[0] as string + password: rest[0] as string, }; } - + const userId = params.userId; const password = params.password; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); + throw new AppwriteException( + 'Missing required parameter: "password"', + ); } - - const apiPath = '/users/{userId}/password'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/password'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof password !== 'undefined') { - payload['password'] = password; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2374,7 +2872,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updatePhone(params: { userId: string, number: string }): Promise>; + updatePhone< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + number: string; + }): Promise>; /** * Update the user phone by its unique ID. * @@ -2384,51 +2887,58 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePhone(userId: string, number: string): Promise>; - updatePhone( - paramsOrFirst: { userId: string, number: string } | string, - ...rest: [(string)?] + updatePhone< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, number: string): Promise>; + updatePhone< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; number: string } | string, + ...rest: [string?] ): Promise> { - let params: { userId: string, number: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, number: string }; + let params: { userId: string; number: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + number: string; + }; } else { params = { userId: paramsOrFirst as string, - number: rest[0] as string + number: rest[0] as string, }; } - + const userId = params.userId; const number = params.number; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof number === 'undefined') { throw new AppwriteException('Missing required parameter: "number"'); } - - const apiPath = '/users/{userId}/phone'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/phone'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof number !== 'undefined') { - payload['number'] = number; + apiPayload['number'] = number; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2438,7 +2948,9 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - getPrefs(params: { userId: string }): Promise; + getPrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { userId: string }): Promise; /** * Get the user preferences by its unique ID. * @@ -2447,41 +2959,43 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getPrefs(userId: string): Promise; - getPrefs( - paramsOrFirst: { userId: string } | string - ): Promise { + getPrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string): Promise; + getPrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(paramsOrFirst: { userId: string } | string): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - - const userId = params.userId; + const userId = params.userId; if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/prefs'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/prefs'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2492,7 +3006,9 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - updatePrefs(params: { userId: string, prefs: object }): Promise; + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { userId: string; prefs: object }): Promise; /** * Update the user preferences by its unique ID. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. * @@ -2502,51 +3018,55 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePrefs(userId: string, prefs: object): Promise; - updatePrefs( - paramsOrFirst: { userId: string, prefs: object } | string, - ...rest: [(object)?] + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, prefs: object): Promise; + updatePrefs< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; prefs: object } | string, + ...rest: [object?] ): Promise { - let params: { userId: string, prefs: object }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, prefs: object }; + let params: { userId: string; prefs: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { userId: string; prefs: object }; } else { params = { userId: paramsOrFirst as string, - prefs: rest[0] as object + prefs: rest[0] as object, }; } - + const userId = params.userId; const prefs = params.prefs; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof prefs === 'undefined') { throw new AppwriteException('Missing required parameter: "prefs"'); } - - const apiPath = '/users/{userId}/prefs'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/prefs'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof prefs !== 'undefined') { - payload['prefs'] = prefs; + apiPayload['prefs'] = prefs; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2557,7 +3077,10 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - listSessions(params: { userId: string, total?: boolean }): Promise; + listSessions(params: { + userId: string; + total?: boolean; + }): Promise; /** * Get the user sessions list by its unique ID. * @@ -2569,50 +3092,53 @@ export class Users { */ listSessions(userId: string, total?: boolean): Promise; listSessions( - paramsOrFirst: { userId: string, total?: boolean } | string, - ...rest: [(boolean)?] + paramsOrFirst: { userId: string; total?: boolean } | string, + ...rest: [boolean?] ): Promise { - let params: { userId: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, total?: boolean }; + let params: { userId: string; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + total?: boolean; + }; } else { params = { userId: paramsOrFirst as string, - total: rest[0] as boolean + total: rest[0] as boolean, }; } - + const userId = params.userId; const total = params.total; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/sessions'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/sessions'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** * Creates a session for a user. Returns an immediately usable session object. - * + * * If you want to generate a token for a custom authentication flow, use the [POST /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) endpoint. * * @param {string} params.userId - User 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. @@ -2622,7 +3148,7 @@ export class Users { createSession(params: { userId: string }): Promise; /** * Creates a session for a user. Returns an immediately usable session object. - * + * * If you want to generate a token for a custom authentication flow, use the [POST /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) endpoint. * * @param {string} userId - User 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. @@ -2632,40 +3158,40 @@ export class Users { */ createSession(userId: string): Promise; createSession( - paramsOrFirst: { userId: string } | string + paramsOrFirst: { userId: string } | string, ): Promise { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - - const userId = params.userId; + const userId = params.userId; if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/sessions'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/sessions'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2685,40 +3211,38 @@ export class Users { * @deprecated Use the object parameter style method for a better developer experience. */ deleteSessions(userId: string): Promise<{}>; - deleteSessions( - paramsOrFirst: { userId: string } | string - ): Promise<{}> { + deleteSessions(paramsOrFirst: { userId: string } | string): Promise<{}> { let params: { userId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { userId: string }; } else { params = { - userId: paramsOrFirst as string + userId: paramsOrFirst as string, }; } - - const userId = params.userId; + const userId = params.userId; if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/sessions'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/sessions'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -2729,7 +3253,7 @@ export class Users { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteSession(params: { userId: string, sessionId: string }): Promise<{}>; + deleteSession(params: { userId: string; sessionId: string }): Promise<{}>; /** * Delete a user sessions by its unique ID. * @@ -2741,45 +3265,49 @@ export class Users { */ deleteSession(userId: string, sessionId: string): Promise<{}>; deleteSession( - paramsOrFirst: { userId: string, sessionId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { userId: string; sessionId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { userId: string, sessionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, sessionId: string }; + let params: { userId: string; sessionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + sessionId: string; + }; } else { params = { userId: paramsOrFirst as string, - sessionId: rest[0] as string + sessionId: rest[0] as string, }; } - + const userId = params.userId; const sessionId = params.sessionId; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof sessionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "sessionId"'); - } - - const apiPath = '/users/{userId}/sessions/{sessionId}'.replace('{userId}', encodeURIComponent(String(userId))).replace('{sessionId}', encodeURIComponent(String(sessionId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "sessionId"', + ); + } + const apiPath = '/users/{userId}/sessions/{sessionId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{sessionId}', encodeURIComponent(String(sessionId))); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -2790,7 +3318,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updateStatus(params: { userId: string, status: boolean }): Promise>; + updateStatus< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + status: boolean; + }): Promise>; /** * Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user's ID reserved. * @@ -2800,51 +3333,58 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateStatus(userId: string, status: boolean): Promise>; - updateStatus( - paramsOrFirst: { userId: string, status: boolean } | string, - ...rest: [(boolean)?] + updateStatus< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(userId: string, status: boolean): Promise>; + updateStatus< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; status: boolean } | string, + ...rest: [boolean?] ): Promise> { - let params: { userId: string, status: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, status: boolean }; + let params: { userId: string; status: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + status: boolean; + }; } else { params = { userId: paramsOrFirst as string, - status: rest[0] as boolean + status: rest[0] as boolean, }; } - + const userId = params.userId; const status = params.status; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof status === 'undefined') { throw new AppwriteException('Missing required parameter: "status"'); } - - const apiPath = '/users/{userId}/status'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/status'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof status !== 'undefined') { - payload['status'] = status; + apiPayload['status'] = status; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2856,7 +3396,11 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - listTargets(params: { userId: string, queries?: string[], total?: boolean }): Promise; + listTargets(params: { + userId: string; + queries?: string[]; + total?: boolean; + }): Promise; /** * List the messaging targets that are associated with a user. * @@ -2867,52 +3411,61 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTargets(userId: string, queries?: string[], total?: boolean): Promise; listTargets( - paramsOrFirst: { userId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] + userId: string, + queries?: string[], + total?: boolean, + ): Promise; + listTargets( + paramsOrFirst: + { userId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] ): Promise { - let params: { userId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, queries?: string[], total?: boolean }; + let params: { userId: string; queries?: string[]; total?: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + queries?: string[]; + total?: boolean; + }; } else { params = { userId: paramsOrFirst as string, queries: rest[0] as string[], - total: rest[1] as boolean + total: rest[1] as boolean, }; } - + const userId = params.userId; const queries = params.queries; const total = params.total; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/targets'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/targets'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2927,7 +3480,14 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - createTarget(params: { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string }): Promise; + createTarget(params: { + userId: string; + targetId: string; + providerType: MessagingProviderType; + identifier: string; + providerId?: string; + name?: string; + }): Promise; /** * Create a messaging target. * @@ -2941,15 +3501,49 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTarget(userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string): Promise; createTarget( - paramsOrFirst: { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string } | string, - ...rest: [(string)?, (MessagingProviderType)?, (string)?, (string)?, (string)?] + userId: string, + targetId: string, + providerType: MessagingProviderType, + identifier: string, + providerId?: string, + name?: string, + ): Promise; + createTarget( + paramsOrFirst: + | { + userId: string; + targetId: string; + providerType: MessagingProviderType; + identifier: string; + providerId?: string; + name?: string; + } + | string, + ...rest: [string?, MessagingProviderType?, string?, string?, string?] ): Promise { - let params: { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string }; + let params: { + userId: string; + targetId: string; + providerType: MessagingProviderType; + identifier: string; + providerId?: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + targetId: string; + providerType: MessagingProviderType; + identifier: string; + providerId?: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, @@ -2957,61 +3551,63 @@ export class Users { providerType: rest[1] as MessagingProviderType, identifier: rest[2] as string, providerId: rest[3] as string, - name: rest[4] as string + name: rest[4] as string, }; } - + const userId = params.userId; const targetId = params.targetId; const providerType = params.providerType; const identifier = params.identifier; const providerId = params.providerId; const name = params.name; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof targetId === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetId"'); + throw new AppwriteException( + 'Missing required parameter: "targetId"', + ); } if (typeof providerType === 'undefined') { - throw new AppwriteException('Missing required parameter: "providerType"'); + throw new AppwriteException( + 'Missing required parameter: "providerType"', + ); } if (typeof identifier === 'undefined') { - throw new AppwriteException('Missing required parameter: "identifier"'); + throw new AppwriteException( + 'Missing required parameter: "identifier"', + ); } - - const apiPath = '/users/{userId}/targets'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/targets'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof targetId !== 'undefined') { - payload['targetId'] = targetId; + apiPayload['targetId'] = targetId; } if (typeof providerType !== 'undefined') { - payload['providerType'] = providerType; + apiPayload['providerType'] = providerType; } if (typeof identifier !== 'undefined') { - payload['identifier'] = identifier; + apiPayload['identifier'] = identifier; } if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3022,7 +3618,10 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - getTarget(params: { userId: string, targetId: string }): Promise; + getTarget(params: { + userId: string; + targetId: string; + }): Promise; /** * Get a user's push notification target by ID. * @@ -3034,45 +3633,49 @@ export class Users { */ getTarget(userId: string, targetId: string): Promise; getTarget( - paramsOrFirst: { userId: string, targetId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { userId: string; targetId: string } | string, + ...rest: [string?] ): Promise { - let params: { userId: string, targetId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, targetId: string }; + let params: { userId: string; targetId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + targetId: string; + }; } else { params = { userId: paramsOrFirst as string, - targetId: rest[0] as string + targetId: rest[0] as string, }; } - + const userId = params.userId; const targetId = params.targetId; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof targetId === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetId"'); - } - - const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', encodeURIComponent(String(userId))).replace('{targetId}', encodeURIComponent(String(targetId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "targetId"', + ); + } + const apiPath = '/users/{userId}/targets/{targetId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{targetId}', encodeURIComponent(String(targetId))); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3086,7 +3689,13 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - updateTarget(params: { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string }): Promise; + updateTarget(params: { + userId: string; + targetId: string; + identifier?: string; + providerId?: string; + name?: string; + }): Promise; /** * Update a messaging target. * @@ -3099,63 +3708,90 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateTarget(userId: string, targetId: string, identifier?: string, providerId?: string, name?: string): Promise; updateTarget( - paramsOrFirst: { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?] + userId: string, + targetId: string, + identifier?: string, + providerId?: string, + name?: string, + ): Promise; + updateTarget( + paramsOrFirst: + | { + userId: string; + targetId: string; + identifier?: string; + providerId?: string; + name?: string; + } + | string, + ...rest: [string?, string?, string?, string?] ): Promise { - let params: { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string }; + let params: { + userId: string; + targetId: string; + identifier?: string; + providerId?: string; + name?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + targetId: string; + identifier?: string; + providerId?: string; + name?: string; + }; } else { params = { userId: paramsOrFirst as string, targetId: rest[0] as string, identifier: rest[1] as string, providerId: rest[2] as string, - name: rest[3] as string + name: rest[3] as string, }; } - + const userId = params.userId; const targetId = params.targetId; const identifier = params.identifier; const providerId = params.providerId; const name = params.name; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof targetId === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetId"'); - } - - const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', encodeURIComponent(String(userId))).replace('{targetId}', encodeURIComponent(String(targetId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "targetId"', + ); + } + const apiPath = '/users/{userId}/targets/{targetId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{targetId}', encodeURIComponent(String(targetId))); + const apiPayload: Payload = {}; if (typeof identifier !== 'undefined') { - payload['identifier'] = identifier; + apiPayload['identifier'] = identifier; } if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; + apiPayload['providerId'] = providerId; } if (typeof name !== 'undefined') { - payload['name'] = name; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3166,7 +3802,7 @@ export class Users { * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteTarget(params: { userId: string, targetId: string }): Promise<{}>; + deleteTarget(params: { userId: string; targetId: string }): Promise<{}>; /** * Delete a messaging target. * @@ -3178,50 +3814,54 @@ export class Users { */ deleteTarget(userId: string, targetId: string): Promise<{}>; deleteTarget( - paramsOrFirst: { userId: string, targetId: string } | string, - ...rest: [(string)?] + paramsOrFirst: { userId: string; targetId: string } | string, + ...rest: [string?] ): Promise<{}> { - let params: { userId: string, targetId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, targetId: string }; + let params: { userId: string; targetId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + targetId: string; + }; } else { params = { userId: paramsOrFirst as string, - targetId: rest[0] as string + targetId: rest[0] as string, }; } - + const userId = params.userId; const targetId = params.targetId; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof targetId === 'undefined') { - throw new AppwriteException('Missing required parameter: "targetId"'); - } - - const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', encodeURIComponent(String(userId))).replace('{targetId}', encodeURIComponent(String(targetId))); - const payload: Payload = {}; + throw new AppwriteException( + 'Missing required parameter: "targetId"', + ); + } + const apiPath = '/users/{userId}/targets/{targetId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{targetId}', encodeURIComponent(String(targetId))); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** * Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. - * + * * * @param {string} params.userId - User ID. * @param {number} params.length - Token length in characters. The default length is 6 characters @@ -3229,10 +3869,14 @@ export class Users { * @throws {AppwriteException} * @returns {Promise} */ - createToken(params: { userId: string, length?: number, expire?: number }): Promise; + createToken(params: { + userId: string; + length?: number; + expire?: number; + }): Promise; /** * Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. - * + * * * @param {string} userId - User ID. * @param {number} length - Token length in characters. The default length is 6 characters @@ -3241,53 +3885,62 @@ export class Users { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createToken(userId: string, length?: number, expire?: number): Promise; createToken( - paramsOrFirst: { userId: string, length?: number, expire?: number } | string, - ...rest: [(number)?, (number)?] + userId: string, + length?: number, + expire?: number, + ): Promise; + createToken( + paramsOrFirst: + { userId: string; length?: number; expire?: number } | string, + ...rest: [number?, number?] ): Promise { - let params: { userId: string, length?: number, expire?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, length?: number, expire?: number }; + let params: { userId: string; length?: number; expire?: number }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + length?: number; + expire?: number; + }; } else { params = { userId: paramsOrFirst as string, length: rest[0] as number, - expire: rest[1] as number + expire: rest[1] as number, }; } - + const userId = params.userId; const length = params.length; const expire = params.expire; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - - const apiPath = '/users/{userId}/tokens'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/tokens'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof length !== 'undefined') { - payload['length'] = length; + apiPayload['length'] = length; } if (typeof expire !== 'undefined') { - payload['expire'] = expire; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3298,7 +3951,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updateEmailVerification(params: { userId: string, emailVerification: boolean }): Promise>; + updateEmailVerification< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + emailVerification: boolean; + }): Promise>; /** * Update the user email verification status by its unique ID. * @@ -3308,51 +3966,63 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmailVerification(userId: string, emailVerification: boolean): Promise>; - updateEmailVerification( - paramsOrFirst: { userId: string, emailVerification: boolean } | string, - ...rest: [(boolean)?] + updateEmailVerification< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + emailVerification: boolean, + ): Promise>; + updateEmailVerification< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; emailVerification: boolean } | string, + ...rest: [boolean?] ): Promise> { - let params: { userId: string, emailVerification: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, emailVerification: boolean }; + let params: { userId: string; emailVerification: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + emailVerification: boolean; + }; } else { params = { userId: paramsOrFirst as string, - emailVerification: rest[0] as boolean + emailVerification: rest[0] as boolean, }; } - + const userId = params.userId; const emailVerification = params.emailVerification; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof emailVerification === 'undefined') { - throw new AppwriteException('Missing required parameter: "emailVerification"'); + throw new AppwriteException( + 'Missing required parameter: "emailVerification"', + ); } - - const apiPath = '/users/{userId}/verification'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/verification'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof emailVerification !== 'undefined') { - payload['emailVerification'] = emailVerification; + apiPayload['emailVerification'] = emailVerification; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3363,7 +4033,12 @@ export class Users { * @throws {AppwriteException} * @returns {Promise>} */ - updatePhoneVerification(params: { userId: string, phoneVerification: boolean }): Promise>; + updatePhoneVerification< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >(params: { + userId: string; + phoneVerification: boolean; + }): Promise>; /** * Update the user phone verification status by its unique ID. * @@ -3373,50 +4048,62 @@ export class Users { * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePhoneVerification(userId: string, phoneVerification: boolean): Promise>; - updatePhoneVerification( - paramsOrFirst: { userId: string, phoneVerification: boolean } | string, - ...rest: [(boolean)?] + updatePhoneVerification< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + userId: string, + phoneVerification: boolean, + ): Promise>; + updatePhoneVerification< + Preferences extends Models.Preferences = Models.DefaultPreferences, + >( + paramsOrFirst: { userId: string; phoneVerification: boolean } | string, + ...rest: [boolean?] ): Promise> { - let params: { userId: string, phoneVerification: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, phoneVerification: boolean }; + let params: { userId: string; phoneVerification: boolean }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + phoneVerification: boolean; + }; } else { params = { userId: paramsOrFirst as string, - phoneVerification: rest[0] as boolean + phoneVerification: rest[0] as boolean, }; } - + const userId = params.userId; const phoneVerification = params.phoneVerification; - if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof phoneVerification === 'undefined') { - throw new AppwriteException('Missing required parameter: "phoneVerification"'); + throw new AppwriteException( + 'Missing required parameter: "phoneVerification"', + ); } - - const apiPath = '/users/{userId}/verification/phone'.replace('{userId}', encodeURIComponent(String(userId))); - const payload: Payload = {}; + const apiPath = '/users/{userId}/verification/phone'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + const apiPayload: Payload = {}; if (typeof phoneVerification !== 'undefined') { - payload['phoneVerification'] = phoneVerification; + apiPayload['phoneVerification'] = phoneVerification; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } } diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts new file mode 100644 index 00000000..97ac1dd7 --- /dev/null +++ b/src/services/vectors-db.ts @@ -0,0 +1,3616 @@ +import { AppwriteException, Client, type Payload } from '../client'; +import type { Models } from '../models'; + +import { VectorsDBIndexType } from '../enums/vectors-db-index-type'; +import { OrderBy } from '../enums/order-by'; +export class VectorsDB { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * Get a list of all databases from the current Appwrite project. You can use the search parameter 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 columns: name + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + list(params?: { + queries?: string[]; + total?: boolean; + }): Promise; + /** + * Get a list of all databases from the current Appwrite project. You can use the search parameter 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 columns: name + * @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. + */ + list(queries?: string[], total?: boolean): Promise; + list( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] + ): Promise { + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 = '/vectorsdb'; + 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 Database. + * + * + * @param {string} params.databaseId - Unique 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 - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {string} params.specification - Database specification. Defaults to `serverless`, which creates the database on the shared pool. Any other value provisions a dedicated database on that specification. + * @param {number} params.replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Requires a dedicated `specification`; must be 0 for a serverless database. High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode for the dedicated database backing this database. Requires a dedicated `specification`; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. + * @throws {AppwriteException} + * @returns {Promise} + */ + create(params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }): Promise; + /** + * Create a new Database. + * + * + * @param {string} databaseId - Unique 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 - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {string} specification - Database specification. Defaults to `serverless`, which creates the database on the shared pool. Any other value provisions a dedicated database on that specification. + * @param {number} replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Requires a dedicated `specification`; must be 0 for a serverless database. High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode for the dedicated database backing this database. Requires a dedicated `specification`; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create( + databaseId: string, + name: string, + enabled?: boolean, + specification?: string, + replicas?: number, + syncMode?: string, + ): Promise; + create( + paramsOrFirst: + | { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + } + | string, + ...rest: [string?, boolean?, string?, number?, string?] + ): Promise { + let params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + specification: rest[2] as string, + replicas: rest[3] as number, + syncMode: rest[4] as string, + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + const specification = params.specification; + const replicas = params.replicas; + const syncMode = params.syncMode; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/vectorsdb'; + const apiPayload: Payload = {}; + if (typeof databaseId !== 'undefined') { + apiPayload['databaseId'] = databaseId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof specification !== 'undefined') { + apiPayload['specification'] = specification; + } + if (typeof replicas !== 'undefined') { + apiPayload['replicas'] = replicas; + } + if (typeof syncMode !== 'undefined') { + apiPayload['syncMode'] = syncMode; + } + 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 the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + listSpecifications(): Promise { + const apiPath = '/vectorsdb/specifications'; + 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); + } + + /** + * 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). + * @throws {AppwriteException} + * @returns {Promise} + */ + listTransactions(params?: { + queries?: string[]; + }): 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). + * @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[], + ): Promise { + let params: { queries?: string[] }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[], + }; + } + + const queries = params.queries; + const apiPath = '/vectorsdb/transactions'; + 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 transaction. + * + * @param {number} params.ttl - Seconds before the transaction expires. + * @throws {AppwriteException} + * @returns {Promise} + */ + createTransaction(params?: { ttl?: number }): Promise; + /** + * Create a new transaction. + * + * @param {number} ttl - Seconds before the transaction expires. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTransaction(ttl?: number): Promise; + createTransaction( + paramsOrFirst?: { ttl?: number } | number, + ): Promise { + let params: { ttl?: number }; + + if ( + !paramsOrFirst || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { ttl?: number }; + } else { + params = { + ttl: paramsOrFirst as number, + }; + } + + const ttl = params.ttl; + const apiPath = '/vectorsdb/transactions'; + const apiPayload: Payload = {}; + 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); + } + + /** + * Get a transaction by its unique ID. + * + * @param {string} params.transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getTransaction(params: { + transactionId: string; + }): Promise; + /** + * Get a transaction by its unique ID. + * + * @param {string} transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getTransaction(transactionId: string): Promise; + getTransaction( + paramsOrFirst: { transactionId: string } | string, + ): Promise { + let params: { transactionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { transactionId: string }; + } else { + params = { + transactionId: paramsOrFirst as string, + }; + } + + const transactionId = params.transactionId; + if (typeof transactionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); + } + const apiPath = '/vectorsdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + 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 transaction, to either commit or roll back its operations. + * + * @param {string} params.transactionId - Transaction ID. + * @param {boolean} params.commit - Commit transaction? + * @param {boolean} params.rollback - Rollback transaction? + * @throws {AppwriteException} + * @returns {Promise} + */ + updateTransaction(params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }): Promise; + /** + * Update a transaction, to either commit or roll back its operations. + * + * @param {string} transactionId - Transaction ID. + * @param {boolean} commit - Commit transaction? + * @param {boolean} rollback - Rollback transaction? + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTransaction( + transactionId: string, + commit?: boolean, + rollback?: boolean, + ): Promise; + updateTransaction( + paramsOrFirst: + | { transactionId: string; commit?: boolean; rollback?: boolean } + | string, + ...rest: [boolean?, boolean?] + ): Promise { + let params: { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + transactionId: string; + commit?: boolean; + rollback?: boolean; + }; + } else { + params = { + transactionId: paramsOrFirst as string, + commit: rest[0] as boolean, + rollback: rest[1] as boolean, + }; + } + + const transactionId = params.transactionId; + const commit = params.commit; + const rollback = params.rollback; + if (typeof transactionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); + } + const apiPath = '/vectorsdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + const apiPayload: Payload = {}; + if (typeof commit !== 'undefined') { + apiPayload['commit'] = commit; + } + if (typeof rollback !== 'undefined') { + apiPayload['rollback'] = rollback; + } + 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 a transaction by its unique ID. + * + * @param {string} params.transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteTransaction(params: { transactionId: string }): Promise<{}>; + /** + * Delete a transaction by its unique ID. + * + * @param {string} transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteTransaction(transactionId: string): Promise<{}>; + deleteTransaction( + paramsOrFirst: { transactionId: string } | string, + ): Promise<{}> { + let params: { transactionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { transactionId: string }; + } else { + params = { + transactionId: paramsOrFirst as string, + }; + } + + const transactionId = params.transactionId; + if (typeof transactionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); + } + const apiPath = '/vectorsdb/transactions/{transactionId}'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + 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', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } + + /** + * Create multiple operations in a single transaction. + * + * @param {string} params.transactionId - Transaction ID. + * @param {object[]} params.operations - Array of staged operations. + * @throws {AppwriteException} + * @returns {Promise} + */ + createOperations(params: { + transactionId: string; + operations?: object[]; + }): Promise; + /** + * Create multiple operations in a single transaction. + * + * @param {string} transactionId - Transaction ID. + * @param {object[]} operations - Array of staged operations. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createOperations( + transactionId: string, + operations?: object[], + ): Promise; + createOperations( + paramsOrFirst: + { transactionId: string; operations?: object[] } | string, + ...rest: [object[]?] + ): Promise { + let params: { transactionId: string; operations?: object[] }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + transactionId: string; + operations?: object[]; + }; + } else { + params = { + transactionId: paramsOrFirst as string, + operations: rest[0] as object[], + }; + } + + const transactionId = params.transactionId; + const operations = params.operations; + if (typeof transactionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "transactionId"', + ); + } + const apiPath = + '/vectorsdb/transactions/{transactionId}/operations'.replace( + '{transactionId}', + encodeURIComponent(String(transactionId)), + ); + const apiPayload: Payload = {}; + if (typeof operations !== 'undefined') { + apiPayload['operations'] = operations; + } + 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 database by its unique ID. This endpoint response returns a JSON object with the database metadata. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + get(params: { databaseId: string }): Promise; + /** + * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(databaseId: string): Promise; + get( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/vectorsdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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 database by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.name - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {string} params.specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. + * @param {number} params.replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. + * @param {string} params.syncMode - Replication sync mode for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. + * @throws {AppwriteException} + * @returns {Promise} + */ + update(params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }): Promise; + /** + * Update a database by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} name - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {string} specification - Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. + * @param {number} replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. + * @param {string} syncMode - Replication sync mode for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update( + databaseId: string, + name: string, + enabled?: boolean, + specification?: string, + replicas?: number, + syncMode?: string, + ): Promise; + update( + paramsOrFirst: + | { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + } + | string, + ...rest: [string?, boolean?, string?, number?, string?] + ): Promise { + let params: { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + name: string; + enabled?: boolean; + specification?: string; + replicas?: number; + syncMode?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + specification: rest[2] as string, + replicas: rest[3] as number, + syncMode: rest[4] as string, + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + const specification = params.specification; + const replicas = params.replicas; + const syncMode = params.syncMode; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/vectorsdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof specification !== 'undefined') { + apiPayload['specification'] = specification; + } + if (typeof replicas !== 'undefined') { + apiPayload['replicas'] = replicas; + } + if (typeof syncMode !== 'undefined') { + apiPayload['syncMode'] = syncMode; + } + 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 database by its unique ID. Only API keys with with databases.write scope can delete a database. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { databaseId: string }): Promise<{}>; + /** + * Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(databaseId: string): Promise<{}>; + delete(paramsOrFirst: { databaseId: string } | string): Promise<{}> { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/vectorsdb/{databaseId}'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } + + /** + * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. + * + * @param {string} params.databaseId - Database 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: name, enabled, documentSecurity + * @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} + */ + listCollections(params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; + /** + * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. + * + * @param {string} databaseId - Database 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: name, enabled, documentSecurity + * @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. + */ + listCollections( + databaseId: string, + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listCollections( + paramsOrFirst: + | { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + } + | string, + ...rest: [string[]?, string?, boolean?] + ): Promise { + let params: { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + queries?: string[]; + search?: string; + total?: boolean; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string, + total: rest[2] as boolean, + }; + } + + const databaseId = params.databaseId; + const queries = params.queries; + const search = params.search; + const total = params.total; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/vectorsdb/{databaseId}/collections'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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 new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Unique 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 - Collection name. Max length: 128 chars. + * @param {number} params.dimension - Embedding dimension. + * @param {string[]} params.permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + */ + createCollection(params: { + databaseId: string; + collectionId: string; + name: string; + dimension: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + }): Promise; + /** + * Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Unique 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 - Collection name. Max length: 128 chars. + * @param {number} dimension - Embedding dimension. + * @param {string[]} permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createCollection( + databaseId: string, + collectionId: string, + name: string, + dimension: number, + permissions?: string[], + documentSecurity?: boolean, + enabled?: boolean, + ): Promise; + createCollection( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + name: string; + dimension: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, number?, string[]?, boolean?, boolean?] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + name: string; + dimension: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + name: string; + dimension: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + name: rest[1] as string, + dimension: rest[2] as number, + permissions: rest[3] as string[], + documentSecurity: rest[4] as boolean, + enabled: rest[5] as boolean, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const name = params.name; + const dimension = params.dimension; + const permissions = params.permissions; + const documentSecurity = params.documentSecurity; + const enabled = params.enabled; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof dimension === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "dimension"', + ); + } + const apiPath = '/vectorsdb/{databaseId}/collections'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof collectionId !== 'undefined') { + apiPayload['collectionId'] = collectionId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof dimension !== 'undefined') { + apiPayload['dimension'] = dimension; + } + if (typeof permissions !== 'undefined') { + apiPayload['permissions'] = permissions; + } + if (typeof documentSecurity !== 'undefined') { + apiPayload['documentSecurity'] = documentSecurity; + } + 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('post', uri, apiHeaders, apiPayload); + } + + /** + * Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getCollection(params: { + databaseId: string; + collectionId: string; + }): Promise; + /** + * Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getCollection( + databaseId: string, + collectionId: string, + ): Promise; + getCollection( + paramsOrFirst: { databaseId: string; collectionId: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; collectionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + 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 collection by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.name - Collection name. Max length: 128 chars. + * @param {number} params.dimension - Embedding dimensions. + * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateCollection(params: { + databaseId: string; + collectionId: string; + name: string; + dimension?: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + }): Promise; + /** + * Update a collection by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} name - Collection name. Max length: 128 chars. + * @param {number} dimension - Embedding dimensions. + * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateCollection( + databaseId: string, + collectionId: string, + name: string, + dimension?: number, + permissions?: string[], + documentSecurity?: boolean, + enabled?: boolean, + ): Promise; + updateCollection( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + name: string; + dimension?: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + } + | string, + ...rest: [string?, string?, number?, string[]?, boolean?, boolean?] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + name: string; + dimension?: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + name: string; + dimension?: number; + permissions?: string[]; + documentSecurity?: boolean; + enabled?: boolean; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + name: rest[1] as string, + dimension: rest[2] as number, + permissions: rest[3] as string[], + documentSecurity: rest[4] as boolean, + enabled: rest[5] as boolean, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const name = params.name; + const dimension = params.dimension; + const permissions = params.permissions; + const documentSecurity = params.documentSecurity; + const enabled = params.enabled; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof dimension !== 'undefined') { + apiPayload['dimension'] = dimension; + } + if (typeof permissions !== 'undefined') { + apiPayload['permissions'] = permissions; + } + if (typeof documentSecurity !== 'undefined') { + apiPayload['documentSecurity'] = documentSecurity; + } + 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('put', uri, apiHeaders, apiPayload); + } + + /** + * Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteCollection(params: { + databaseId: string; + collectionId: string; + }): Promise<{}>; + /** + * Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteCollection(databaseId: string, collectionId: string): Promise<{}>; + deleteCollection( + paramsOrFirst: { databaseId: string; collectionId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { databaseId: string; collectionId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + 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', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } + + /** + * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @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 524288 characters long. + * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @param {number} params.ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + * @throws {AppwriteException} + * @returns {Promise>} + */ + listDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }): Promise>; + /** + * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @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 524288 characters long. + * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @param {number} ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listDocuments( + databaseId: string, + collectionId: string, + queries?: string[], + transactionId?: string, + total?: boolean, + ttl?: number, + ): Promise>; + listDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + } + | string, + ...rest: [string?, string[]?, string?, boolean?, number?] + ): Promise> { + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + transactionId: rest[2] as string, + total: rest[3] as boolean, + ttl: rest[4] as number, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const transactionId = params.transactionId; + const total = params.total; + const ttl = params.ttl; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + 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, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {string} params.documentId - Document 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 {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} params.data - Document data as JSON object. + * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise} + */ + createDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & Omit; + permissions?: string[]; + }): Promise; + /** + * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {string} documentId - Document 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 {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} data - Document data as JSON object. + * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDocument( + databaseId: string, + collectionId: string, + documentId: string, + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & Omit, + permissions?: string[], + ): Promise; + createDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit)?, + string[]?, + ] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit; + permissions?: string[]; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Omit, + permissions: rest[3] as string[], + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + if (typeof data === 'undefined') { + throw new AppwriteException('Missing required parameter: "data"'); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof documentId !== 'undefined') { + apiPayload['documentId'] = documentId; + } + if (typeof data !== 'undefined') { + apiPayload['data'] = data; + } + if (typeof permissions !== 'undefined') { + apiPayload['permissions'] = permissions; + } + 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); + } + + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {object[]} params.documents - Array of documents data as JSON objects. + * @throws {AppwriteException} + * @returns {Promise>} + */ + createDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documents: object[]; + }): Promise>; + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {object[]} documents - Array of documents data as JSON objects. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDocuments( + databaseId: string, + collectionId: string, + documents: object[], + ): Promise>; + createDocuments( + paramsOrFirst: + | { databaseId: string; collectionId: string; documents: object[] } + | string, + ...rest: [string?, object[]?] + ): Promise> { + let params: { + databaseId: string; + collectionId: string; + documents: object[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documents: object[]; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documents: rest[1] as object[], + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documents = params.documents; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documents === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documents"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof documents !== 'undefined') { + apiPayload['documents'] = documents; + } + 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); + } + + /** + * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {object[]} params.documents - Array of document data as JSON objects. May contain partial documents. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + */ + upsertDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }): Promise>; + /** + * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {object[]} documents - Array of document data as JSON objects. May contain partial documents. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + upsertDocuments( + databaseId: string, + collectionId: string, + documents: object[], + transactionId?: string, + ): Promise>; + upsertDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + } + | string, + ...rest: [string?, object[]?, string?] + ): Promise> { + let params: { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documents: object[]; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documents: rest[1] as object[], + transactionId: rest[2] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documents = params.documents; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documents === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documents"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof documents !== 'undefined') { + apiPayload['documents'] = documents; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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); + } + + /** + * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {object} params.data - Document data as JSON object. Include only attribute and value pairs to be updated. + * @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.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + */ + updateDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }): Promise>; + /** + * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {object} data - Document data as JSON object. Include only attribute and value pairs to be updated. + * @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} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDocuments( + databaseId: string, + collectionId: string, + data?: object, + queries?: string[], + transactionId?: string, + ): Promise>; + updateDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, object?, string[]?, string?] + ): Promise> { + let params: { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + data?: object; + queries?: string[]; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + data: rest[1] as object, + queries: rest[2] as string[], + transactionId: rest[3] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const data = params.data; + const queries = params.queries; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof data !== 'undefined') { + apiPayload['data'] = data; + } + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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); + } + + /** + * Bulk delete documents using queries, if no queries are passed then all documents are deleted. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @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.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + */ + deleteDocuments< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }): Promise>; + /** + * Bulk delete documents using queries, if no queries are passed then all documents are deleted. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @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} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteDocuments( + databaseId: string, + collectionId: string, + queries?: string[], + transactionId?: string, + ): Promise>; + deleteDocuments( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string[]?, string?] + ): Promise> { + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + transactionId: rest[2] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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 the user's documents in a given collection using a POST request. This behaves identically to the list documents endpoint but accepts the queries in the request body, allowing much larger `queries` arrays than can fit in a URL query string. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @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 524288 characters long. + * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @param {number} params.ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + * @throws {AppwriteException} + * @returns {Promise>} + */ + createQuery< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }): Promise>; + /** + * Get a list of all the user's documents in a given collection using a POST request. This behaves identically to the list documents endpoint but accepts the queries in the request body, allowing much larger `queries` arrays than can fit in a URL query string. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @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 524288 characters long. + * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @param {number} ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createQuery( + databaseId: string, + collectionId: string, + queries?: string[], + transactionId?: string, + total?: boolean, + ttl?: number, + ): Promise>; + createQuery( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + } + | string, + ...rest: [string?, string[]?, string?, boolean?, number?] + ): Promise> { + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + transactionId?: string; + total?: boolean; + ttl?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + transactionId: rest[2] as string, + total: rest[3] as boolean, + ttl: rest[4] as number, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const transactionId = params.transactionId; + const total = params.total; + const ttl = params.ttl; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents/query' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + 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); + } + + /** + * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.documentId - Document 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. + * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. + * @throws {AppwriteException} + * @returns {Promise} + */ + getDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }): Promise; + /** + * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} documentId - Document 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. + * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getDocument( + databaseId: string, + collectionId: string, + documentId: string, + queries?: string[], + transactionId?: string, + ): Promise; + getDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string[]?, string?] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + queries?: string[]; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + queries: rest[2] as string[], + transactionId: rest[3] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const queries = params.queries; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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 or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} params.data - Document data as JSON object. Include all required fields of the document to be created or updated. + * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + */ + upsertDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; + /** + * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} data - Document data as JSON object. Include all required fields of the document to be created or updated. + * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + upsertDocument( + databaseId: string, + collectionId: string, + documentId: string, + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + upsertDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>)?, + string[]?, + string?, + ] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions: rest[3] as string[], + transactionId: rest[4] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); + const apiPayload: Payload = {}; + if (typeof data !== 'undefined') { + apiPayload['data'] = data; + } + if (typeof permissions !== 'undefined') { + apiPayload['permissions'] = permissions; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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); + } + + /** + * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} params.data - Document data as JSON object. Include only fields and value pairs to be updated. + * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateDocument< + Document extends Models.Document = Models.DefaultDocument, + >(params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }): Promise; + /** + * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} data - Document data as JSON object. Include only fields and value pairs to be updated. + * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDocument( + databaseId: string, + collectionId: string, + documentId: string, + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions?: string[], + transactionId?: string, + ): Promise; + updateDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + } + | string, + ...rest: [ + string?, + string?, + (Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>)?, + string[]?, + string?, + ] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + data?: Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>; + permissions?: string[]; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as Document extends Models.DefaultDocument + ? Partial & Record + : Partial & + Partial>, + permissions: rest[3] as string[], + transactionId: rest[4] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); + const apiPayload: Payload = {}; + if (typeof data !== 'undefined') { + apiPayload['data'] = data; + } + if (typeof permissions !== 'undefined') { + apiPayload['permissions'] = permissions; + } + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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 a document by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.documentId - Document ID. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteDocument(params: { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }): Promise<{}>; + /** + * Delete a document by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} documentId - Document ID. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteDocument( + databaseId: string, + collectionId: string, + documentId: string, + transactionId?: string, + ): Promise<{}>; + deleteDocument( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + } + | string, + ...rest: [string?, string?, string?] + ): Promise<{}> { + let params: { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + documentId: string; + transactionId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + transactionId: rest[2] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const transactionId = params.transactionId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "documentId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace( + '{documentId}', + encodeURIComponent(String(documentId)), + ); + const apiPayload: Payload = {}; + if (typeof transactionId !== 'undefined') { + apiPayload['transactionId'] = transactionId; + } + 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', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } + + /** + * List indexes in the collection. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @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: key, type, status, attributes, error + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listIndexes(params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }): Promise; + /** + * List indexes in the collection. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @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: key, type, status, attributes, error + * @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. + */ + listIndexes( + databaseId: string, + collectionId: string, + queries?: string[], + total?: boolean, + ): Promise; + listIndexes( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + } + | string, + ...rest: [string?, string[]?, boolean?] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + queries?: string[]; + total?: boolean; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + total: rest[2] as boolean, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const total = params.total; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + 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); + } + + /** + * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. + * Attributes can be `key`, `fulltext`, and `unique`. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @param {VectorsDBIndexType} params.type - Index type. + * @param {string[]} params.attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. + * @param {OrderBy[]} params.orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} params.lengths - Length of index. Maximum of 100 + * @throws {AppwriteException} + * @returns {Promise} + */ + createIndex(params: { + databaseId: string; + collectionId: string; + key: string; + type: VectorsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }): Promise; + /** + * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. + * Attributes can be `key`, `fulltext`, and `unique`. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @param {VectorsDBIndexType} type - Index type. + * @param {string[]} attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. + * @param {OrderBy[]} orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} lengths - Length of index. Maximum of 100 + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIndex( + databaseId: string, + collectionId: string, + key: string, + type: VectorsDBIndexType, + attributes: string[], + orders?: OrderBy[], + lengths?: number[], + ): Promise; + createIndex( + paramsOrFirst: + | { + databaseId: string; + collectionId: string; + key: string; + type: VectorsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + } + | string, + ...rest: [ + string?, + string?, + VectorsDBIndexType?, + string[]?, + OrderBy[]?, + number[]?, + ] + ): Promise { + let params: { + databaseId: string; + collectionId: string; + key: string; + type: VectorsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + type: VectorsDBIndexType; + attributes: string[]; + orders?: OrderBy[]; + lengths?: number[]; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + type: rest[2] as VectorsDBIndexType, + attributes: rest[3] as string[], + orders: rest[4] as OrderBy[], + lengths: rest[5] as number[], + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const type = params.type; + const attributes = params.attributes; + const orders = params.orders; + const lengths = params.lengths; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (typeof attributes === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "attributes"', + ); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ); + const apiPayload: Payload = {}; + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof type !== 'undefined') { + apiPayload['type'] = type; + } + if (typeof attributes !== 'undefined') { + apiPayload['attributes'] = attributes; + } + if (typeof orders !== 'undefined') { + apiPayload['orders'] = orders; + } + if (typeof lengths !== 'undefined') { + apiPayload['lengths'] = lengths; + } + 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 index by ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @throws {AppwriteException} + * @returns {Promise} + */ + getIndex(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise; + /** + * Get index by ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getIndex( + databaseId: string, + collectionId: string, + key: string, + ): Promise; + getIndex( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] + ): Promise { + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + 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 an index. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteIndex(params: { + databaseId: string; + collectionId: string; + key: string; + }): Promise<{}>; + /** + * Delete an index. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteIndex( + databaseId: string, + collectionId: string, + key: string, + ): Promise<{}>; + deleteIndex( + paramsOrFirst: + { databaseId: string; collectionId: string; key: string } | string, + ...rest: [string?, string?] + ): Promise<{}> { + let params: { databaseId: string; collectionId: string; key: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + collectionId: string; + key: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "collectionId"', + ); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + const apiPath = + '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .replace('{databaseId}', encodeURIComponent(String(databaseId))) + .replace( + '{collectionId}', + encodeURIComponent(String(collectionId)), + ) + .replace('{key}', encodeURIComponent(String(key))); + 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', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } + + /** + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. + * @throws {AppwriteException} + * @returns {Promise} + */ + createFailover(params: { + databaseId: string; + targetReplicaId?: string; + }): Promise; + /** + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. + * + * @param {string} databaseId - Database ID. + * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFailover( + databaseId: string, + targetReplicaId?: string, + ): Promise; + createFailover( + paramsOrFirst: + { databaseId: string; targetReplicaId?: string } | string, + ...rest: [string?] + ): Promise { + let params: { databaseId: string; targetReplicaId?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + targetReplicaId?: string; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + targetReplicaId: rest[0] as string, + }; + } + + const databaseId = params.databaseId; + const targetReplicaId = params.targetReplicaId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/vectorsdb/{databaseId}/failovers'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof targetReplicaId !== 'undefined') { + apiPayload['targetReplicaId'] = targetReplicaId; + } + 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 the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.status - Filter by operation status. + * @param {number} params.limit - Maximum number of operations to return. + * @param {number} params.offset - Number of operations to skip. + * @throws {AppwriteException} + * @returns {Promise} + */ + listOperations(params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }): Promise; + /** + * List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. + * + * @param {string} databaseId - Database ID. + * @param {string} status - Filter by operation status. + * @param {number} limit - Maximum number of operations to return. + * @param {number} offset - Number of operations to skip. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listOperations( + databaseId: string, + status?: string, + limit?: number, + offset?: number, + ): Promise; + listOperations( + paramsOrFirst: + | { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + } + | string, + ...rest: [string?, number?, number?] + ): Promise { + let params: { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + databaseId: string; + status?: string; + limit?: number; + offset?: number; + }; + } else { + params = { + databaseId: paramsOrFirst as string, + status: rest[0] as string, + limit: rest[1] as number, + offset: rest[2] as number, + }; + } + + const databaseId = params.databaseId; + const status = params.status; + const limit = params.limit; + const offset = params.offset; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/vectorsdb/{databaseId}/operations'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + const apiPayload: Payload = {}; + if (typeof status !== 'undefined') { + apiPayload['status'] = status; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof offset !== 'undefined') { + apiPayload['offset'] = offset; + } + 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 high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getReplicas(params: { + databaseId: string; + }): Promise; + /** + * Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getReplicas(databaseId: string): Promise; + getReplicas( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/vectorsdb/{databaseId}/replicas'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } + + /** + * Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getStatus(params: { databaseId: string }): Promise; + /** + * Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getStatus(databaseId: string): Promise; + getStatus( + paramsOrFirst: { databaseId: string } | string, + ): Promise { + let params: { databaseId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + const apiPath = '/vectorsdb/{databaseId}/status'.replace( + '{databaseId}', + encodeURIComponent(String(databaseId)), + ); + 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); + } +} diff --git a/src/services/webhooks.ts b/src/services/webhooks.ts index 71d27f13..b63c750c 100644 --- a/src/services/webhooks.ts +++ b/src/services/webhooks.ts @@ -1,8 +1,6 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; - - export class Webhooks { client: Client; @@ -18,7 +16,10 @@ export class Webhooks { * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], total?: boolean }): Promise; + list(params?: { + queries?: string[]; + total?: boolean; + }): Promise; /** * Get a list of all webhooks belonging to the project. You can use the query params to filter your results. * @@ -30,45 +31,46 @@ export class Webhooks { */ list(queries?: string[], total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], total?: boolean } | string[], - ...rest: [(boolean)?] + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] ): Promise { - let params: { queries?: string[], total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + let params: { queries?: string[]; total?: boolean }; + + if ( + !paramsOrFirst || + (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 + total: rest[0] as boolean, }; } - + const queries = params.queries; const total = params.total; - - const apiPath = '/webhooks'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof queries !== 'undefined') { - payload['queries'] = queries; + apiPayload['queries'] = queries; } if (typeof total !== 'undefined') { - payload['total'] = total; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -86,7 +88,17 @@ export class Webhooks { * @throws {AppwriteException} * @returns {Promise} */ - create(params: { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string, secret?: string }): Promise; + create(params: { + webhookId: string; + url: string; + name: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + secret?: string; + }): Promise; /** * Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur. * @@ -103,15 +115,70 @@ export class Webhooks { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(webhookId: string, url: string, name: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string, secret?: string): Promise; create( - paramsOrFirst: { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string, secret?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (string)?, (string)?, (string)?] + webhookId: string, + url: string, + name: string, + events: string[], + enabled?: boolean, + tls?: boolean, + authUsername?: string, + authPassword?: string, + secret?: string, + ): Promise; + create( + paramsOrFirst: + | { + webhookId: string; + url: string; + name: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + secret?: string; + } + | string, + ...rest: [ + string?, + string?, + string[]?, + boolean?, + boolean?, + string?, + string?, + string?, + ] ): Promise { - let params: { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string, secret?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string, secret?: string }; + let params: { + webhookId: string; + url: string; + name: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + secret?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + webhookId: string; + url: string; + name: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + secret?: string; + }; } else { params = { webhookId: paramsOrFirst as string, @@ -122,10 +189,10 @@ export class Webhooks { tls: rest[4] as boolean, authUsername: rest[5] as string, authPassword: rest[6] as string, - secret: rest[7] as string + secret: rest[7] as string, }; } - + const webhookId = params.webhookId; const url = params.url; const name = params.name; @@ -135,9 +202,10 @@ export class Webhooks { const authUsername = params.authUsername; const authPassword = params.authPassword; const secret = params.secret; - if (typeof webhookId === 'undefined') { - throw new AppwriteException('Missing required parameter: "webhookId"'); + throw new AppwriteException( + 'Missing required parameter: "webhookId"', + ); } if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); @@ -148,54 +216,48 @@ export class Webhooks { if (typeof events === 'undefined') { throw new AppwriteException('Missing required parameter: "events"'); } - const apiPath = '/webhooks'; - const payload: Payload = {}; + const apiPayload: Payload = {}; if (typeof webhookId !== 'undefined') { - payload['webhookId'] = webhookId; + apiPayload['webhookId'] = webhookId; } if (typeof url !== 'undefined') { - payload['url'] = url; + apiPayload['url'] = url; } if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof events !== 'undefined') { - payload['events'] = events; + apiPayload['events'] = events; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof tls !== 'undefined') { - payload['tls'] = tls; + apiPayload['tls'] = tls; } if (typeof authUsername !== 'undefined') { - payload['authUsername'] = authUsername; + apiPayload['authUsername'] = authUsername; } if (typeof authPassword !== 'undefined') { - payload['authPassword'] = authPassword; + apiPayload['authPassword'] = authPassword; } if (typeof secret !== 'undefined') { - payload['secret'] = secret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** - * Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project. + * Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project. * * @param {string} params.webhookId - Webhook ID. * @throws {AppwriteException} @@ -203,7 +265,7 @@ export class Webhooks { */ get(params: { webhookId: string }): Promise; /** - * Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project. + * Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project. * * @param {string} webhookId - Webhook ID. * @throws {AppwriteException} @@ -212,39 +274,41 @@ export class Webhooks { */ get(webhookId: string): Promise; get( - paramsOrFirst: { webhookId: string } | string + paramsOrFirst: { webhookId: string } | string, ): Promise { let params: { webhookId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { webhookId: string }; } else { params = { - webhookId: paramsOrFirst as string + webhookId: paramsOrFirst as string, }; } - - const webhookId = params.webhookId; + const webhookId = params.webhookId; if (typeof webhookId === 'undefined') { - throw new AppwriteException('Missing required parameter: "webhookId"'); + throw new AppwriteException( + 'Missing required parameter: "webhookId"', + ); } - - const apiPath = '/webhooks/{webhookId}'.replace('{webhookId}', encodeURIComponent(String(webhookId))); - const payload: Payload = {}; + const apiPath = '/webhooks/{webhookId}'.replace( + '{webhookId}', + encodeURIComponent(String(webhookId)), + ); + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -261,7 +325,16 @@ export class Webhooks { * @throws {AppwriteException} * @returns {Promise} */ - update(params: { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string }): Promise; + update(params: { + webhookId: string; + name: string; + url: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + }): Promise; /** * Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook. * @@ -277,15 +350,65 @@ export class Webhooks { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(webhookId: string, name: string, url: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string): Promise; update( - paramsOrFirst: { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (string)?, (string)?] + webhookId: string, + name: string, + url: string, + events: string[], + enabled?: boolean, + tls?: boolean, + authUsername?: string, + authPassword?: string, + ): Promise; + update( + paramsOrFirst: + | { + webhookId: string; + name: string; + url: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + } + | string, + ...rest: [ + string?, + string?, + string[]?, + boolean?, + boolean?, + string?, + string?, + ] ): Promise { - let params: { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string }; + let params: { + webhookId: string; + name: string; + url: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + webhookId: string; + name: string; + url: string; + events: string[]; + enabled?: boolean; + tls?: boolean; + authUsername?: string; + authPassword?: string; + }; } else { params = { webhookId: paramsOrFirst as string, @@ -295,10 +418,10 @@ export class Webhooks { enabled: rest[3] as boolean, tls: rest[4] as boolean, authUsername: rest[5] as string, - authPassword: rest[6] as string + authPassword: rest[6] as string, }; } - + const webhookId = params.webhookId; const name = params.name; const url = params.url; @@ -307,9 +430,10 @@ export class Webhooks { const tls = params.tls; const authUsername = params.authUsername; const authPassword = params.authPassword; - if (typeof webhookId === 'undefined') { - throw new AppwriteException('Missing required parameter: "webhookId"'); + throw new AppwriteException( + 'Missing required parameter: "webhookId"', + ); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); @@ -320,48 +444,45 @@ export class Webhooks { if (typeof events === 'undefined') { throw new AppwriteException('Missing required parameter: "events"'); } - - const apiPath = '/webhooks/{webhookId}'.replace('{webhookId}', encodeURIComponent(String(webhookId))); - const payload: Payload = {}; + const apiPath = '/webhooks/{webhookId}'.replace( + '{webhookId}', + encodeURIComponent(String(webhookId)), + ); + const apiPayload: Payload = {}; if (typeof name !== 'undefined') { - payload['name'] = name; + apiPayload['name'] = name; } if (typeof url !== 'undefined') { - payload['url'] = url; + apiPayload['url'] = url; } if (typeof events !== 'undefined') { - payload['events'] = events; + apiPayload['events'] = events; } if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + apiPayload['enabled'] = enabled; } if (typeof tls !== 'undefined') { - payload['tls'] = tls; + apiPayload['tls'] = tls; } if (typeof authUsername !== 'undefined') { - payload['authUsername'] = authUsername; + apiPayload['authUsername'] = authUsername; } if (typeof authPassword !== 'undefined') { - payload['authPassword'] = authPassword; + apiPayload['authPassword'] = authPassword; } 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', - } + accept: 'application/json', + }; - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** - * Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events. + * Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events. * * @param {string} params.webhookId - Webhook ID. * @throws {AppwriteException} @@ -369,7 +490,7 @@ export class Webhooks { */ delete(params: { webhookId: string }): Promise<{}>; /** - * Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events. + * Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events. * * @param {string} webhookId - Webhook ID. * @throws {AppwriteException} @@ -377,40 +498,40 @@ export class Webhooks { * @deprecated Use the object parameter style method for a better developer experience. */ delete(webhookId: string): Promise<{}>; - delete( - paramsOrFirst: { webhookId: string } | string - ): Promise<{}> { + delete(paramsOrFirst: { webhookId: string } | string): Promise<{}> { let params: { webhookId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { params = (paramsOrFirst || {}) as { webhookId: string }; } else { params = { - webhookId: paramsOrFirst as string + webhookId: paramsOrFirst as string, }; } - - const webhookId = params.webhookId; + const webhookId = params.webhookId; if (typeof webhookId === 'undefined') { - throw new AppwriteException('Missing required parameter: "webhookId"'); + throw new AppwriteException( + 'Missing required parameter: "webhookId"', + ); } - - const apiPath = '/webhooks/{webhookId}'.replace('{webhookId}', encodeURIComponent(String(webhookId))); - const payload: Payload = {}; + const apiPath = '/webhooks/{webhookId}'.replace( + '{webhookId}', + encodeURIComponent(String(webhookId)), + ); + 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', - } + }; - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -421,7 +542,10 @@ export class Webhooks { * @throws {AppwriteException} * @returns {Promise} */ - updateSecret(params: { webhookId: string, secret?: string }): Promise; + updateSecret(params: { + webhookId: string; + secret?: string; + }): Promise; /** * Update the webhook signing key. This endpoint can be used to regenerate the signing key used to sign and validate payload deliveries for a specific webhook. * @@ -433,45 +557,50 @@ export class Webhooks { */ updateSecret(webhookId: string, secret?: string): Promise; updateSecret( - paramsOrFirst: { webhookId: string, secret?: string } | string, - ...rest: [(string)?] + paramsOrFirst: { webhookId: string; secret?: string } | string, + ...rest: [string?] ): Promise { - let params: { webhookId: string, secret?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { webhookId: string, secret?: string }; + let params: { webhookId: string; secret?: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + webhookId: string; + secret?: string; + }; } else { params = { webhookId: paramsOrFirst as string, - secret: rest[0] as string + secret: rest[0] as string, }; } - + const webhookId = params.webhookId; const secret = params.secret; - if (typeof webhookId === 'undefined') { - throw new AppwriteException('Missing required parameter: "webhookId"'); + throw new AppwriteException( + 'Missing required parameter: "webhookId"', + ); } - - const apiPath = '/webhooks/{webhookId}/secret'.replace('{webhookId}', encodeURIComponent(String(webhookId))); - const payload: Payload = {}; + const apiPath = '/webhooks/{webhookId}/secret'.replace( + '{webhookId}', + encodeURIComponent(String(webhookId)), + ); + const apiPayload: Payload = {}; if (typeof secret !== 'undefined') { - payload['secret'] = secret; + 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', - } + accept: 'application/json', + }; - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); + return this.client.call('patch', uri, apiHeaders, apiPayload); } } diff --git a/test/client.test.js b/test/client.test.js index 0e10914e..c13af6c4 100644 --- a/test/client.test.js +++ b/test/client.test.js @@ -1,32 +1,43 @@ -const { Client } = require("../dist/client"); -const { fetch: mockedFetch, Response, Dispatcher } = require("undici"); +const { Client } = require('../dist/client'); +const { fetch: mockedFetch, Response, Dispatcher } = require('undici'); -jest.mock("undici", () => ({ ...jest.requireActual("undici"), fetch: jest.fn() })); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); -describe("Client", () => { +describe('Client', () => { beforeEach(() => { mockedFetch.mockReset(); mockedFetch.mockImplementation(() => Response.json({ ok: true })); }); - test("does not include a dispatcher by default", async () => { + test('does not include a dispatcher by default', async () => { const client = new Client(); - await client.call("GET", new URL("https://cloud.appwrite.io/v1/health")); + await client.call( + 'GET', + new URL('https://cloud.appwrite.io/v1/health'), + ); expect(mockedFetch).toHaveBeenCalledTimes(1); - expect(mockedFetch.mock.calls[0][1]).not.toHaveProperty("dispatcher"); + expect(mockedFetch.mock.calls[0][1]).not.toHaveProperty('dispatcher'); }); - test("includes a dispatcher for self-signed requests", async () => { + test('includes a dispatcher for self-signed requests', async () => { const client = new Client(); client.setSelfSigned(true); try { - await client.call("GET", new URL("https://self-hosted.example/v1/health")); + await client.call( + 'GET', + new URL('https://self-hosted.example/v1/health'), + ); expect(mockedFetch).toHaveBeenCalledTimes(1); - expect(mockedFetch.mock.calls[0][1].dispatcher).toBeInstanceOf(Dispatcher); + expect(mockedFetch.mock.calls[0][1].dispatcher).toBeInstanceOf( + Dispatcher, + ); } finally { client.setSelfSigned(false); } diff --git a/test/id.test.js b/test/id.test.js index 0a648bc1..5b3305d8 100644 --- a/test/id.test.js +++ b/test/id.test.js @@ -1,6 +1,6 @@ -const { ID } = require("../dist/id"); +const { ID } = require('../dist/id'); -describe("ID", () => { +describe('ID', () => { test('unique', () => expect(ID.unique()).toHaveLength(20)); test('custom', () => expect(ID.custom('custom')).toEqual('custom')); }); diff --git a/test/operator.test.js b/test/operator.test.js index a14910cd..fde8923d 100644 --- a/test/operator.test.js +++ b/test/operator.test.js @@ -1,99 +1,139 @@ -const { Condition, Operator } = require("../dist/operator"); +const { Condition, Operator } = require('../dist/operator'); describe('Operator', () => { - test('returns increment', () => { - expect(Operator.increment(1)).toEqual(`{"method":"increment","values":[1]}`); - }); - - test('returns increment with max', () => { - expect(Operator.increment(5, 100)).toEqual(`{"method":"increment","values":[5,100]}`); - }); - - test('returns decrement', () => { - expect(Operator.decrement(1)).toEqual(`{"method":"decrement","values":[1]}`); - }); - - test('returns decrement with min', () => { - expect(Operator.decrement(3, 0)).toEqual(`{"method":"decrement","values":[3,0]}`); - }); - - test('returns multiply', () => { - expect(Operator.multiply(2)).toEqual(`{"method":"multiply","values":[2]}`); - }); - - test('returns multiply with max', () => { - expect(Operator.multiply(3, 1000)).toEqual(`{"method":"multiply","values":[3,1000]}`); - }); - - test('returns divide', () => { - expect(Operator.divide(2)).toEqual(`{"method":"divide","values":[2]}`); - }); - - test('returns divide with min', () => { - expect(Operator.divide(4, 1)).toEqual(`{"method":"divide","values":[4,1]}`); - }); - - test('returns modulo', () => { - expect(Operator.modulo(5)).toEqual(`{"method":"modulo","values":[5]}`); - }); - - test('returns power', () => { - expect(Operator.power(2)).toEqual(`{"method":"power","values":[2]}`); - }); - - test('returns arrayAppend', () => { - expect(Operator.arrayAppend(['item1', 'item2'])).toEqual('{"method":"arrayAppend","values":["item1","item2"]}'); - }); - - test('returns arrayPrepend', () => { - expect(Operator.arrayPrepend(['first', 'second'])).toEqual('{"method":"arrayPrepend","values":["first","second"]}'); - }); - - test('returns arrayInsert', () => { - expect(Operator.arrayInsert(0, 'newItem')).toEqual('{"method":"arrayInsert","values":[0,"newItem"]}'); - }); - - test('returns arrayRemove', () => { - expect(Operator.arrayRemove('oldItem')).toEqual('{"method":"arrayRemove","values":["oldItem"]}'); - }); - - test('returns arrayUnique', () => { - expect(Operator.arrayUnique()).toEqual('{"method":"arrayUnique","values":[]}'); - }); - - test('returns arrayIntersect', () => { - expect(Operator.arrayIntersect(['a', 'b', 'c'])).toEqual('{"method":"arrayIntersect","values":["a","b","c"]}'); - }); - - test('returns arrayDiff', () => { - expect(Operator.arrayDiff(['x', 'y'])).toEqual('{"method":"arrayDiff","values":["x","y"]}'); - }); - - test('returns arrayFilter', () => { - expect(Operator.arrayFilter(Condition.Equal, 'test')).toEqual('{"method":"arrayFilter","values":["equal","test"]}'); - }); - - test('returns stringConcat', () => { - expect(Operator.stringConcat('suffix')).toEqual('{"method":"stringConcat","values":["suffix"]}'); - }); - - test('returns stringReplace', () => { - expect(Operator.stringReplace('old', 'new')).toEqual('{"method":"stringReplace","values":["old","new"]}'); - }); - - test('returns toggle', () => { - expect(Operator.toggle()).toEqual('{"method":"toggle","values":[]}'); - }); - - test('returns dateAddDays', () => { - expect(Operator.dateAddDays(7)).toEqual('{"method":"dateAddDays","values":[7]}'); - }); - - test('returns dateSubDays', () => { - expect(Operator.dateSubDays(7)).toEqual('{"method":"dateSubDays","values":[7]}'); - }); - - test('returns dateSetNow', () => { - expect(Operator.dateSetNow()).toEqual('{"method":"dateSetNow","values":[]}'); - }); + test('returns increment', () => { + expect(Operator.increment(1)).toEqual( + `{"method":"increment","values":[1]}`, + ); + }); + + test('returns increment with max', () => { + expect(Operator.increment(5, 100)).toEqual( + `{"method":"increment","values":[5,100]}`, + ); + }); + + test('returns decrement', () => { + expect(Operator.decrement(1)).toEqual( + `{"method":"decrement","values":[1]}`, + ); + }); + + test('returns decrement with min', () => { + expect(Operator.decrement(3, 0)).toEqual( + `{"method":"decrement","values":[3,0]}`, + ); + }); + + test('returns multiply', () => { + expect(Operator.multiply(2)).toEqual( + `{"method":"multiply","values":[2]}`, + ); + }); + + test('returns multiply with max', () => { + expect(Operator.multiply(3, 1000)).toEqual( + `{"method":"multiply","values":[3,1000]}`, + ); + }); + + test('returns divide', () => { + expect(Operator.divide(2)).toEqual(`{"method":"divide","values":[2]}`); + }); + + test('returns divide with min', () => { + expect(Operator.divide(4, 1)).toEqual( + `{"method":"divide","values":[4,1]}`, + ); + }); + + test('returns modulo', () => { + expect(Operator.modulo(5)).toEqual(`{"method":"modulo","values":[5]}`); + }); + + test('returns power', () => { + expect(Operator.power(2)).toEqual(`{"method":"power","values":[2]}`); + }); + + test('returns arrayAppend', () => { + expect(Operator.arrayAppend(['item1', 'item2'])).toEqual( + '{"method":"arrayAppend","values":["item1","item2"]}', + ); + }); + + test('returns arrayPrepend', () => { + expect(Operator.arrayPrepend(['first', 'second'])).toEqual( + '{"method":"arrayPrepend","values":["first","second"]}', + ); + }); + + test('returns arrayInsert', () => { + expect(Operator.arrayInsert(0, 'newItem')).toEqual( + '{"method":"arrayInsert","values":[0,"newItem"]}', + ); + }); + + test('returns arrayRemove', () => { + expect(Operator.arrayRemove('oldItem')).toEqual( + '{"method":"arrayRemove","values":["oldItem"]}', + ); + }); + + test('returns arrayUnique', () => { + expect(Operator.arrayUnique()).toEqual( + '{"method":"arrayUnique","values":[]}', + ); + }); + + test('returns arrayIntersect', () => { + expect(Operator.arrayIntersect(['a', 'b', 'c'])).toEqual( + '{"method":"arrayIntersect","values":["a","b","c"]}', + ); + }); + + test('returns arrayDiff', () => { + expect(Operator.arrayDiff(['x', 'y'])).toEqual( + '{"method":"arrayDiff","values":["x","y"]}', + ); + }); + + test('returns arrayFilter', () => { + expect(Operator.arrayFilter(Condition.Equal, 'test')).toEqual( + '{"method":"arrayFilter","values":["equal","test"]}', + ); + }); + + test('returns stringConcat', () => { + expect(Operator.stringConcat('suffix')).toEqual( + '{"method":"stringConcat","values":["suffix"]}', + ); + }); + + test('returns stringReplace', () => { + expect(Operator.stringReplace('old', 'new')).toEqual( + '{"method":"stringReplace","values":["old","new"]}', + ); + }); + + test('returns toggle', () => { + expect(Operator.toggle()).toEqual('{"method":"toggle","values":[]}'); + }); + + test('returns dateAddDays', () => { + expect(Operator.dateAddDays(7)).toEqual( + '{"method":"dateAddDays","values":[7]}', + ); + }); + + test('returns dateSubDays', () => { + expect(Operator.dateSubDays(7)).toEqual( + '{"method":"dateSubDays","values":[7]}', + ); + }); + + test('returns dateSetNow', () => { + expect(Operator.dateSetNow()).toEqual( + '{"method":"dateSetNow","values":[]}', + ); + }); }); diff --git a/test/permission.test.js b/test/permission.test.js index 7f972d3b..891ee166 100644 --- a/test/permission.test.js +++ b/test/permission.test.js @@ -1,10 +1,15 @@ -const { Permission } = require("../dist/permission"); -const { Role } = require("../dist/role"); +const { Permission } = require('../dist/permission'); +const { Role } = require('../dist/role'); describe('Permission', () => { - test('read', () => expect(Permission.read(Role.any())).toEqual('read("any")')); - test('write', () => expect(Permission.write(Role.any())).toEqual('write("any")')); - test('create', () => expect(Permission.create(Role.any())).toEqual('create("any")')); - test('update', () => expect(Permission.update(Role.any())).toEqual('update("any")')); - test('delete', () => expect(Permission.delete(Role.any())).toEqual('delete("any")')); -}) + test('read', () => + expect(Permission.read(Role.any())).toEqual('read("any")')); + test('write', () => + expect(Permission.write(Role.any())).toEqual('write("any")')); + test('create', () => + expect(Permission.create(Role.any())).toEqual('create("any")')); + test('update', () => + expect(Permission.update(Role.any())).toEqual('update("any")')); + test('delete', () => + expect(Permission.delete(Role.any())).toEqual('delete("any")')); +}); diff --git a/test/query.test.js b/test/query.test.js index e539a1f6..52e9490c 100644 --- a/test/query.test.js +++ b/test/query.test.js @@ -1,155 +1,157 @@ -const { Query } = require("../dist/query"); +const { Query } = require('../dist/query'); const tests = [ { description: 'with a string', value: 's', - expectedValues: '["s"]' + expectedValues: '["s"]', }, { description: 'with a integer', value: 1, - expectedValues: '[1]' + expectedValues: '[1]', }, { description: 'with a double', value: 1.2, - expectedValues: '[1.2]' + expectedValues: '[1.2]', }, { description: 'with a whole number double', value: 1.0, - expectedValues: '[1]' + expectedValues: '[1]', }, { description: 'with a bool', value: false, - expectedValues: '[false]' + expectedValues: '[false]', }, { description: 'with a list', value: ['a', 'b', 'c'], - expectedValues: '["a","b","c"]' - } + expectedValues: '["a","b","c"]', + }, ]; describe('Query', () => { describe('basic filter equal', () => { for (const t of tests) { test(t.description, () => - expect(Query.equal("attr", t.value)) - .toEqual(`{"method":"equal","attribute":"attr","values":${t.expectedValues}}`) - ) + expect(Query.equal('attr', t.value)).toEqual( + `{"method":"equal","attribute":"attr","values":${t.expectedValues}}`, + ), + ); } - }) + }); describe('basic filter notEqual', () => { for (const t of tests) { test(t.description, () => - expect(Query.notEqual("attr", t.value)) - .toEqual(`{"method":"notEqual","attribute":"attr","values":${t.expectedValues}}`) - ) + expect(Query.notEqual('attr', t.value)).toEqual( + `{"method":"notEqual","attribute":"attr","values":${t.expectedValues}}`, + ), + ); } }); describe('basic filter lessThan', () => { for (const t of tests) { test(t.description, () => - expect(Query.lessThan("attr", t.value)) - .toEqual(`{"method":"lessThan","attribute":"attr","values":${t.expectedValues}}`) - ) + expect(Query.lessThan('attr', t.value)).toEqual( + `{"method":"lessThan","attribute":"attr","values":${t.expectedValues}}`, + ), + ); } }); describe('basic filter lessThanEqual', () => { for (const t of tests) { test(t.description, () => - expect(Query.lessThanEqual("attr", t.value)) - .toEqual(`{"method":"lessThanEqual","attribute":"attr","values":${t.expectedValues}}`) - ) + expect(Query.lessThanEqual('attr', t.value)).toEqual( + `{"method":"lessThanEqual","attribute":"attr","values":${t.expectedValues}}`, + ), + ); } }); describe('basic filter greaterThan', () => { for (const t of tests) { test(t.description, () => - expect(Query.greaterThan("attr", t.value)) - .toEqual(`{"method":"greaterThan","attribute":"attr","values":${t.expectedValues}}`) - ) + expect(Query.greaterThan('attr', t.value)).toEqual( + `{"method":"greaterThan","attribute":"attr","values":${t.expectedValues}}`, + ), + ); } }); describe('basic filter greaterThanEqual', () => { for (const t of tests) { test(t.description, () => - expect(Query.greaterThanEqual("attr", t.value)) - .toEqual(`{"method":"greaterThanEqual","attribute":"attr","values":${t.expectedValues}}`) - ) + expect(Query.greaterThanEqual('attr', t.value)).toEqual( + `{"method":"greaterThanEqual","attribute":"attr","values":${t.expectedValues}}`, + ), + ); } }); test('search', () => - expect(Query.search('attr', 'keyword1 keyword2')) - .toEqual(`{"method":"search","attribute":"attr","values":["keyword1 keyword2"]}`) - ); + expect(Query.search('attr', 'keyword1 keyword2')).toEqual( + `{"method":"search","attribute":"attr","values":["keyword1 keyword2"]}`, + )); test('isNull', () => - expect(Query.isNull('attr')) - .toEqual(`{"method":"isNull","attribute":"attr"}`) - ); + expect(Query.isNull('attr')).toEqual( + `{"method":"isNull","attribute":"attr"}`, + )); test('isNotNull', () => - expect(Query.isNotNull('attr')) - .toEqual(`{"method":"isNotNull","attribute":"attr"}`) - ); + expect(Query.isNotNull('attr')).toEqual( + `{"method":"isNotNull","attribute":"attr"}`, + )); describe('between', () => { test('with integers', () => - expect(Query.between('attr', 1, 2)) - .toEqual(`{"method":"between","attribute":"attr","values":[1,2]}`) - ); + expect(Query.between('attr', 1, 2)).toEqual( + `{"method":"between","attribute":"attr","values":[1,2]}`, + )); test('with doubles', () => - expect(Query.between('attr', 1.2, 2.2)) - .toEqual(`{"method":"between","attribute":"attr","values":[1.2,2.2]}`) - ); + expect(Query.between('attr', 1.2, 2.2)).toEqual( + `{"method":"between","attribute":"attr","values":[1.2,2.2]}`, + )); test('with strings', () => - expect(Query.between('attr',"a","z")) - .toEqual(`{"method":"between","attribute":"attr","values":["a","z"]}`) - ); + expect(Query.between('attr', 'a', 'z')).toEqual( + `{"method":"between","attribute":"attr","values":["a","z"]}`, + )); }); test('select', () => - expect(Query.select(['attr1', 'attr2'])) - .toEqual(`{"method":"select","values":["attr1","attr2"]}`) - ); + expect(Query.select(['attr1', 'attr2'])).toEqual( + `{"method":"select","values":["attr1","attr2"]}`, + )); test('orderAsc', () => - expect(Query.orderAsc('attr')) - .toEqual(`{"method":"orderAsc","attribute":"attr"}`) - ); + expect(Query.orderAsc('attr')).toEqual( + `{"method":"orderAsc","attribute":"attr"}`, + )); test('orderDesc', () => - expect(Query.orderDesc('attr')) - .toEqual(`{"method":"orderDesc","attribute":"attr"}`) - ); + expect(Query.orderDesc('attr')).toEqual( + `{"method":"orderDesc","attribute":"attr"}`, + )); test('cursorBefore', () => - expect(Query.cursorBefore('attr')) - .toEqual('{"method":"cursorBefore","values":["attr"]}') - ); + expect(Query.cursorBefore('attr')).toEqual( + '{"method":"cursorBefore","values":["attr"]}', + )); test('cursorAfter', () => - expect(Query.cursorAfter('attr')) - .toEqual('{"method":"cursorAfter","values":["attr"]}') - ); + expect(Query.cursorAfter('attr')).toEqual( + '{"method":"cursorAfter","values":["attr"]}', + )); test('limit', () => - expect(Query.limit(1)) - .toEqual('{"method":"limit","values":[1]}') - ); + expect(Query.limit(1)).toEqual('{"method":"limit","values":[1]}')); test('offset', () => - expect(Query.offset(1)) - .toEqual('{"method":"offset","values":[1]}') - ); -}) + expect(Query.offset(1)).toEqual('{"method":"offset","values":[1]}')); +}); diff --git a/test/role.test.js b/test/role.test.js index 8f7420bd..827c8452 100644 --- a/test/role.test.js +++ b/test/role.test.js @@ -1,14 +1,22 @@ -const { Role } = require("../dist/role"); +const { Role } = require('../dist/role'); describe('Role', () => { test('any', () => expect(Role.any()).toEqual('any')); - test('user without status', () => expect(Role.user('custom')).toEqual('user:custom')); - test('user with status', () => expect(Role.user('custom', 'verified')).toEqual('user:custom/verified')); + test('user without status', () => + expect(Role.user('custom')).toEqual('user:custom')); + test('user with status', () => + expect(Role.user('custom', 'verified')).toEqual( + 'user:custom/verified', + )); test('users without status', () => expect(Role.users()).toEqual('users')); - test('users with status', () => expect(Role.users('verified')).toEqual('users/verified')); + test('users with status', () => + expect(Role.users('verified')).toEqual('users/verified')); test('guests', () => expect(Role.guests()).toEqual('guests')); - test('team without role', () => expect(Role.team('custom')).toEqual('team:custom')) - test('team with role', () => expect(Role.team('custom', 'owner')).toEqual('team:custom/owner')) - test('member', () => expect(Role.member('custom')).toEqual('member:custom')) - test('label', () => expect(Role.label('admin')).toEqual('label:admin')) -}) + test('team without role', () => + expect(Role.team('custom')).toEqual('team:custom')); + test('team with role', () => + expect(Role.team('custom', 'owner')).toEqual('team:custom/owner')); + test('member', () => + expect(Role.member('custom')).toEqual('member:custom')); + test('label', () => expect(Role.label('admin')).toEqual('label:admin')); +}); diff --git a/test/services/account.test.js b/test/services/account.test.js index 09473055..3f7f45e7 100644 --- a/test/services/account.test.js +++ b/test/services/account.test.js @@ -1,64 +1,63 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Account } = require("../../dist/services/account"); +const { Client } = require('../../dist/client'); +const { Account } = require('../../dist/services/account'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Account', () => { const client = new Client(); const account = new Account(client); - 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', - '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',}; + 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 account.get( - ); + const response = await account.get(); // 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', - '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',}; + 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 account.create( '', 'email@example.com', @@ -70,91 +69,80 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method listConsents()', async () => { - const data = { - 'total': 5, - 'consents': [],}; + const data = { + total: 5, + consents: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.listConsents( - ); + const response = await account.listConsents(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getConsent()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'appId': '5e5ea5c16897e', - 'cimdUrl': 'https://example.com/.well-known/client-metadata.json', - 'scopes': [], - 'resources': [], - 'authorizationDetails': '[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]', - 'expire': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c16897e', + appId: '5e5ea5c16897e', + cimdUrl: 'https://example.com/.well-known/client-metadata.json', + scopes: [], + resources: [], + authorizationDetails: + '[{\\"type\\":\\"calendar\\",\\"identifier\\":\\"primary\\",\\"actions\\":[\\"read_events\\",\\"create_event\\"]}]', + expire: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.getConsent( - '', - ); + const response = await account.getConsent(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteConsent()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.deleteConsent( - '', - ); + const response = await account.deleteConsent(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listConsentTokens()', async () => { - const data = { - 'total': 5, - 'tokens': [],}; + const data = { + total: 5, + tokens: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.listConsentTokens( - '', - ); + const response = await account.listConsentTokens(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getConsentToken()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'consentId': '5e5ea5c16897e', - 'userId': '5e5ea5c16897e', - 'appId': '5e5ea5c16897e', - 'cimdUrl': 'https://example.com/.well-known/client-metadata.json', - 'scopes': [], - 'resources': [], - 'authorizationDetails': '[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]', - 'expire': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + consentId: '5e5ea5c16897e', + userId: '5e5ea5c16897e', + appId: '5e5ea5c16897e', + cimdUrl: 'https://example.com/.well-known/client-metadata.json', + scopes: [], + resources: [], + authorizationDetails: + '[{\\"type\\":\\"calendar\\",\\"identifier\\":\\"primary\\",\\"actions\\":[\\"read_events\\",\\"create_event\\"]}]', + expire: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await account.getConsentToken( '', '', @@ -165,11 +153,9 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method deleteConsentToken()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await account.deleteConsentToken( '', '', @@ -180,27 +166,26 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method updateEmail()', 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',}; + 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 account.updateEmail( 'email@example.com', 'password', @@ -211,272 +196,232 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method listIdentities()', async () => { - const data = { - 'total': 5, - 'identities': [],}; + const data = { + total: 5, + identities: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.listIdentities( - ); + const response = await account.listIdentities(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteIdentity()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.deleteIdentity( - '', - ); + const response = await account.deleteIdentity(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listLogs()', async () => { - const data = { - 'total': 5, - 'logs': [],}; + const data = { + total: 5, + logs: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.listLogs( - ); + const response = await account.listLogs(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateMFA()', 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',}; + 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 account.updateMFA( - true, - ); + const response = await account.updateMFA(true); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createMfaAuthenticator()', async () => { - const data = { - 'secret': '[SHARED_SECRET]', - 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; + const data = { + secret: '[SHARED_SECRET]', + uri: 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.createMfaAuthenticator( - 'totp', - ); + const response = await account.createMfaAuthenticator('totp'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createMFAAuthenticator()', async () => { - const data = { - 'secret': '[SHARED_SECRET]', - 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; + const data = { + secret: '[SHARED_SECRET]', + uri: 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.createMFAAuthenticator( - 'totp', - ); + const response = await account.createMFAAuthenticator('totp'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateMfaAuthenticator()', 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',}; + 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 account.updateMfaAuthenticator( - 'totp', - '', - ); + const response = await account.updateMfaAuthenticator('totp', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateMFAAuthenticator()', 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',}; + 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 account.updateMFAAuthenticator( - 'totp', - '', - ); + const response = await account.updateMFAAuthenticator('totp', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteMfaAuthenticator()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.deleteMfaAuthenticator( - 'totp', - ); + const response = await account.deleteMfaAuthenticator('totp'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteMFAAuthenticator()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.deleteMFAAuthenticator( - 'totp', - ); + const response = await account.deleteMFAAuthenticator('totp'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createMfaChallenge()', async () => { - const data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': 'bb8ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c168bb8', + expire: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.createMfaChallenge( - 'email', - ); + const response = await account.createMfaChallenge('email'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createMFAChallenge()', async () => { - const data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': 'bb8ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c168bb8', + expire: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.createMFAChallenge( - 'email', - ); + const response = await account.createMFAChallenge('email'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateMfaChallenge()', 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',}; + 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.updateMfaChallenge( '', '', @@ -487,40 +432,39 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method updateMFAChallenge()', 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',}; + 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.updateMFAChallenge( '', '', @@ -531,271 +475,238 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method listMfaFactors()', async () => { - const data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true, - 'custom': true,}; + const data = { + totp: true, + phone: true, + email: true, + recoveryCode: true, + custom: true, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.listMfaFactors( - ); + const response = await account.listMfaFactors(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listMFAFactors()', async () => { - const data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true, - 'custom': true,}; + const data = { + totp: true, + phone: true, + email: true, + recoveryCode: true, + custom: true, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.listMFAFactors( - ); + const response = await account.listMFAFactors(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getMfaRecoveryCodes()', async () => { - const data = { - 'recoveryCodes': [],}; + const data = { + recoveryCodes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.getMfaRecoveryCodes( - ); + const response = await account.getMfaRecoveryCodes(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getMFARecoveryCodes()', async () => { - const data = { - 'recoveryCodes': [],}; + const data = { + recoveryCodes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.getMFARecoveryCodes( - ); + const response = await account.getMFARecoveryCodes(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createMfaRecoveryCodes()', async () => { - const data = { - 'recoveryCodes': [],}; + const data = { + recoveryCodes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.createMfaRecoveryCodes( - ); + const response = await account.createMfaRecoveryCodes(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createMFARecoveryCodes()', async () => { - const data = { - 'recoveryCodes': [],}; + const data = { + recoveryCodes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.createMFARecoveryCodes( - ); + const response = await account.createMFARecoveryCodes(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateMfaRecoveryCodes()', async () => { - const data = { - 'recoveryCodes': [],}; + const data = { + recoveryCodes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.updateMfaRecoveryCodes( - ); + const response = await account.updateMfaRecoveryCodes(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateMFARecoveryCodes()', async () => { - const data = { - 'recoveryCodes': [],}; + const data = { + recoveryCodes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.updateMFARecoveryCodes( - ); + const response = await account.updateMFARecoveryCodes(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateName()', 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',}; + 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 account.updateName( - '', - ); + const response = await account.updateName(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updatePassword()', 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',}; + 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 account.updatePassword( - 'password', - ); + const response = await account.updatePassword('password'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updatePhone()', 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',}; + 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 account.updatePhone( - '+12065550100', - 'password', - ); + const response = await account.updatePhone('+12065550100', 'password'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getPrefs()', async () => { - const data = {}; + const data = {}; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.getPrefs( - ); + const response = await account.getPrefs(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updatePrefs()', 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',}; + 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 account.updatePrefs( - {}, - ); + const response = await account.updatePrefs({}); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createRecovery()', 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',}; + 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.createRecovery( 'email@example.com', 'https://example.com', @@ -806,17 +717,16 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method updateRecovery()', 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',}; + 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.updateRecovery( '', '', @@ -828,110 +738,102 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method listSessions()', async () => { - const data = { - 'total': 5, - 'sessions': [],}; + const data = { + total: 5, + sessions: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.listSessions( - ); + const response = await account.listSessions(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteSessions()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.deleteSessions( - ); + const response = await account.deleteSessions(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createAnonymousSession()', 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',}; + 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.createAnonymousSession( - ); + const response = await account.createAnonymousSession(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createEmailPasswordSession()', 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',}; + 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.createEmailPasswordSession( 'email@example.com', 'password', @@ -942,40 +844,39 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method updateMagicURLSession()', 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',}; + 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.updateMagicURLSession( '', '', @@ -986,40 +887,39 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method updatePhoneSession()', 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',}; + 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.updatePhoneSession( '', '', @@ -1030,190 +930,173 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method createSession()', 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',}; + 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.createSession( - '', - '', - ); + const response = await account.createSession('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getSession()', 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',}; + 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.getSession( - '', - ); + const response = await account.getSession(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateSession()', 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',}; + 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.updateSession( - '', - ); + const response = await account.updateSession(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteSession()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await account.deleteSession( - '', - ); + const response = await account.deleteSession(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateStatus()', 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',}; + 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 account.updateStatus( - ); + const response = await account.updateStatus(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createEmailToken()', 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',}; + 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.createEmailToken( '', 'email@example.com', @@ -1224,17 +1107,16 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method createMagicURLToken()', 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',}; + 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.createMagicURLToken( '', 'email@example.com', @@ -1245,31 +1127,26 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method createOAuth2Token()', async () => { const data = 'https://example.com/'; mockedFetch.mockImplementation(() => Response.redirect(data)); - - const response = await account.createOAuth2Token( - 'amazon', - ); + const response = await account.createOAuth2Token('amazon'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createPhoneToken()', 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',}; + 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.createPhoneToken( '', '+12065550100', @@ -1280,17 +1157,16 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method createEmailVerification()', 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',}; + 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.createEmailVerification( 'https://example.com', ); @@ -1300,17 +1176,16 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method createVerification()', 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',}; + 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.createVerification( 'https://example.com', ); @@ -1320,17 +1195,16 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method updateEmailVerification()', 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',}; + 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.updateEmailVerification( '', '', @@ -1341,17 +1215,16 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method updateVerification()', 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',}; + 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.updateVerification( '', '', @@ -1362,36 +1235,33 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method createPhoneVerification()', 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',}; + 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.createPhoneVerification( - ); + const response = await account.createPhoneVerification(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updatePhoneVerification()', 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',}; + 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.updatePhoneVerification( '', '', @@ -1402,4 +1272,4 @@ describe('Account', () => { expect(response).toEqual(data); }); - }) +}); diff --git a/test/services/activities.test.js b/test/services/activities.test.js index 61bc5967..52700744 100644 --- a/test/services/activities.test.js +++ b/test/services/activities.test.js @@ -1,70 +1,68 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Activities } = require("../../dist/services/activities"); +const { Client } = require('../../dist/client'); +const { Activities } = require('../../dist/services/activities'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Activities', () => { const client = new Client(); const activities = new Activities(client); - test('test method listEvents()', async () => { - const data = { - 'total': 5, - 'events': [],}; + const data = { + total: 5, + events: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await activities.listEvents( - ); + const response = await activities.listEvents(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getEvent()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - 'actorType': 'user', - 'actorId': '610fc2f985ee0', - 'actorEmail': 'john@appwrite.io', - 'actorName': 'John Doe', - 'resourceParent': 'database/ID', - 'resourceType': 'collection', - 'resourceId': '610fc2f985ee0', - 'resource': 'collections/610fc2f985ee0', - 'event': 'account.sessions.create', - 'userAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36', - 'ip': '127.0.0.1', - 'mode': 'admin', - 'country': 'US', - 'continentCode': 'NA', - 'city': 'Mountain View', - 'subdivisions': 'California', - 'isp': 'Google', - 'autonomousSystemNumber': '15169', - 'autonomousSystemOrganization': 'GOOGLE', - 'connectionType': 'cable', - 'connectionUsageType': 'residential', - 'connectionOrganization': 'Google LLC', - 'time': '2020-10-15T06:38:00.000+00:00', - 'projectId': '610fc2f985ee0', - 'teamId': '610fc2f985ee0', - 'hostname': 'appwrite.io', - 'sdk': 'web', - 'sdkVersion': '14.0.0',}; + const data = { + '\\$id': '5e5ea5c16897e', + actorType: 'user', + actorId: '610fc2f985ee0', + actorEmail: 'john@appwrite.io', + actorName: 'John Doe', + resourceParent: 'database/ID', + resourceType: 'collection', + resourceId: '610fc2f985ee0', + resource: 'collections/610fc2f985ee0', + event: 'account.sessions.create', + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36', + ip: '127.0.0.1', + mode: 'admin', + country: 'US', + continentCode: 'NA', + city: 'Mountain View', + subdivisions: 'California', + isp: 'Google', + autonomousSystemNumber: '15169', + autonomousSystemOrganization: 'GOOGLE', + connectionType: 'cable', + connectionUsageType: 'residential', + connectionOrganization: 'Google LLC', + time: '2020-10-15T06:38:00.000+00:00', + projectId: '610fc2f985ee0', + teamId: '610fc2f985ee0', + hostname: 'appwrite.io', + sdk: 'web', + sdkVersion: '14.0.0', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await activities.getEvent( - '', - ); + const response = await activities.getEvent(''); // 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/advisor.test.js b/test/services/advisor.test.js index 401e34a5..777728a8 100644 --- a/test/services/advisor.test.js +++ b/test/services/advisor.test.js @@ -1,103 +1,93 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Advisor } = require("../../dist/services/advisor"); +const { Client } = require('../../dist/client'); +const { Advisor } = require('../../dist/services/advisor'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Advisor', () => { const client = new Client(); const advisor = new Advisor(client); - test('test method listReports()', async () => { - const data = { - 'total': 5, - 'reports': [],}; + const data = { + total: 5, + reports: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await advisor.listReports( - ); + const response = await advisor.listReports(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getReport()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'type': 'lighthouse', - 'title': 'Lighthouse audit for https://appwrite.io/', - 'summary': 'Performance score 78. 4 opportunities found.', - 'targetType': 'urls', - 'target': 'https://appwrite.io/', - 'categories': [], - 'insights': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + appId: '5e5ea5c16897e', + type: 'lighthouse', + title: 'Lighthouse audit for https://appwrite.io/', + summary: 'Performance score 78. 4 opportunities found.', + targetType: 'urls', + target: 'https://appwrite.io/', + categories: [], + insights: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await advisor.getReport( - '', - ); + const response = await advisor.getReport(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteReport()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await advisor.deleteReport( - '', - ); + const response = await advisor.deleteReport(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listInsights()', async () => { - const data = { - 'total': 5, - 'insights': [],}; + const data = { + total: 5, + insights: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await advisor.listInsights( - '', - ); + const response = await advisor.listInsights(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getInsight()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'reportId': '5e5ea5c16897e', - 'type': 'tablesDBIndex', - 'severity': 'warning', - 'status': 'active', - 'resourceType': 'databases', - 'resourceId': 'main', - 'parentResourceType': 'tables', - 'parentResourceId': 'orders', - 'title': 'Missing index on collection orders', - 'summary': 'Queries against `orders.status` are scanning the full collection.', - 'ctas': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + reportId: '5e5ea5c16897e', + type: 'tablesDBIndex', + severity: 'warning', + status: 'active', + resourceType: 'databases', + resourceId: 'main', + parentResourceType: 'tables', + parentResourceId: 'orders', + title: 'Missing index on collection orders', + summary: + 'Queries against `orders.status` are scanning the full collection.', + ctas: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await advisor.getInsight( '', '', @@ -108,4 +98,4 @@ describe('Advisor', () => { expect(response).toEqual(data); }); - }) +}); diff --git a/test/services/apps.test.js b/test/services/apps.test.js index 2026c43c..d79c42cc 100644 --- a/test/services/apps.test.js +++ b/test/services/apps.test.js @@ -1,226 +1,202 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Apps } = require("../../dist/services/apps"); +const { Client } = require('../../dist/client'); +const { Apps } = require('../../dist/services/apps'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Apps', () => { const client = new Client(); const apps = new Apps(client); - test('test method list()', async () => { - const data = { - 'total': 5, - 'apps': [],}; + const data = { + total: 5, + apps: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.list( - ); + const response = await apps.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', - 'name': 'My Application', - 'description': 'Connect your workspace to My Application.', - 'clientUri': 'https://example.com', - 'logoUri': 'https://example.com/logo.png', - 'privacyPolicyUrl': 'https://example.com/privacy', - 'termsUrl': 'https://example.com/terms', - 'contacts': [], - 'tagline': 'Automate your workspace.', - 'tags': [], - 'labels': [], - 'images': [], - 'supportUrl': 'https://example.com/support', - 'dataDeletionUrl': 'https://example.com/data-deletion', - 'redirectUris': [], - 'postLogoutRedirectUris': [], - 'enabled': true, - 'type': 'confidential', - 'deviceFlow': true, - 'teamId': '5e5ea5c16897e', - 'userId': '5e5ea5c16897e', - 'installationScopes': [], - 'installationRedirectUrl': 'https://example.com/setup', - 'secrets': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Application', + description: 'Connect your workspace to My Application.', + clientUri: 'https://example.com', + logoUri: 'https://example.com/logo.png', + privacyPolicyUrl: 'https://example.com/privacy', + termsUrl: 'https://example.com/terms', + contacts: [], + tagline: 'Automate your workspace.', + tags: [], + labels: [], + images: [], + supportUrl: 'https://example.com/support', + dataDeletionUrl: 'https://example.com/data-deletion', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: true, + teamId: '5e5ea5c16897e', + userId: '5e5ea5c16897e', + installationScopes: [], + installationRedirectUrl: 'https://example.com/setup', + secrets: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.create( - '', - '', - [], - ); + const response = await apps.create('', '', []); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listInstallationScopes()', async () => { - const data = { - 'total': 5, - 'scopes': [],}; + const data = { + total: 5, + scopes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.listInstallationScopes( - ); + const response = await apps.listInstallationScopes(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listOAuth2Scopes()', async () => { - const data = { - 'total': 5, - 'scopes': [],}; + const data = { + total: 5, + scopes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.listOAuth2Scopes( - ); + const response = await apps.listOAuth2Scopes(); // 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', - 'name': 'My Application', - 'description': 'Connect your workspace to My Application.', - 'clientUri': 'https://example.com', - 'logoUri': 'https://example.com/logo.png', - 'privacyPolicyUrl': 'https://example.com/privacy', - 'termsUrl': 'https://example.com/terms', - 'contacts': [], - 'tagline': 'Automate your workspace.', - 'tags': [], - 'labels': [], - 'images': [], - 'supportUrl': 'https://example.com/support', - 'dataDeletionUrl': 'https://example.com/data-deletion', - 'redirectUris': [], - 'postLogoutRedirectUris': [], - 'enabled': true, - 'type': 'confidential', - 'deviceFlow': true, - 'teamId': '5e5ea5c16897e', - 'userId': '5e5ea5c16897e', - 'installationScopes': [], - 'installationRedirectUrl': 'https://example.com/setup', - 'secrets': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Application', + description: 'Connect your workspace to My Application.', + clientUri: 'https://example.com', + logoUri: 'https://example.com/logo.png', + privacyPolicyUrl: 'https://example.com/privacy', + termsUrl: 'https://example.com/terms', + contacts: [], + tagline: 'Automate your workspace.', + tags: [], + labels: [], + images: [], + supportUrl: 'https://example.com/support', + dataDeletionUrl: 'https://example.com/data-deletion', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: true, + teamId: '5e5ea5c16897e', + userId: '5e5ea5c16897e', + installationScopes: [], + installationRedirectUrl: 'https://example.com/setup', + secrets: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.get( - '', - ); + const response = await apps.get(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method update()', 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 Application', - 'description': 'Connect your workspace to My Application.', - 'clientUri': 'https://example.com', - 'logoUri': 'https://example.com/logo.png', - 'privacyPolicyUrl': 'https://example.com/privacy', - 'termsUrl': 'https://example.com/terms', - 'contacts': [], - 'tagline': 'Automate your workspace.', - 'tags': [], - 'labels': [], - 'images': [], - 'supportUrl': 'https://example.com/support', - 'dataDeletionUrl': 'https://example.com/data-deletion', - 'redirectUris': [], - 'postLogoutRedirectUris': [], - 'enabled': true, - 'type': 'confidential', - 'deviceFlow': true, - 'teamId': '5e5ea5c16897e', - 'userId': '5e5ea5c16897e', - 'installationScopes': [], - 'installationRedirectUrl': 'https://example.com/setup', - 'secrets': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Application', + description: 'Connect your workspace to My Application.', + clientUri: 'https://example.com', + logoUri: 'https://example.com/logo.png', + privacyPolicyUrl: 'https://example.com/privacy', + termsUrl: 'https://example.com/terms', + contacts: [], + tagline: 'Automate your workspace.', + tags: [], + labels: [], + images: [], + supportUrl: 'https://example.com/support', + dataDeletionUrl: 'https://example.com/data-deletion', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: true, + teamId: '5e5ea5c16897e', + userId: '5e5ea5c16897e', + installationScopes: [], + installationRedirectUrl: 'https://example.com/setup', + secrets: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.update( - '', - '', - ); + const response = await apps.update('', ''); // 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: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.delete( - '', - ); + const response = await apps.delete(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listInstallations()', async () => { - const data = { - 'total': 5, - 'installations': [],}; + const data = { + total: 5, + installations: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.listInstallations( - '', - ); + const response = await apps.listInstallations(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getInstallation()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'teamId': '5e5ea5c16897e', - 'scopes': [], - 'authorizationDetails': {}, - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + appId: '5e5ea5c16897e', + teamId: '5e5ea5c16897e', + scopes: [], + authorizationDetails: [], + createdById: '5e5ea5c16897e', + createdByName: 'Walter White', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await apps.getInstallation( '', '', @@ -231,11 +207,9 @@ describe('Apps', () => { expect(response).toEqual(data); }); - test('test method deleteInstallation()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await apps.deleteInstallation( '', '', @@ -246,16 +220,15 @@ describe('Apps', () => { expect(response).toEqual(data); }); - test('test method createInstallationToken()', async () => { - const data = { - 'access_token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...', - 'token_type': 'Bearer', - 'expires_in': 3600, - 'refresh_token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...', - 'scope': 'openid email profile',}; + const data = { + access_token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...', + token_type: 'Bearer', + expires_in: 3600, + refresh_token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...', + scope: 'openid email profile', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await apps.createInstallationToken( '', '', @@ -266,252 +239,210 @@ describe('Apps', () => { expect(response).toEqual(data); }); - test('test method listKeys()', async () => { - const data = { - 'total': 5, - 'keys': [],}; + const data = { + total: 5, + keys: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.listKeys( - '', - ); + const response = await apps.listKeys(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createKey()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'secret': '5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a', - 'hint': 'f5c6c7', - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + appId: '5e5ea5c16897e', + secret: '5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a', + hint: 'f5c6c7', + createdById: '5e5ea5c16897e', + createdByName: 'Walter White', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.createKey( - '', - ); + const response = await apps.createKey(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getKey()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'secret': '5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a', - 'hint': 'f5c6c7', - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + appId: '5e5ea5c16897e', + secret: '5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a', + hint: 'f5c6c7', + createdById: '5e5ea5c16897e', + createdByName: 'Walter White', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.getKey( - '', - '', - ); + const response = await apps.getKey('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteKey()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.deleteKey( - '', - '', - ); + const response = await apps.deleteKey('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateLabels()', 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 Application', - 'description': 'Connect your workspace to My Application.', - 'clientUri': 'https://example.com', - 'logoUri': 'https://example.com/logo.png', - 'privacyPolicyUrl': 'https://example.com/privacy', - 'termsUrl': 'https://example.com/terms', - 'contacts': [], - 'tagline': 'Automate your workspace.', - 'tags': [], - 'labels': [], - 'images': [], - 'supportUrl': 'https://example.com/support', - 'dataDeletionUrl': 'https://example.com/data-deletion', - 'redirectUris': [], - 'postLogoutRedirectUris': [], - 'enabled': true, - 'type': 'confidential', - 'deviceFlow': true, - 'teamId': '5e5ea5c16897e', - 'userId': '5e5ea5c16897e', - 'installationScopes': [], - 'installationRedirectUrl': 'https://example.com/setup', - 'secrets': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Application', + description: 'Connect your workspace to My Application.', + clientUri: 'https://example.com', + logoUri: 'https://example.com/logo.png', + privacyPolicyUrl: 'https://example.com/privacy', + termsUrl: 'https://example.com/terms', + contacts: [], + tagline: 'Automate your workspace.', + tags: [], + labels: [], + images: [], + supportUrl: 'https://example.com/support', + dataDeletionUrl: 'https://example.com/data-deletion', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: true, + teamId: '5e5ea5c16897e', + userId: '5e5ea5c16897e', + installationScopes: [], + installationRedirectUrl: 'https://example.com/setup', + secrets: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.updateLabels( - '', - [], - ); + const response = await apps.updateLabels('', []); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listSecrets()', async () => { - const data = { - 'total': 5, - 'secrets': [],}; + const data = { + total: 5, + secrets: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.listSecrets( - '', - ); + const response = await apps.listSecrets(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createSecret()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'secret': '5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a', - 'hint': 'f5c6c7', - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + appId: '5e5ea5c16897e', + secret: '5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a', + hint: 'f5c6c7', + createdById: '5e5ea5c16897e', + createdByName: 'Walter White', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.createSecret( - '', - ); + const response = await apps.createSecret(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getSecret()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'secret': '', - 'hint': 'f5c6c7', - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + appId: '5e5ea5c16897e', + secret: '', + hint: 'f5c6c7', + createdById: '5e5ea5c16897e', + createdByName: 'Walter White', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.getSecret( - '', - '', - ); + const response = await apps.getSecret('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteSecret()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.deleteSecret( - '', - '', - ); + const response = await apps.deleteSecret('', ''); // 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', - 'name': 'My Application', - 'description': 'Connect your workspace to My Application.', - 'clientUri': 'https://example.com', - 'logoUri': 'https://example.com/logo.png', - 'privacyPolicyUrl': 'https://example.com/privacy', - 'termsUrl': 'https://example.com/terms', - 'contacts': [], - 'tagline': 'Automate your workspace.', - 'tags': [], - 'labels': [], - 'images': [], - 'supportUrl': 'https://example.com/support', - 'dataDeletionUrl': 'https://example.com/data-deletion', - 'redirectUris': [], - 'postLogoutRedirectUris': [], - 'enabled': true, - 'type': 'confidential', - 'deviceFlow': true, - 'teamId': '5e5ea5c16897e', - 'userId': '5e5ea5c16897e', - 'installationScopes': [], - 'installationRedirectUrl': 'https://example.com/setup', - 'secrets': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Application', + description: 'Connect your workspace to My Application.', + clientUri: 'https://example.com', + logoUri: 'https://example.com/logo.png', + privacyPolicyUrl: 'https://example.com/privacy', + termsUrl: 'https://example.com/terms', + contacts: [], + tagline: 'Automate your workspace.', + tags: [], + labels: [], + images: [], + supportUrl: 'https://example.com/support', + dataDeletionUrl: 'https://example.com/data-deletion', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: true, + teamId: '5e5ea5c16897e', + userId: '5e5ea5c16897e', + installationScopes: [], + installationRedirectUrl: 'https://example.com/setup', + secrets: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.updateTeam( - '', - '', - ); + const response = await apps.updateTeam('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteTokens()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await apps.deleteTokens( - '', - ); + const response = await apps.deleteTokens(''); // 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/avatars.test.js b/test/services/avatars.test.js index 56da275c..62baf68d 100644 --- a/test/services/avatars.test.js +++ b/test/services/avatars.test.js @@ -1,123 +1,104 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Avatars } = require("../../dist/services/avatars"); +const { Client } = require('../../dist/client'); +const { Avatars } = require('../../dist/services/avatars'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Avatars', () => { const client = new Client(); const avatars = new Avatars(client); - test('test method getBrowser()', async () => { const data = new ArrayBuffer(0); mockedFetch.mockImplementation(() => new Response(data)); - - const response = await avatars.getBrowser( - 'aa', - ); + const response = await avatars.getBrowser('aa'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getCreditCard()', async () => { const data = new ArrayBuffer(0); mockedFetch.mockImplementation(() => new Response(data)); - - const response = await avatars.getCreditCard( - 'amex', - ); + const response = await avatars.getCreditCard('amex'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getFavicon()', async () => { const data = new ArrayBuffer(0); mockedFetch.mockImplementation(() => new Response(data)); - - const response = await avatars.getFavicon( - 'https://example.com', - ); + const response = await avatars.getFavicon('https://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 getFlag()', async () => { const data = new ArrayBuffer(0); mockedFetch.mockImplementation(() => new Response(data)); - - const response = await avatars.getFlag( - 'af', - ); + const response = await avatars.getFlag('af'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getImage()', async () => { const data = new ArrayBuffer(0); mockedFetch.mockImplementation(() => new Response(data)); - - const response = await avatars.getImage( - 'https://example.com', - ); + const response = await avatars.getImage('https://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 getInitials()', async () => { const data = new ArrayBuffer(0); mockedFetch.mockImplementation(() => new Response(data)); + const response = await avatars.getInitials(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; - const response = await avatars.getInitials( - ); + expect(response).toEqual(data); + }); + test('test method getPhoto()', async () => { + const data = new ArrayBuffer(0); + mockedFetch.mockImplementation(() => new Response(data)); + const response = await avatars.getPhoto(); // 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)); - - const response = await avatars.getQR( - '', - ); + const response = await avatars.getQR(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getScreenshot()', async () => { const data = new ArrayBuffer(0); mockedFetch.mockImplementation(() => new Response(data)); - - const response = await avatars.getScreenshot( - 'https://example.com', - ); + const response = await avatars.getScreenshot('https://example.com'); // 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/backups.test.js b/test/services/backups.test.js index b37c790a..912e8344 100644 --- a/test/services/backups.test.js +++ b/test/services/backups.test.js @@ -1,259 +1,222 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Backups } = require("../../dist/services/backups"); +const { Client } = require('../../dist/client'); +const { Backups } = require('../../dist/services/backups'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Backups', () => { const client = new Client(); const backups = new Backups(client); - test('test method listArchives()', async () => { - const data = { - 'total': 5, - 'archives': [],}; + const data = { + total: 5, + archives: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await backups.listArchives( - ); + const response = await backups.listArchives(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createArchive()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'policyId': 'did8jx6ws45jana098ab7', - 'size': 100000, - 'status': 'completed', - 'startedAt': '2020-10-15T06:38:00.000+00:00', - 'migrationId': 'did8jx6ws45jana098ab7', - 'services': [], - 'resources': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + policyId: 'did8jx6ws45jana098ab7', + size: 100000, + status: 'completed', + startedAt: '2020-10-15T06:38:00.000+00:00', + migrationId: 'did8jx6ws45jana098ab7', + services: [], + resources: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await backups.createArchive( - [], - ); + const response = await backups.createArchive([]); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getArchive()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'policyId': 'did8jx6ws45jana098ab7', - 'size': 100000, - 'status': 'completed', - 'startedAt': '2020-10-15T06:38:00.000+00:00', - 'migrationId': 'did8jx6ws45jana098ab7', - 'services': [], - 'resources': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + policyId: 'did8jx6ws45jana098ab7', + size: 100000, + status: 'completed', + startedAt: '2020-10-15T06:38:00.000+00:00', + migrationId: 'did8jx6ws45jana098ab7', + services: [], + resources: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await backups.getArchive( - '', - ); + const response = await backups.getArchive(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteArchive()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await backups.deleteArchive( - '', - ); + const response = await backups.deleteArchive(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listPolicies()', async () => { - const data = { - 'total': 5, - 'policies': [],}; + const data = { + total: 5, + policies: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await backups.listPolicies( - ); + const response = await backups.listPolicies(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createPolicy()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - 'name': 'Hourly backups', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'services': [], - 'resources': [], - 'retention': 7, - 'schedule': '0 * * * *', - 'type': 'full', - 'enabled': true,}; + const data = { + '\\$id': '5e5ea5c16897e', + name: 'Hourly backups', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + services: [], + resources: [], + retention: 7, + schedule: '0 * * * *', + type: 'full', + enabled: true, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await backups.createPolicy( - '', - [], - 1, - '', - ); + const response = await backups.createPolicy('', [], 1, ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getPolicy()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - 'name': 'Hourly backups', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'services': [], - 'resources': [], - 'retention': 7, - 'schedule': '0 * * * *', - 'type': 'full', - 'enabled': true,}; + const data = { + '\\$id': '5e5ea5c16897e', + name: 'Hourly backups', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + services: [], + resources: [], + retention: 7, + schedule: '0 * * * *', + type: 'full', + enabled: true, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await backups.getPolicy( - '', - ); + const response = await backups.getPolicy(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updatePolicy()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - 'name': 'Hourly backups', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'services': [], - 'resources': [], - 'retention': 7, - 'schedule': '0 * * * *', - 'type': 'full', - 'enabled': true,}; + const data = { + '\\$id': '5e5ea5c16897e', + name: 'Hourly backups', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + services: [], + resources: [], + retention: 7, + schedule: '0 * * * *', + type: 'full', + enabled: true, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await backups.updatePolicy( - '', - ); + const response = await backups.updatePolicy(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deletePolicy()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await backups.deletePolicy( - '', - ); + const response = await backups.deletePolicy(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createRestoration()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'archiveId': 'did8jx6ws45jana098ab7', - 'policyId': 'did8jx6ws45jana098ab7', - 'status': 'completed', - 'startedAt': '2020-10-15T06:38:00.000+00:00', - 'migrationId': 'did8jx6ws45jana098ab7', - 'services': [], - 'resources': [], - 'options': '{databases.database[{oldId, newId, newName}]}',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + archiveId: 'did8jx6ws45jana098ab7', + policyId: 'did8jx6ws45jana098ab7', + status: 'completed', + startedAt: '2020-10-15T06:38:00.000+00:00', + migrationId: 'did8jx6ws45jana098ab7', + services: [], + resources: [], + options: '{databases.database[{oldId, newId, newName}]}', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await backups.createRestoration( - '', - [], - ); + const response = await backups.createRestoration('', []); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listRestorations()', async () => { - const data = { - 'total': 5, - 'restorations': [],}; + const data = { + total: 5, + restorations: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await backups.listRestorations( - ); + const response = await backups.listRestorations(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getRestoration()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'archiveId': 'did8jx6ws45jana098ab7', - 'policyId': 'did8jx6ws45jana098ab7', - 'status': 'completed', - 'startedAt': '2020-10-15T06:38:00.000+00:00', - 'migrationId': 'did8jx6ws45jana098ab7', - 'services': [], - 'resources': [], - 'options': '{databases.database[{oldId, newId, newName}]}',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + archiveId: 'did8jx6ws45jana098ab7', + policyId: 'did8jx6ws45jana098ab7', + status: 'completed', + startedAt: '2020-10-15T06:38:00.000+00:00', + migrationId: 'did8jx6ws45jana098ab7', + services: [], + resources: [], + options: '{databases.database[{oldId, newId, newName}]}', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await backups.getRestoration( - '', - ); + const response = await backups.getRestoration(''); // 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/databases.test.js b/test/services/databases.test.js index e4172d2f..2af87b02 100644 --- a/test/services/databases.test.js +++ b/test/services/databases.test.js @@ -1,245 +1,210 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Databases } = require("../../dist/services/databases"); +const { Client } = require('../../dist/client'); +const { Databases } = require('../../dist/services/databases'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Databases', () => { const client = new Client(); const databases = new Databases(client); - test('test method list()', async () => { - const data = { - 'total': 5, - 'databases': [],}; + const data = { + total: 5, + databases: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await databases.list( - ); + const response = await databases.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', - 'name': 'My Database', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true, - 'type': 'legacy',}; + const data = { + '\\$id': '5e5ea5c16897e', + name: 'My Database', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + enabled: true, + type: 'legacy', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await databases.create( - '', - '', - ); + const response = await databases.create('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listTransactions()', async () => { - const data = { - 'total': 5, - 'transactions': [],}; + const data = { + total: 5, + transactions: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await databases.listTransactions( - ); + const response = await databases.listTransactions(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createTransaction()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await databases.createTransaction( - ); + const response = await databases.createTransaction(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getTransaction()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await databases.getTransaction( - '', - ); + const response = await databases.getTransaction(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateTransaction()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await databases.updateTransaction( - '', - ); + const response = await databases.updateTransaction(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteTransaction()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await databases.deleteTransaction( - '', - ); + const response = await databases.deleteTransaction(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createOperations()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await databases.createOperations( - '', - ); + const response = await databases.createOperations(''); // 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', - 'name': 'My Database', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true, - 'type': 'legacy',}; + const data = { + '\\$id': '5e5ea5c16897e', + name: 'My Database', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + enabled: true, + type: 'legacy', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await databases.get( - '', - ); + const response = await databases.get(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method update()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - 'name': 'My Database', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true, - 'type': 'legacy',}; + const data = { + '\\$id': '5e5ea5c16897e', + name: 'My Database', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + enabled: true, + type: 'legacy', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await databases.update( - '', - ); + const response = await databases.update(''); // 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: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await databases.delete( - '', - ); + const response = await databases.delete(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listCollections()', async () => { - const data = { - 'total': 5, - 'collections': [],}; + const data = { + total: 5, + collections: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await databases.listCollections( - '', - ); + const response = await databases.listCollections(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createCollection()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'databaseId': '5e5ea5c16897e', - 'name': 'My Collection', - 'enabled': true, - 'documentSecurity': true, - 'attributes': [], - 'indexes': [], - 'bytesMax': 65535, - 'bytesUsed': 1500,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + databaseId: '5e5ea5c16897e', + name: 'My Collection', + enabled: true, + documentSecurity: true, + attributes: [], + indexes: [], + bytesMax: 65535, + bytesUsed: 1500, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createCollection( '', '', @@ -251,23 +216,22 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method getCollection()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'databaseId': '5e5ea5c16897e', - 'name': 'My Collection', - 'enabled': true, - 'documentSecurity': true, - 'attributes': [], - 'indexes': [], - 'bytesMax': 65535, - 'bytesUsed': 1500,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + databaseId: '5e5ea5c16897e', + name: 'My Collection', + enabled: true, + documentSecurity: true, + attributes: [], + indexes: [], + bytesMax: 65535, + bytesUsed: 1500, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.getCollection( '', '', @@ -278,23 +242,22 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateCollection()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'databaseId': '5e5ea5c16897e', - 'name': 'My Collection', - 'enabled': true, - 'documentSecurity': true, - 'attributes': [], - 'indexes': [], - 'bytesMax': 65535, - 'bytesUsed': 1500,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + databaseId: '5e5ea5c16897e', + name: 'My Collection', + enabled: true, + documentSecurity: true, + attributes: [], + indexes: [], + bytesMax: 65535, + bytesUsed: 1500, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateCollection( '', '', @@ -305,11 +268,9 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method deleteCollection()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.deleteCollection( '', '', @@ -320,13 +281,12 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method listAttributes()', async () => { - const data = { - 'total': 5, - 'attributes': [],}; + const data = { + total: 5, + attributes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.listAttributes( '', '', @@ -337,22 +297,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createBigIntAttribute()', async () => { - const data = { - 'key': 'count', - 'type': 'bigint', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'count', + type: 'bigint', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createBigIntAttribute( '', '', - '', + '', true, ); @@ -361,22 +320,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateBigIntAttribute()', async () => { - const data = { - 'key': 'count', - 'type': 'bigint', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'count', + type: 'bigint', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateBigIntAttribute( '', '', - '', + '', true, 1, ); @@ -386,22 +344,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createBooleanAttribute()', async () => { - const data = { - 'key': 'isEnabled', - 'type': 'boolean', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'isEnabled', + type: 'boolean', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createBooleanAttribute( '', '', - '', + '', true, ); @@ -410,22 +367,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateBooleanAttribute()', async () => { - const data = { - 'key': 'isEnabled', - 'type': 'boolean', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'isEnabled', + type: 'boolean', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateBooleanAttribute( '', '', - '', + '', true, true, ); @@ -435,23 +391,22 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createDatetimeAttribute()', async () => { - const data = { - 'key': 'birthDay', - 'type': 'datetime', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'datetime',}; + const data = { + key: 'birthDay', + type: 'datetime', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'datetime', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createDatetimeAttribute( '', '', - '', + '', true, ); @@ -460,23 +415,22 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateDatetimeAttribute()', async () => { - const data = { - 'key': 'birthDay', - 'type': 'datetime', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'datetime',}; + const data = { + key: 'birthDay', + type: 'datetime', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'datetime', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateDatetimeAttribute( '', '', - '', + '', true, '2020-10-15T06:38:00.000+00:00', ); @@ -486,23 +440,22 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createEmailAttribute()', async () => { - const data = { - 'key': 'userEmail', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'email',}; + const data = { + key: 'userEmail', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'email', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createEmailAttribute( '', '', - '', + '', true, ); @@ -511,23 +464,22 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateEmailAttribute()', async () => { - const data = { - 'key': 'userEmail', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'email',}; + const data = { + key: 'userEmail', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'email', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateEmailAttribute( '', '', - '', + '', true, 'email@example.com', ); @@ -537,24 +489,23 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createEnumAttribute()', async () => { - const data = { - 'key': 'status', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'elements': [], - 'format': 'enum',}; + const data = { + key: 'status', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + elements: [], + format: 'enum', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createEnumAttribute( '', '', - '', + '', [], true, ); @@ -564,27 +515,26 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateEnumAttribute()', async () => { - const data = { - 'key': 'status', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'elements': [], - 'format': 'enum',}; + const data = { + key: 'status', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + elements: [], + format: 'enum', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateEnumAttribute( '', '', - '', + '', [], true, - '', + 'active', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -592,22 +542,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createFloatAttribute()', async () => { - const data = { - 'key': 'percentageCompleted', - 'type': 'double', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'percentageCompleted', + type: 'double', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createFloatAttribute( '', '', - '', + '', true, ); @@ -616,22 +565,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateFloatAttribute()', async () => { - const data = { - 'key': 'percentageCompleted', - 'type': 'double', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'percentageCompleted', + type: 'double', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateFloatAttribute( '', '', - '', + '', true, 1.0, ); @@ -641,22 +589,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createIntegerAttribute()', async () => { - const data = { - 'key': 'count', - 'type': 'integer', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'count', + type: 'integer', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createIntegerAttribute( '', '', - '', + '', true, ); @@ -665,22 +612,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateIntegerAttribute()', async () => { - const data = { - 'key': 'count', - 'type': 'integer', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'count', + type: 'integer', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateIntegerAttribute( '', '', - '', + '', true, 1, ); @@ -690,23 +636,22 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createIpAttribute()', async () => { - const data = { - 'key': 'ipAddress', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'ip',}; + const data = { + key: 'ipAddress', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'ip', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createIpAttribute( '', '', - '', + '', true, ); @@ -715,25 +660,24 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateIpAttribute()', async () => { - const data = { - 'key': 'ipAddress', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'ip',}; + const data = { + key: 'ipAddress', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'ip', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateIpAttribute( '', '', - '', + '', true, - '', + '192.0.2.0', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -741,22 +685,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createLineAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createLineAttribute( '', '', - '', + '', true, ); @@ -765,22 +708,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateLineAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateLineAttribute( '', '', - '', + '', true, ); @@ -789,22 +731,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createLongtextAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createLongtextAttribute( '', '', - '', + '', true, ); @@ -813,24 +754,23 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateLongtextAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateLongtextAttribute( '', '', - '', + '', true, - '', + 'Hello World', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -838,22 +778,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createMediumtextAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createMediumtextAttribute( '', '', - '', + '', true, ); @@ -862,24 +801,23 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateMediumtextAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateMediumtextAttribute( '', '', - '', + '', true, - '', + 'Hello World', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -887,22 +825,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createPointAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createPointAttribute( '', '', - '', + '', true, ); @@ -911,22 +848,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updatePointAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updatePointAttribute( '', '', - '', + '', true, ); @@ -935,22 +871,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createPolygonAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createPolygonAttribute( '', '', - '', + '', true, ); @@ -959,22 +894,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updatePolygonAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updatePolygonAttribute( '', '', - '', + '', true, ); @@ -983,24 +917,23 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createRelationshipAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'relatedCollection': 'collection', - 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', - 'twoWay': true, - 'twoWayKey': 'string', - 'onDelete': 'restrict|cascade|setNull', - 'side': 'parent|child',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + relatedCollection: 'collection', + relationType: 'oneToOne|oneToMany|manyToOne|manyToMany', + twoWay: true, + twoWayKey: 'string', + onDelete: 'restrict|cascade|setNull', + side: 'parent|child', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createRelationshipAttribute( '', '', @@ -1013,28 +946,27 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateRelationshipAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'relatedCollection': 'collection', - 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', - 'twoWay': true, - 'twoWayKey': 'string', - 'onDelete': 'restrict|cascade|setNull', - 'side': 'parent|child',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + relatedCollection: 'collection', + relationType: 'oneToOne|oneToMany|manyToOne|manyToMany', + twoWay: true, + twoWayKey: 'string', + onDelete: 'restrict|cascade|setNull', + side: 'parent|child', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateRelationshipAttribute( '', '', - '', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1042,23 +974,22 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createStringAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'size': 128,}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + size: 128, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createStringAttribute( '', '', - '', + '', 1, true, ); @@ -1068,25 +999,24 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateStringAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'size': 128,}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + size: 128, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateStringAttribute( '', '', - '', + '', true, - '', + 'Hello World', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1094,22 +1024,21 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createTextAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createTextAttribute( '', '', - '', + '', true, ); @@ -1118,24 +1047,23 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateTextAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateTextAttribute( '', '', - '', + '', true, - '', + 'Hello World', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1143,23 +1071,22 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createUrlAttribute()', async () => { - const data = { - 'key': 'githubUrl', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'url',}; + const data = { + key: 'githubUrl', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'url', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createUrlAttribute( '', '', - '', + '', true, ); @@ -1168,23 +1095,22 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateUrlAttribute()', async () => { - const data = { - 'key': 'githubUrl', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'url',}; + const data = { + key: 'githubUrl', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'url', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateUrlAttribute( '', '', - '', + '', true, 'https://example.com', ); @@ -1194,23 +1120,22 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createVarcharAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'size': 128,}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + size: 128, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createVarcharAttribute( '', '', - '', + '', 1, true, ); @@ -1220,25 +1145,24 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateVarcharAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'size': 128,}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + size: 128, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateVarcharAttribute( '', '', - '', + '', true, - '', + 'Hello World', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1246,23 +1170,22 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method getAttribute()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'size': 128,}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + size: 128, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.getAttribute( '', '', - '', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1270,15 +1193,13 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method deleteAttribute()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.deleteAttribute( '', '', - '', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1286,13 +1207,12 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method listDocuments()', async () => { - const data = { - 'total': 5, - 'documents': [],}; + const data = { + total: 5, + documents: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.listDocuments( '', '', @@ -1303,18 +1223,17 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createDocument()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createDocument( '', '', @@ -1327,13 +1246,12 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createDocuments()', async () => { - const data = { - 'total': 5, - 'documents': [],}; + const data = { + total: 5, + documents: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createDocuments( '', '', @@ -1345,13 +1263,12 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method upsertDocuments()', async () => { - const data = { - 'total': 5, - 'documents': [],}; + const data = { + total: 5, + documents: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.upsertDocuments( '', '', @@ -1363,13 +1280,12 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateDocuments()', async () => { - const data = { - 'total': 5, - 'documents': [],}; + const data = { + total: 5, + documents: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateDocuments( '', '', @@ -1380,13 +1296,12 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method deleteDocuments()', async () => { - const data = { - 'total': 5, - 'documents': [],}; + const data = { + total: 5, + documents: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.deleteDocuments( '', '', @@ -1397,18 +1312,17 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method getDocument()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.getDocument( '', '', @@ -1420,18 +1334,17 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method upsertDocument()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.upsertDocument( '', '', @@ -1443,18 +1356,17 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method updateDocument()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.updateDocument( '', '', @@ -1466,11 +1378,9 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method deleteDocument()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.deleteDocument( '', '', @@ -1482,23 +1392,22 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method decrementDocumentAttribute()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.decrementDocumentAttribute( '', '', '', - '', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1506,23 +1415,22 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method incrementDocumentAttribute()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.incrementDocumentAttribute( '', '', '', - '', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1530,13 +1438,12 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method listIndexes()', async () => { - const data = { - 'total': 5, - 'indexes': [],}; + const data = { + total: 5, + indexes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.listIndexes( '', '', @@ -1547,24 +1454,23 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method createIndex()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'index1', - 'type': 'primary', - 'status': 'available', - 'error': 'string', - 'attributes': [], - 'lengths': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'index1', + type: 'primary', + status: 'available', + error: 'string', + attributes: [], + lengths: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.createIndex( '', '', - '', + '', 'key', [], ); @@ -1574,24 +1480,23 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method getIndex()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'index1', - 'type': 'primary', - 'status': 'available', - 'error': 'string', - 'attributes': [], - 'lengths': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'index1', + type: 'primary', + status: 'available', + error: 'string', + attributes: [], + lengths: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.getIndex( '', '', - '', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1599,15 +1504,13 @@ describe('Databases', () => { expect(response).toEqual(data); }); - test('test method deleteIndex()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await databases.deleteIndex( '', '', - '', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1615,4 +1518,4 @@ describe('Databases', () => { expect(response).toEqual(data); }); - }) +}); diff --git a/test/services/documents-d-b.test.js b/test/services/documents-d-b.test.js new file mode 100644 index 00000000..26a4f93d --- /dev/null +++ b/test/services/documents-d-b.test.js @@ -0,0 +1,723 @@ +const { Client } = require('../../dist/client'); +const { DocumentsDB } = require('../../dist/services/documents-db'); + +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); + +describe('DocumentsDB', () => { + const client = new Client(); + const documentsDB = new DocumentsDB(client); + + test('test method list()', async () => { + const data = { + total: 5, + databases: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.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', + name: 'My Database', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + enabled: true, + type: 'legacy', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.create('', ''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listSpecifications()', async () => { + const data = { + specifications: [], + total: 9, + pricing: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.listSpecifications(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listTransactions()', async () => { + const data = { + total: 5, + transactions: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.listTransactions(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createTransaction()', async () => { + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.createTransaction(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getTransaction()', async () => { + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.getTransaction(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateTransaction()', async () => { + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = + await documentsDB.updateTransaction(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteTransaction()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = + await documentsDB.deleteTransaction(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createOperations()', async () => { + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.createOperations(''); + + // 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', + name: 'My Database', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + enabled: true, + type: 'legacy', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.get(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method update()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + name: 'My Database', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + enabled: true, + type: 'legacy', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.update('', ''); + + // 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 documentsDB.delete(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listCollections()', async () => { + const data = { + total: 5, + collections: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.listCollections(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createCollection()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + databaseId: '5e5ea5c16897e', + name: 'My Collection', + enabled: true, + documentSecurity: true, + attributes: [], + indexes: [], + bytesMax: 65535, + bytesUsed: 1500, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.createCollection( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getCollection()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + databaseId: '5e5ea5c16897e', + name: 'My Collection', + enabled: true, + documentSecurity: true, + attributes: [], + indexes: [], + bytesMax: 65535, + bytesUsed: 1500, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.getCollection( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateCollection()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + databaseId: '5e5ea5c16897e', + name: 'My Collection', + enabled: true, + documentSecurity: true, + attributes: [], + indexes: [], + bytesMax: 65535, + bytesUsed: 1500, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.updateCollection( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteCollection()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.deleteCollection( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listDocuments()', async () => { + const data = { + total: 5, + documents: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.listDocuments( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createDocument()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.createDocument( + '', + '', + '', + {}, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createDocuments()', async () => { + const data = { + total: 5, + documents: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.createDocuments( + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method upsertDocuments()', async () => { + const data = { + total: 5, + documents: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.upsertDocuments( + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateDocuments()', async () => { + const data = { + total: 5, + documents: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.updateDocuments( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteDocuments()', async () => { + const data = { + total: 5, + documents: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.deleteDocuments( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getDocument()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.getDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method upsertDocument()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.upsertDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateDocument()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.updateDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteDocument()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.deleteDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method decrementDocumentAttribute()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.decrementDocumentAttribute( + '', + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method incrementDocumentAttribute()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.incrementDocumentAttribute( + '', + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listIndexes()', async () => { + const data = { + total: 5, + indexes: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.listIndexes( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createIndex()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'index1', + type: 'primary', + status: 'available', + error: 'string', + attributes: [], + lengths: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.createIndex( + '', + '', + '', + 'key', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getIndex()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'index1', + type: 'primary', + status: 'available', + error: 'string', + attributes: [], + lengths: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.getIndex( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteIndex()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.deleteIndex( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createFailover()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.createFailover(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listOperations()', async () => { + const data = { + total: 5, + operations: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.listOperations(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getReplicas()', async () => { + const data = { + replicas: 2, + syncMode: 'async', + syncDegraded: true, + syncAcknowledgements: 1, + syncStandbyCount: 2, + members: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.getReplicas(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getStatus()', async () => { + const data = { + health: 'healthy', + ready: true, + engine: 'postgresql', + version: '17', + uptime: 86400, + connections: {}, + syncMode: 'async', + syncDegraded: true, + syncAcknowledgements: 1, + syncStandbyCount: 2, + replicas: [], + volumes: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await documentsDB.getStatus(''); + + // 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/embeddings.test.js b/test/services/embeddings.test.js index 02e84edf..ae0732ef 100644 --- a/test/services/embeddings.test.js +++ b/test/services/embeddings.test.js @@ -1,28 +1,27 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Embeddings } = require("../../dist/services/embeddings"); +const { Client } = require('../../dist/client'); +const { Embeddings } = require('../../dist/services/embeddings'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Embeddings', () => { const client = new Client(); const embeddings = new Embeddings(client); - test('test method createTextEmbeddings()', async () => { - const data = { - 'total': 5, - 'embeddings': [],}; + const data = { + total: 5, + embeddings: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await embeddings.createTextEmbeddings( - [], - ); + const response = await embeddings.createTextEmbeddings([]); // 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/functions.test.js b/test/services/functions.test.js index e8059310..62c32e06 100644 --- a/test/services/functions.test.js +++ b/test/services/functions.test.js @@ -1,66 +1,66 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Functions } = require("../../dist/services/functions"); +const { Client } = require('../../dist/client'); +const { InputFile } = require('../../dist/inputFile'); +const { Functions } = require('../../dist/services/functions'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Functions', () => { const client = new Client(); const functions = new Functions(client); - test('test method list()', async () => { - const data = { - 'total': 5, - 'functions': [],}; + const data = { + total: 5, + functions: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await functions.list( - ); + const response = await functions.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', - 'execute': [], - 'name': 'My Function', - 'enabled': true, - 'live': true, - 'logging': true, - 'runtime': 'python-3.8', - 'deploymentRetention': 7, - 'deploymentId': '5e5ea5c16897e', - 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'latestDeploymentId': '5e5ea5c16897e', - 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'latestDeploymentStatus': 'ready', - 'scopes': [], - 'vars': [], - 'events': [], - 'schedule': '5 4 * * *', - 'timeout': 300, - 'entrypoint': 'index.js', - 'commands': 'npm install', - 'version': 'v2', - 'installationId': '6m40at4ejk5h2u9s1hboo', - 'providerRepositoryId': 'appwrite', - 'providerBranch': 'main', - 'providerRootDirectory': 'functions/helloWorld', - 'providerSilentMode': true, - 'providerBranches': [], - 'providerPaths': [], - 'buildSpecification': 's-1vcpu-512mb', - 'runtimeSpecification': 's-1vcpu-512mb',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + execute: [], + name: 'My Function', + enabled: true, + live: true, + logging: true, + runtime: 'python-3.8', + deploymentRetention: 7, + deploymentId: '5e5ea5c16897e', + deploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + latestDeploymentId: '5e5ea5c16897e', + latestDeploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + latestDeploymentStatus: 'ready', + scopes: [], + vars: [], + events: [], + schedule: '5 4 * * *', + timeout: 300, + entrypoint: 'index.js', + commands: 'npm install', + version: 'v2', + installationId: '6m40at4ejk5h2u9s1hboo', + providerRepositoryId: 'appwrite', + providerBranch: 'main', + providerRootDirectory: 'functions/helloWorld', + providerSilentMode: true, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await functions.create( '', '', @@ -72,180 +72,164 @@ describe('Functions', () => { expect(response).toEqual(data); }); - test('test method listRuntimes()', async () => { - const data = { - 'total': 5, - 'runtimes': [],}; + const data = { + total: 5, + runtimes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await functions.listRuntimes( - ); + const response = await functions.listRuntimes(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listSpecifications()', async () => { - const data = { - 'total': 5, - 'specifications': [],}; + const data = { + total: 5, + specifications: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await functions.listSpecifications( - ); + const response = await functions.listSpecifications(); // 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', - 'execute': [], - 'name': 'My Function', - 'enabled': true, - 'live': true, - 'logging': true, - 'runtime': 'python-3.8', - 'deploymentRetention': 7, - 'deploymentId': '5e5ea5c16897e', - 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'latestDeploymentId': '5e5ea5c16897e', - 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'latestDeploymentStatus': 'ready', - 'scopes': [], - 'vars': [], - 'events': [], - 'schedule': '5 4 * * *', - 'timeout': 300, - 'entrypoint': 'index.js', - 'commands': 'npm install', - 'version': 'v2', - 'installationId': '6m40at4ejk5h2u9s1hboo', - 'providerRepositoryId': 'appwrite', - 'providerBranch': 'main', - 'providerRootDirectory': 'functions/helloWorld', - 'providerSilentMode': true, - 'providerBranches': [], - 'providerPaths': [], - 'buildSpecification': 's-1vcpu-512mb', - 'runtimeSpecification': 's-1vcpu-512mb',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + execute: [], + name: 'My Function', + enabled: true, + live: true, + logging: true, + runtime: 'python-3.8', + deploymentRetention: 7, + deploymentId: '5e5ea5c16897e', + deploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + latestDeploymentId: '5e5ea5c16897e', + latestDeploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + latestDeploymentStatus: 'ready', + scopes: [], + vars: [], + events: [], + schedule: '5 4 * * *', + timeout: 300, + entrypoint: 'index.js', + commands: 'npm install', + version: 'v2', + installationId: '6m40at4ejk5h2u9s1hboo', + providerRepositoryId: 'appwrite', + providerBranch: 'main', + providerRootDirectory: 'functions/helloWorld', + providerSilentMode: true, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await functions.get( - '', - ); + const response = await functions.get(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method update()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'execute': [], - 'name': 'My Function', - 'enabled': true, - 'live': true, - 'logging': true, - 'runtime': 'python-3.8', - 'deploymentRetention': 7, - 'deploymentId': '5e5ea5c16897e', - 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'latestDeploymentId': '5e5ea5c16897e', - 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'latestDeploymentStatus': 'ready', - 'scopes': [], - 'vars': [], - 'events': [], - 'schedule': '5 4 * * *', - 'timeout': 300, - 'entrypoint': 'index.js', - 'commands': 'npm install', - 'version': 'v2', - 'installationId': '6m40at4ejk5h2u9s1hboo', - 'providerRepositoryId': 'appwrite', - 'providerBranch': 'main', - 'providerRootDirectory': 'functions/helloWorld', - 'providerSilentMode': true, - 'providerBranches': [], - 'providerPaths': [], - 'buildSpecification': 's-1vcpu-512mb', - 'runtimeSpecification': 's-1vcpu-512mb',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + execute: [], + name: 'My Function', + enabled: true, + live: true, + logging: true, + runtime: 'python-3.8', + deploymentRetention: 7, + deploymentId: '5e5ea5c16897e', + deploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + latestDeploymentId: '5e5ea5c16897e', + latestDeploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + latestDeploymentStatus: 'ready', + scopes: [], + vars: [], + events: [], + schedule: '5 4 * * *', + timeout: 300, + entrypoint: 'index.js', + commands: 'npm install', + version: 'v2', + installationId: '6m40at4ejk5h2u9s1hboo', + providerRepositoryId: 'appwrite', + providerBranch: 'main', + providerRootDirectory: 'functions/helloWorld', + providerSilentMode: true, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await functions.update( - '', - '', - ); + const response = await functions.update('', ''); // 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: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await functions.delete( - '', - ); + const response = await functions.delete(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateFunctionDeployment()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'execute': [], - 'name': 'My Function', - 'enabled': true, - 'live': true, - 'logging': true, - 'runtime': 'python-3.8', - 'deploymentRetention': 7, - 'deploymentId': '5e5ea5c16897e', - 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'latestDeploymentId': '5e5ea5c16897e', - 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'latestDeploymentStatus': 'ready', - 'scopes': [], - 'vars': [], - 'events': [], - 'schedule': '5 4 * * *', - 'timeout': 300, - 'entrypoint': 'index.js', - 'commands': 'npm install', - 'version': 'v2', - 'installationId': '6m40at4ejk5h2u9s1hboo', - 'providerRepositoryId': 'appwrite', - 'providerBranch': 'main', - 'providerRootDirectory': 'functions/helloWorld', - 'providerSilentMode': true, - 'providerBranches': [], - 'providerPaths': [], - 'buildSpecification': 's-1vcpu-512mb', - 'runtimeSpecification': 's-1vcpu-512mb',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + execute: [], + name: 'My Function', + enabled: true, + live: true, + logging: true, + runtime: 'python-3.8', + deploymentRetention: 7, + deploymentId: '5e5ea5c16897e', + deploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + latestDeploymentId: '5e5ea5c16897e', + latestDeploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + latestDeploymentStatus: 'ready', + scopes: [], + vars: [], + events: [], + schedule: '5 4 * * *', + timeout: 300, + entrypoint: 'index.js', + commands: 'npm install', + version: 'v2', + installationId: '6m40at4ejk5h2u9s1hboo', + providerRepositoryId: 'appwrite', + providerBranch: 'main', + providerRootDirectory: 'functions/helloWorld', + providerSilentMode: true, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await functions.updateFunctionDeployment( '', '', @@ -256,54 +240,53 @@ describe('Functions', () => { expect(response).toEqual(data); }); - test('test method listDeployments()', async () => { - const data = { - 'total': 5, - 'deployments': [],}; + const data = { + total: 5, + deployments: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await functions.listDeployments( - '', - ); + const response = await functions.listDeployments(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createDeployment()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'type': 'vcs', - 'resourceId': '5e5ea6g16897e', - 'resourceType': 'functions', - 'entrypoint': 'index.js', - 'sourceSize': 128, - 'buildSize': 128, - 'totalSize': 128, - 'buildId': '5e5ea5c16897e', - 'activate': true, - 'screenshotLight': '5e5ea5c16897e', - 'screenshotDark': '5e5ea5c16897e', - 'status': 'ready', - 'buildLogs': 'Compiling source files...', - 'buildDuration': 128, - 'providerRepositoryName': 'database', - 'providerRepositoryOwner': 'utopia', - 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', - 'providerCommitHash': '7c3f25d', - 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', - 'providerCommitAuthor': 'Khushboo Verma', - 'providerCommitMessage': 'Update index.js', - 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', - 'providerBranch': '0.7.x', - 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + type: 'vcs', + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + entrypoint: 'index.js', + sourceSize: 128, + buildSize: 128, + totalSize: 128, + buildId: '5e5ea5c16897e', + activate: true, + screenshotLight: '5e5ea5c16897e', + screenshotDark: '5e5ea5c16897e', + status: 'ready', + buildLogs: 'Compiling source files...', + buildDuration: 128, + providerRepositoryName: 'database', + providerRepositoryOwner: 'utopia', + providerRepositoryUrl: + 'https://github.com/vermakhushboo/g4-node-function', + providerCommitHash: '7c3f25d', + providerCommitAuthorUrl: 'https://github.com/vermakhushboo', + providerCommitAuthor: 'Khushboo Verma', + providerCommitMessage: 'Update index.js', + providerCommitUrl: + 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + providerBranch: '0.7.x', + providerBranchUrl: + 'https://github.com/vermakhushboo/appwrite/tree/0.7.x', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await functions.createDeployment( '', InputFile.fromBuffer(new Uint8Array(0), 'image.png'), @@ -315,38 +298,40 @@ describe('Functions', () => { expect(response).toEqual(data); }); - test('test method createDuplicateDeployment()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'type': 'vcs', - 'resourceId': '5e5ea6g16897e', - 'resourceType': 'functions', - 'entrypoint': 'index.js', - 'sourceSize': 128, - 'buildSize': 128, - 'totalSize': 128, - 'buildId': '5e5ea5c16897e', - 'activate': true, - 'screenshotLight': '5e5ea5c16897e', - 'screenshotDark': '5e5ea5c16897e', - 'status': 'ready', - 'buildLogs': 'Compiling source files...', - 'buildDuration': 128, - 'providerRepositoryName': 'database', - 'providerRepositoryOwner': 'utopia', - 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', - 'providerCommitHash': '7c3f25d', - 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', - 'providerCommitAuthor': 'Khushboo Verma', - 'providerCommitMessage': 'Update index.js', - 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', - 'providerBranch': '0.7.x', - 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + type: 'vcs', + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + entrypoint: 'index.js', + sourceSize: 128, + buildSize: 128, + totalSize: 128, + buildId: '5e5ea5c16897e', + activate: true, + screenshotLight: '5e5ea5c16897e', + screenshotDark: '5e5ea5c16897e', + status: 'ready', + buildLogs: 'Compiling source files...', + buildDuration: 128, + providerRepositoryName: 'database', + providerRepositoryOwner: 'utopia', + providerRepositoryUrl: + 'https://github.com/vermakhushboo/g4-node-function', + providerCommitHash: '7c3f25d', + providerCommitAuthorUrl: 'https://github.com/vermakhushboo', + providerCommitAuthor: 'Khushboo Verma', + providerCommitMessage: 'Update index.js', + providerCommitUrl: + 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + providerBranch: '0.7.x', + providerBranchUrl: + 'https://github.com/vermakhushboo/appwrite/tree/0.7.x', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await functions.createDuplicateDeployment( '', '', @@ -357,38 +342,40 @@ describe('Functions', () => { expect(response).toEqual(data); }); - test('test method createTemplateDeployment()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'type': 'vcs', - 'resourceId': '5e5ea6g16897e', - 'resourceType': 'functions', - 'entrypoint': 'index.js', - 'sourceSize': 128, - 'buildSize': 128, - 'totalSize': 128, - 'buildId': '5e5ea5c16897e', - 'activate': true, - 'screenshotLight': '5e5ea5c16897e', - 'screenshotDark': '5e5ea5c16897e', - 'status': 'ready', - 'buildLogs': 'Compiling source files...', - 'buildDuration': 128, - 'providerRepositoryName': 'database', - 'providerRepositoryOwner': 'utopia', - 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', - 'providerCommitHash': '7c3f25d', - 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', - 'providerCommitAuthor': 'Khushboo Verma', - 'providerCommitMessage': 'Update index.js', - 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', - 'providerBranch': '0.7.x', - 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + type: 'vcs', + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + entrypoint: 'index.js', + sourceSize: 128, + buildSize: 128, + totalSize: 128, + buildId: '5e5ea5c16897e', + activate: true, + screenshotLight: '5e5ea5c16897e', + screenshotDark: '5e5ea5c16897e', + status: 'ready', + buildLogs: 'Compiling source files...', + buildDuration: 128, + providerRepositoryName: 'database', + providerRepositoryOwner: 'utopia', + providerRepositoryUrl: + 'https://github.com/vermakhushboo/g4-node-function', + providerCommitHash: '7c3f25d', + providerCommitAuthorUrl: 'https://github.com/vermakhushboo', + providerCommitAuthor: 'Khushboo Verma', + providerCommitMessage: 'Update index.js', + providerCommitUrl: + 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + providerBranch: '0.7.x', + providerBranchUrl: + 'https://github.com/vermakhushboo/appwrite/tree/0.7.x', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await functions.createTemplateDeployment( '', '', @@ -403,38 +390,40 @@ describe('Functions', () => { expect(response).toEqual(data); }); - test('test method createVcsDeployment()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'type': 'vcs', - 'resourceId': '5e5ea6g16897e', - 'resourceType': 'functions', - 'entrypoint': 'index.js', - 'sourceSize': 128, - 'buildSize': 128, - 'totalSize': 128, - 'buildId': '5e5ea5c16897e', - 'activate': true, - 'screenshotLight': '5e5ea5c16897e', - 'screenshotDark': '5e5ea5c16897e', - 'status': 'ready', - 'buildLogs': 'Compiling source files...', - 'buildDuration': 128, - 'providerRepositoryName': 'database', - 'providerRepositoryOwner': 'utopia', - 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', - 'providerCommitHash': '7c3f25d', - 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', - 'providerCommitAuthor': 'Khushboo Verma', - 'providerCommitMessage': 'Update index.js', - 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', - 'providerBranch': '0.7.x', - 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + type: 'vcs', + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + entrypoint: 'index.js', + sourceSize: 128, + buildSize: 128, + totalSize: 128, + buildId: '5e5ea5c16897e', + activate: true, + screenshotLight: '5e5ea5c16897e', + screenshotDark: '5e5ea5c16897e', + status: 'ready', + buildLogs: 'Compiling source files...', + buildDuration: 128, + providerRepositoryName: 'database', + providerRepositoryOwner: 'utopia', + providerRepositoryUrl: + 'https://github.com/vermakhushboo/g4-node-function', + providerCommitHash: '7c3f25d', + providerCommitAuthorUrl: 'https://github.com/vermakhushboo', + providerCommitAuthor: 'Khushboo Verma', + providerCommitMessage: 'Update index.js', + providerCommitUrl: + 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + providerBranch: '0.7.x', + providerBranchUrl: + 'https://github.com/vermakhushboo/appwrite/tree/0.7.x', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await functions.createVcsDeployment( '', 'branch', @@ -446,38 +435,40 @@ describe('Functions', () => { expect(response).toEqual(data); }); - test('test method getDeployment()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'type': 'vcs', - 'resourceId': '5e5ea6g16897e', - 'resourceType': 'functions', - 'entrypoint': 'index.js', - 'sourceSize': 128, - 'buildSize': 128, - 'totalSize': 128, - 'buildId': '5e5ea5c16897e', - 'activate': true, - 'screenshotLight': '5e5ea5c16897e', - 'screenshotDark': '5e5ea5c16897e', - 'status': 'ready', - 'buildLogs': 'Compiling source files...', - 'buildDuration': 128, - 'providerRepositoryName': 'database', - 'providerRepositoryOwner': 'utopia', - 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', - 'providerCommitHash': '7c3f25d', - 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', - 'providerCommitAuthor': 'Khushboo Verma', - 'providerCommitMessage': 'Update index.js', - 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', - 'providerBranch': '0.7.x', - 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + type: 'vcs', + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + entrypoint: 'index.js', + sourceSize: 128, + buildSize: 128, + totalSize: 128, + buildId: '5e5ea5c16897e', + activate: true, + screenshotLight: '5e5ea5c16897e', + screenshotDark: '5e5ea5c16897e', + status: 'ready', + buildLogs: 'Compiling source files...', + buildDuration: 128, + providerRepositoryName: 'database', + providerRepositoryOwner: 'utopia', + providerRepositoryUrl: + 'https://github.com/vermakhushboo/g4-node-function', + providerCommitHash: '7c3f25d', + providerCommitAuthorUrl: 'https://github.com/vermakhushboo', + providerCommitAuthor: 'Khushboo Verma', + providerCommitMessage: 'Update index.js', + providerCommitUrl: + 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + providerBranch: '0.7.x', + providerBranchUrl: + 'https://github.com/vermakhushboo/appwrite/tree/0.7.x', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await functions.getDeployment( '', '', @@ -488,11 +479,9 @@ describe('Functions', () => { expect(response).toEqual(data); }); - test('test method deleteDeployment()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await functions.deleteDeployment( '', '', @@ -503,11 +492,9 @@ describe('Functions', () => { expect(response).toEqual(data); }); - test('test method getDeploymentDownload()', async () => { const data = new ArrayBuffer(0); mockedFetch.mockImplementation(() => new Response(data)); - const response = await functions.getDeploymentDownload( '', '', @@ -518,38 +505,40 @@ describe('Functions', () => { expect(response).toEqual(data); }); - test('test method updateDeploymentStatus()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'type': 'vcs', - 'resourceId': '5e5ea6g16897e', - 'resourceType': 'functions', - 'entrypoint': 'index.js', - 'sourceSize': 128, - 'buildSize': 128, - 'totalSize': 128, - 'buildId': '5e5ea5c16897e', - 'activate': true, - 'screenshotLight': '5e5ea5c16897e', - 'screenshotDark': '5e5ea5c16897e', - 'status': 'ready', - 'buildLogs': 'Compiling source files...', - 'buildDuration': 128, - 'providerRepositoryName': 'database', - 'providerRepositoryOwner': 'utopia', - 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', - 'providerCommitHash': '7c3f25d', - 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', - 'providerCommitAuthor': 'Khushboo Verma', - 'providerCommitMessage': 'Update index.js', - 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', - 'providerBranch': '0.7.x', - 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + type: 'vcs', + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + entrypoint: 'index.js', + sourceSize: 128, + buildSize: 128, + totalSize: 128, + buildId: '5e5ea5c16897e', + activate: true, + screenshotLight: '5e5ea5c16897e', + screenshotDark: '5e5ea5c16897e', + status: 'ready', + buildLogs: 'Compiling source files...', + buildDuration: 128, + providerRepositoryName: 'database', + providerRepositoryOwner: 'utopia', + providerRepositoryUrl: + 'https://github.com/vermakhushboo/g4-node-function', + providerCommitHash: '7c3f25d', + providerCommitAuthorUrl: 'https://github.com/vermakhushboo', + providerCommitAuthor: 'Khushboo Verma', + providerCommitMessage: 'Update index.js', + providerCommitUrl: + 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + providerBranch: '0.7.x', + providerBranchUrl: + 'https://github.com/vermakhushboo/appwrite/tree/0.7.x', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await functions.updateDeploymentStatus( '', '', @@ -560,75 +549,70 @@ describe('Functions', () => { expect(response).toEqual(data); }); - test('test method listExecutions()', async () => { - const data = { - 'total': 5, - 'executions': [],}; + const data = { + total: 5, + executions: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await functions.listExecutions( - '', - ); + const response = await functions.listExecutions(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createExecution()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + deploymentId: '5e5ea5c16897e', + trigger: 'http', + status: 'processing', + requestMethod: 'GET', + requestPath: '/articles?id=5', + requestHeaders: [], + responseStatusCode: 200, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0.4, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await functions.createExecution( - '', - ); + const response = await functions.createExecution(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getExecution()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + deploymentId: '5e5ea5c16897e', + trigger: 'http', + status: 'processing', + requestMethod: 'GET', + requestPath: '/articles?id=5', + requestHeaders: [], + responseStatusCode: 200, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0.4, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await functions.getExecution( '', '', @@ -639,11 +623,9 @@ describe('Functions', () => { expect(response).toEqual(data); }); - test('test method deleteExecution()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await functions.deleteExecution( '', '', @@ -654,35 +636,31 @@ describe('Functions', () => { expect(response).toEqual(data); }); - test('test method listVariables()', async () => { - const data = { - 'total': 5, - 'variables': [],}; + const data = { + total: 5, + variables: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await functions.listVariables( - '', - ); + const response = await functions.listVariables(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createVariable()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'API_KEY', - 'value': 'myPa\$\$word1', - 'secret': true, - 'resourceType': 'function', - 'resourceId': 'myAwesomeFunction',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'API_KEY', + value: 'myPa\\$\\$word1', + secret: true, + resourceType: 'function', + resourceId: 'myAwesomeFunction', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await functions.createVariable( '', '', @@ -695,19 +673,18 @@ describe('Functions', () => { expect(response).toEqual(data); }); - test('test method getVariable()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'API_KEY', - 'value': 'myPa\$\$word1', - 'secret': true, - 'resourceType': 'function', - 'resourceId': 'myAwesomeFunction',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'API_KEY', + value: 'myPa\\$\\$word1', + secret: true, + resourceType: 'function', + resourceId: 'myAwesomeFunction', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await functions.getVariable( '', '', @@ -718,19 +695,18 @@ describe('Functions', () => { expect(response).toEqual(data); }); - test('test method updateVariable()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'API_KEY', - 'value': 'myPa\$\$word1', - 'secret': true, - 'resourceType': 'function', - 'resourceId': 'myAwesomeFunction',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'API_KEY', + value: 'myPa\\$\\$word1', + secret: true, + resourceType: 'function', + resourceId: 'myAwesomeFunction', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await functions.updateVariable( '', '', @@ -741,11 +717,9 @@ describe('Functions', () => { expect(response).toEqual(data); }); - test('test method deleteVariable()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await functions.deleteVariable( '', '', @@ -756,4 +730,4 @@ describe('Functions', () => { expect(response).toEqual(data); }); - }) +}); diff --git a/test/services/graphql.test.js b/test/services/graphql.test.js index 6f2577da..e98c1c90 100644 --- a/test/services/graphql.test.js +++ b/test/services/graphql.test.js @@ -1,40 +1,34 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Graphql } = require("../../dist/services/graphql"); +const { Client } = require('../../dist/client'); +const { Graphql } = require('../../dist/services/graphql'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Graphql', () => { const client = new Client(); const graphql = new Graphql(client); - test('test method query()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await graphql.query( - {}, - ); + const response = await graphql.query({}); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method mutation()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await graphql.mutation( - {}, - ); + const response = await graphql.mutation({}); // 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/locale.test.js b/test/services/locale.test.js index 675b715e..eb2c3431 100644 --- a/test/services/locale.test.js +++ b/test/services/locale.test.js @@ -1,137 +1,123 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Locale } = require("../../dist/services/locale"); +const { Client } = require('../../dist/client'); +const { Locale } = require('../../dist/services/locale'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Locale', () => { const client = new Client(); const locale = new Locale(client); - test('test method get()', async () => { - const data = { - 'ip': '127.0.0.1', - 'countryCode': 'US', - 'country': 'United States', - 'continentCode': 'NA', - 'continent': 'North America', - 'eu': true, - 'currency': 'USD',}; + const data = { + ip: '127.0.0.1', + countryCode: 'US', + country: 'United States', + continentCode: 'NA', + continent: 'North America', + eu: true, + currency: 'USD', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await locale.get( - ); + const response = await locale.get(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listCodes()', async () => { - const data = { - 'total': 5, - 'localeCodes': [],}; + const data = { + total: 5, + localeCodes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await locale.listCodes( - ); + const response = await locale.listCodes(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listContinents()', async () => { - const data = { - 'total': 5, - 'continents': [],}; + const data = { + total: 5, + continents: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await locale.listContinents( - ); + const response = await locale.listContinents(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listCountries()', async () => { - const data = { - 'total': 5, - 'countries': [],}; + const data = { + total: 5, + countries: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await locale.listCountries( - ); + const response = await locale.listCountries(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listCountriesEU()', async () => { - const data = { - 'total': 5, - 'countries': [],}; + const data = { + total: 5, + countries: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await locale.listCountriesEU( - ); + const response = await locale.listCountriesEU(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listCountriesPhones()', async () => { - const data = { - 'total': 5, - 'phones': [],}; + const data = { + total: 5, + phones: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await locale.listCountriesPhones( - ); + const response = await locale.listCountriesPhones(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listCurrencies()', async () => { - const data = { - 'total': 5, - 'currencies': [],}; + const data = { + total: 5, + currencies: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await locale.listCurrencies( - ); + const response = await locale.listCurrencies(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listLanguages()', async () => { - const data = { - 'total': 5, - 'languages': [],}; + const data = { + total: 5, + languages: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await locale.listLanguages( - ); + const response = await locale.listLanguages(); // 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 007688e0..5afb42c2 100644 --- a/test/services/messaging.test.js +++ b/test/services/messaging.test.js @@ -1,44 +1,43 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Messaging } = require("../../dist/services/messaging"); +const { Client } = require('../../dist/client'); +const { Messaging } = require('../../dist/services/messaging'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Messaging', () => { const client = new Client(); const messaging = new Messaging(client); - test('test method listMessages()', async () => { - const data = { - 'total': 5, - 'messages': [],}; + const data = { + total: 5, + messages: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.listMessages( - ); + const response = await messaging.listMessages(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createEmail()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'providerType': 'email', - 'topics': [], - 'users': [], - 'targets': [], - 'deliveredTotal': 1, - 'data': {}, - 'status': 'processing',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + providerType: 'email', + topics: [], + users: [], + targets: [], + deliveredTotal: 1, + data: {}, + status: 'processing', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await messaging.createEmail( '', '', @@ -50,258 +49,222 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method updateEmail()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'providerType': 'email', - 'topics': [], - 'users': [], - 'targets': [], - 'deliveredTotal': 1, - 'data': {}, - 'status': 'processing',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + providerType: 'email', + topics: [], + users: [], + targets: [], + deliveredTotal: 1, + data: {}, + status: 'processing', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.updateEmail( - '', - ); + const response = await messaging.updateEmail(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createPush()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'providerType': 'email', - 'topics': [], - 'users': [], - 'targets': [], - 'deliveredTotal': 1, - 'data': {}, - 'status': 'processing',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + providerType: 'email', + topics: [], + users: [], + targets: [], + deliveredTotal: 1, + data: {}, + status: 'processing', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.createPush( - '', - ); + const response = await messaging.createPush(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updatePush()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'providerType': 'email', - 'topics': [], - 'users': [], - 'targets': [], - 'deliveredTotal': 1, - 'data': {}, - 'status': 'processing',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + providerType: 'email', + topics: [], + users: [], + targets: [], + deliveredTotal: 1, + data: {}, + status: 'processing', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.updatePush( - '', - ); + const response = await messaging.updatePush(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createSms()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'providerType': 'email', - 'topics': [], - 'users': [], - 'targets': [], - 'deliveredTotal': 1, - 'data': {}, - 'status': 'processing',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + providerType: 'email', + topics: [], + users: [], + targets: [], + deliveredTotal: 1, + data: {}, + status: 'processing', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.createSms( - '', - '', - ); + const response = await messaging.createSms('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createSMS()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'providerType': 'email', - 'topics': [], - 'users': [], - 'targets': [], - 'deliveredTotal': 1, - 'data': {}, - 'status': 'processing',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + providerType: 'email', + topics: [], + users: [], + targets: [], + deliveredTotal: 1, + data: {}, + status: 'processing', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.createSMS( - '', - '', - ); + const response = await messaging.createSMS('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateSms()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'providerType': 'email', - 'topics': [], - 'users': [], - 'targets': [], - 'deliveredTotal': 1, - 'data': {}, - 'status': 'processing',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + providerType: 'email', + topics: [], + users: [], + targets: [], + deliveredTotal: 1, + data: {}, + status: 'processing', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.updateSms( - '', - ); + const response = await messaging.updateSms(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateSMS()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'providerType': 'email', - 'topics': [], - 'users': [], - 'targets': [], - 'deliveredTotal': 1, - 'data': {}, - 'status': 'processing',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + providerType: 'email', + topics: [], + users: [], + targets: [], + deliveredTotal: 1, + data: {}, + status: 'processing', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.updateSMS( - '', - ); + const response = await messaging.updateSMS(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getMessage()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'providerType': 'email', - 'topics': [], - 'users': [], - 'targets': [], - 'deliveredTotal': 1, - 'data': {}, - 'status': 'processing',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + providerType: 'email', + topics: [], + users: [], + targets: [], + deliveredTotal: 1, + data: {}, + status: 'processing', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.getMessage( - '', - ); + const response = await messaging.getMessage(''); // 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: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.delete( - '', - ); + const response = await messaging.delete(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listTargets()', async () => { - const data = { - 'total': 5, - 'targets': [],}; + const data = { + total: 5, + targets: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.listTargets( - '', - ); + const response = await messaging.listTargets(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listProviders()', async () => { - const data = { - 'total': 5, - 'providers': [],}; + const data = { + total: 5, + providers: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.listProviders( - ); + const response = await messaging.listProviders(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createApnsProvider()', 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': {},}; + 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.createApnsProvider( '', '', @@ -312,19 +275,18 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method createAPNSProvider()', 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': {},}; + 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.createAPNSProvider( '', '', @@ -335,63 +297,56 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method updateApnsProvider()', 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': {},}; + 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.updateApnsProvider( - '', - ); + const response = await messaging.updateApnsProvider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateAPNSProvider()', 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': {},}; + 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.updateAPNSProvider( - '', - ); + const response = await messaging.updateAPNSProvider(''); // 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', - '\$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': {},}; + 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.createFcmProvider( '', '', @@ -402,19 +357,18 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method createFCMProvider()', 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': {},}; + 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.createFCMProvider( '', '', @@ -425,63 +379,56 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method updateFcmProvider()', 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': {},}; + 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.updateFcmProvider( - '', - ); + const response = await messaging.updateFcmProvider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateFCMProvider()', 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': {},}; + 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.updateFCMProvider( - '', - ); + const response = await messaging.updateFCMProvider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createMailgunProvider()', 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': {},}; + 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.createMailgunProvider( '', '', @@ -492,41 +439,37 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method updateMailgunProvider()', 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': {},}; + 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.updateMailgunProvider( - '', - ); + const response = await messaging.updateMailgunProvider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createMsg91Provider()', 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': {},}; + 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.createMsg91Provider( '', '', @@ -537,41 +480,37 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method updateMsg91Provider()', 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': {},}; + 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.updateMsg91Provider( - '', - ); + const response = await messaging.updateMsg91Provider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createResendProvider()', 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': {},}; + 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.createResendProvider( '', '', @@ -582,41 +521,37 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method updateResendProvider()', 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': {},}; + 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.updateResendProvider( - '', - ); + const response = await messaging.updateResendProvider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createSendgridProvider()', 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': {},}; + 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.createSendgridProvider( '', '', @@ -627,41 +562,38 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method updateSendgridProvider()', 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': {},}; + 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.updateSendgridProvider( - '', - ); + const response = + await messaging.updateSendgridProvider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createSesProvider()', 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': {},}; + 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.createSesProvider( '', '', @@ -672,41 +604,37 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method updateSesProvider()', 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': {},}; + 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.updateSesProvider( - '', - ); + const response = await messaging.updateSesProvider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createSmtpProvider()', 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': {},}; + 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.createSmtpProvider( '', '', @@ -718,19 +646,18 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method createSMTPProvider()', 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': {},}; + 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.createSMTPProvider( '', '', @@ -742,63 +669,56 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method updateSmtpProvider()', 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': {},}; + 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.updateSmtpProvider( - '', - ); + const response = await messaging.updateSmtpProvider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateSMTPProvider()', 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': {},}; + 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.updateSMTPProvider( - '', - ); + const response = await messaging.updateSMTPProvider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createTelesignProvider()', 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': {},}; + 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.createTelesignProvider( '', '', @@ -809,41 +729,38 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method updateTelesignProvider()', 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': {},}; + 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.updateTelesignProvider( - '', - ); + const response = + await messaging.updateTelesignProvider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createTextmagicProvider()', 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': {},}; + 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.createTextmagicProvider( '', '', @@ -854,41 +771,38 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method updateTextmagicProvider()', 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': {},}; + 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.updateTextmagicProvider( - '', - ); + const response = + await messaging.updateTextmagicProvider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createTwilioProvider()', 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': {},}; + 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.createTwilioProvider( '', '', @@ -899,41 +813,37 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method updateTwilioProvider()', 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': {},}; + 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.updateTwilioProvider( - '', - ); + const response = await messaging.updateTwilioProvider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createVonageProvider()', 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': {},}; + 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.createVonageProvider( '', '', @@ -944,190 +854,160 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method updateVonageProvider()', 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': {},}; + 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.updateVonageProvider( - '', - ); + const response = await messaging.updateVonageProvider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getProvider()', 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': {},}; + 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.getProvider( - '', - ); + const response = await messaging.getProvider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteProvider()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.deleteProvider( - '', - ); + const response = await messaging.deleteProvider(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listTopics()', async () => { - const data = { - 'total': 5, - 'topics': [],}; + const data = { + total: 5, + topics: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.listTopics( - ); + const response = await messaging.listTopics(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createTopic()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'events', - 'emailTotal': 100, - 'smsTotal': 100, - 'pushTotal': 100, - 'subscribe': [],}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'events', + emailTotal: 100, + smsTotal: 100, + pushTotal: 100, + subscribe: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.createTopic( - '', - '', - ); + const response = await messaging.createTopic('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getTopic()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'events', - 'emailTotal': 100, - 'smsTotal': 100, - 'pushTotal': 100, - 'subscribe': [],}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'events', + emailTotal: 100, + smsTotal: 100, + pushTotal: 100, + subscribe: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.getTopic( - '', - ); + const response = await messaging.getTopic(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateTopic()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'events', - 'emailTotal': 100, - 'smsTotal': 100, - 'pushTotal': 100, - 'subscribe': [],}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'events', + emailTotal: 100, + smsTotal: 100, + pushTotal: 100, + subscribe: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.updateTopic( - '', - ); + const response = await messaging.updateTopic(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteTopic()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.deleteTopic( - '', - ); + const response = await messaging.deleteTopic(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listSubscribers()', async () => { - const data = { - 'total': 5, - 'subscribers': [],}; + const data = { + total: 5, + subscribers: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await messaging.listSubscribers( - '', - ); + const response = await messaging.listSubscribers(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createSubscriber()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'targetId': '259125845563242502', - 'target': {}, - 'userId': '5e5ea5c16897e', - 'userName': 'Aegon Targaryen', - 'topicId': '259125845563242502', - 'providerType': 'email',}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + targetId: '259125845563242502', + target: {}, + userId: '5e5ea5c16897e', + userName: 'Aegon Targaryen', + topicId: '259125845563242502', + providerType: 'email', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await messaging.createSubscriber( '', '', @@ -1139,20 +1019,19 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method getSubscriber()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'targetId': '259125845563242502', - 'target': {}, - 'userId': '5e5ea5c16897e', - 'userName': 'Aegon Targaryen', - 'topicId': '259125845563242502', - 'providerType': 'email',}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + targetId: '259125845563242502', + target: {}, + userId: '5e5ea5c16897e', + userName: 'Aegon Targaryen', + topicId: '259125845563242502', + providerType: 'email', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await messaging.getSubscriber( '', '', @@ -1163,11 +1042,9 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - test('test method deleteSubscriber()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await messaging.deleteSubscriber( '', '', @@ -1178,4 +1055,4 @@ describe('Messaging', () => { expect(response).toEqual(data); }); - }) +}); diff --git a/test/services/mongo.test.js b/test/services/mongo.test.js new file mode 100644 index 00000000..eb7d7dc6 --- /dev/null +++ b/test/services/mongo.test.js @@ -0,0 +1,979 @@ +const { Client } = require('../../dist/client'); +const { Mongo } = require('../../dist/services/mongo'); + +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); + +describe('Mongo', () => { + const client = new Client(); + const mongo = new Mongo(client); + + test('test method list()', async () => { + const data = { + total: 5, + databases: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.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', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.create('', ''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listSpecifications()', async () => { + const data = { + specifications: [], + total: 9, + pricing: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.listSpecifications(); + + // 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', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.get(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method update()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.update(''); + + // 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 mongo.delete(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listBackups()', async () => { + const data = { + total: 5, + backups: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.listBackups(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBackup()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + policyId: '5e5ea5c16897e', + trigger: 'schedule', + type: 'full', + requestedType: 'incremental', + fallbackReason: + 'PostgreSQL incremental backups are not offered because they cannot be restored: archived WAL is physical and cannot replay onto a logically-restored base. A full backup was taken instead; use a point-in-time restore (targetTime) to recover to a moment between fulls.', + status: 'completed', + sizeBytes: 1073741824, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.createBackup(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listBackupPolicies()', async () => { + const data = { + total: 5, + policies: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.listBackupPolicies(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBackupPolicy()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + name: 'Hourly backups', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + services: [], + resources: [], + retention: 7, + schedule: '0 * * * *', + type: 'full', + enabled: true, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.createBackupPolicy( + '', + '', + '', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getBackupPolicy()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + name: 'Hourly backups', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + services: [], + resources: [], + retention: 7, + schedule: '0 * * * *', + type: 'full', + enabled: true, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.getBackupPolicy( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateBackupPolicy()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + name: 'Hourly backups', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + services: [], + resources: [], + retention: 7, + schedule: '0 * * * *', + type: 'full', + enabled: true, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.updateBackupPolicy( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteBackupPolicy()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.deleteBackupPolicy( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateBackupStorage()', async () => { + const data = { + provider: 's3', + bucket: 'my-backup-bucket', + region: 'us-east-1', + prefix: 'backups/', + endpoint: 'https://minio.example.com', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.updateBackupStorage( + '', + 's3', + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getBackup()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + policyId: '5e5ea5c16897e', + trigger: 'schedule', + type: 'full', + requestedType: 'incremental', + fallbackReason: + 'PostgreSQL incremental backups are not offered because they cannot be restored: archived WAL is physical and cannot replay onto a logically-restored base. A full backup was taken instead; use a point-in-time restore (targetTime) to recover to a moment between fulls.', + status: 'completed', + sizeBytes: 1073741824, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.getBackup('', ''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteBackup()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.deleteBackup( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listBranches()', async () => { + const data = { + total: 2, + branches: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.listBranches(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBranch()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.createBranch(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteBranch()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.deleteBranch( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateCredentials()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.updateCredentials(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createFailover()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.createFailover(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateMaintenance()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.updateMaintenance( + '', + 'sun', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createMigration()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.createMigration('', 'shared'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listOperations()', async () => { + const data = { + total: 5, + operations: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.listOperations(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPitr()', async () => { + const data = { + earliest: '2020-10-15T06:38:00.000+00:00', + latest: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.getPitr(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getReplicas()', async () => { + const data = { + replicas: 2, + syncMode: 'async', + syncDegraded: true, + syncAcknowledgements: 1, + syncStandbyCount: 2, + members: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.getReplicas(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listRestorations()', async () => { + const data = { + total: 5, + restorations: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.listRestorations(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRestoration()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + sourceDatabaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + backupId: '5e5ea5c16897e', + type: 'backup', + status: 'completed', + targetTime: '2020-10-15T06:38:00.000+00:00', + startedAt: '2020-10-15T06:38:00.000+00:00', + completedAt: '2020-10-15T06:38:00.000+00:00', + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.createRestoration(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getRestoration()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + sourceDatabaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + backupId: '5e5ea5c16897e', + type: 'backup', + status: 'completed', + targetTime: '2020-10-15T06:38:00.000+00:00', + startedAt: '2020-10-15T06:38:00.000+00:00', + completedAt: '2020-10-15T06:38:00.000+00:00', + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.getRestoration( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getStatus()', async () => { + const data = { + health: 'healthy', + ready: true, + engine: 'postgresql', + version: '17', + uptime: 86400, + connections: {}, + syncMode: 'async', + syncDegraded: true, + syncAcknowledgements: 1, + syncStandbyCount: 2, + replicas: [], + volumes: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.getStatus(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createUpgrade()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.createUpgrade( + '', + '', + ); + + // 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/mysql.test.js b/test/services/mysql.test.js new file mode 100644 index 00000000..3cd1e69a --- /dev/null +++ b/test/services/mysql.test.js @@ -0,0 +1,1038 @@ +const { Client } = require('../../dist/client'); +const { Mysql } = require('../../dist/services/mysql'); + +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); + +describe('Mysql', () => { + const client = new Client(); + const mysql = new Mysql(client); + + test('test method list()', async () => { + const data = { + total: 5, + databases: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.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', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.create('', ''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listSpecifications()', async () => { + const data = { + specifications: [], + total: 9, + pricing: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.listSpecifications(); + + // 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', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.get(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method update()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.update(''); + + // 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 mysql.delete(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listBackups()', async () => { + const data = { + total: 5, + backups: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.listBackups(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBackup()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + policyId: '5e5ea5c16897e', + trigger: 'schedule', + type: 'full', + requestedType: 'incremental', + fallbackReason: + 'PostgreSQL incremental backups are not offered because they cannot be restored: archived WAL is physical and cannot replay onto a logically-restored base. A full backup was taken instead; use a point-in-time restore (targetTime) to recover to a moment between fulls.', + status: 'completed', + sizeBytes: 1073741824, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.createBackup(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listBackupPolicies()', async () => { + const data = { + total: 5, + policies: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.listBackupPolicies(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBackupPolicy()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + name: 'Hourly backups', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + services: [], + resources: [], + retention: 7, + schedule: '0 * * * *', + type: 'full', + enabled: true, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.createBackupPolicy( + '', + '', + '', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getBackupPolicy()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + name: 'Hourly backups', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + services: [], + resources: [], + retention: 7, + schedule: '0 * * * *', + type: 'full', + enabled: true, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.getBackupPolicy( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateBackupPolicy()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + name: 'Hourly backups', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + services: [], + resources: [], + retention: 7, + schedule: '0 * * * *', + type: 'full', + enabled: true, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.updateBackupPolicy( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteBackupPolicy()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.deleteBackupPolicy( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateBackupStorage()', async () => { + const data = { + provider: 's3', + bucket: 'my-backup-bucket', + region: 'us-east-1', + prefix: 'backups/', + endpoint: 'https://minio.example.com', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.updateBackupStorage( + '', + 's3', + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getBackup()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + policyId: '5e5ea5c16897e', + trigger: 'schedule', + type: 'full', + requestedType: 'incremental', + fallbackReason: + 'PostgreSQL incremental backups are not offered because they cannot be restored: archived WAL is physical and cannot replay onto a logically-restored base. A full backup was taken instead; use a point-in-time restore (targetTime) to recover to a moment between fulls.', + status: 'completed', + sizeBytes: 1073741824, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.getBackup('', ''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteBackup()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.deleteBackup( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listBranches()', async () => { + const data = { + total: 2, + branches: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.listBranches(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBranch()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.createBranch(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteBranch()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.deleteBranch( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateCredentials()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.updateCredentials(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createExecution()', async () => { + const data = { + rows: [], + rowCount: 1, + columns: [], + durationMs: 12, + truncated: true, + bytes: 1024, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.createExecution('', ''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createFailover()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.createFailover(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateMaintenance()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.updateMaintenance( + '', + 'sun', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createMigration()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.createMigration('', 'shared'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listOperations()', async () => { + const data = { + total: 5, + operations: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.listOperations(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPitr()', async () => { + const data = { + earliest: '2020-10-15T06:38:00.000+00:00', + latest: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.getPitr(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPooler()', async () => { + const data = { + enabled: true, + mode: 'transaction', + maxConnections: 200, + defaultPoolSize: 25, + port: 6432, + readWriteSplitting: true, + poolerCpuRequest: '100m', + poolerCpuLimit: '200m', + poolerMemoryRequest: '64Mi', + poolerMemoryLimit: '128Mi', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.getPooler(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePooler()', async () => { + const data = { + enabled: true, + mode: 'transaction', + maxConnections: 200, + defaultPoolSize: 25, + port: 6432, + readWriteSplitting: true, + poolerCpuRequest: '100m', + poolerCpuLimit: '200m', + poolerMemoryRequest: '64Mi', + poolerMemoryLimit: '128Mi', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.updatePooler(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getReplicas()', async () => { + const data = { + replicas: 2, + syncMode: 'async', + syncDegraded: true, + syncAcknowledgements: 1, + syncStandbyCount: 2, + members: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.getReplicas(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listRestorations()', async () => { + const data = { + total: 5, + restorations: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.listRestorations(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRestoration()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + sourceDatabaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + backupId: '5e5ea5c16897e', + type: 'backup', + status: 'completed', + targetTime: '2020-10-15T06:38:00.000+00:00', + startedAt: '2020-10-15T06:38:00.000+00:00', + completedAt: '2020-10-15T06:38:00.000+00:00', + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.createRestoration(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getRestoration()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + sourceDatabaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + backupId: '5e5ea5c16897e', + type: 'backup', + status: 'completed', + targetTime: '2020-10-15T06:38:00.000+00:00', + startedAt: '2020-10-15T06:38:00.000+00:00', + completedAt: '2020-10-15T06:38:00.000+00:00', + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.getRestoration( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getStatus()', async () => { + const data = { + health: 'healthy', + ready: true, + engine: 'postgresql', + version: '17', + uptime: 86400, + connections: {}, + syncMode: 'async', + syncDegraded: true, + syncAcknowledgements: 1, + syncStandbyCount: 2, + replicas: [], + volumes: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.getStatus(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createUpgrade()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.createUpgrade( + '', + '', + ); + + // 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/oauth2.test.js b/test/services/oauth2.test.js index b1bf4c4f..7523dcf0 100644 --- a/test/services/oauth2.test.js +++ b/test/services/oauth2.test.js @@ -1,152 +1,140 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Oauth2 } = require("../../dist/services/oauth-2"); +const { Client } = require('../../dist/client'); +const { Oauth2 } = require('../../dist/services/oauth-2'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Oauth2', () => { const client = new Client(); const oauth2 = new Oauth2(client); - test('test method approve()', async () => { - const data = { - 'redirectUrl': 'https://example.com/callback?code=abcde&state=fghij',}; + const data = { + redirectUrl: 'https://example.com/callback?code=abcde&state=fghij', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await oauth2.approve( - '', - ); + const response = await oauth2.approve(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method authorize()', async () => { - const data = { - 'grantId': '5e5ea5c16897e', - 'redirectUrl': 'https://example.com/callback?code=abcde&state=fghij',}; + const data = { + grantId: '5e5ea5c16897e', + redirectUrl: 'https://example.com/callback?code=abcde&state=fghij', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await oauth2.authorize( - ); + const response = await oauth2.authorize(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method authorizePost()', async () => { - const data = { - 'grantId': '5e5ea5c16897e', - 'redirectUrl': 'https://example.com/callback?code=abcde&state=fghij',}; + const data = { + grantId: '5e5ea5c16897e', + redirectUrl: 'https://example.com/callback?code=abcde&state=fghij', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await oauth2.authorizePost( - ); + const response = await oauth2.authorizePost(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createDeviceAuthorization()', async () => { - const data = { - 'device_code': '5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a', - 'user_code': 'ABCD-EFGH', - 'verification_uri': 'https://cloud.appwrite.io/console/oauth2/device', - 'verification_uri_complete': 'https://cloud.appwrite.io/console/oauth2/device?user_code=ABCD-EFGH', - 'expires_in': 900, - 'interval': 5,}; + const data = { + device_code: + '5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a', + user_code: 'ABCD-EFGH', + verification_uri: 'https://cloud.appwrite.io/console/oauth2/device', + verification_uri_complete: + 'https://cloud.appwrite.io/console/oauth2/device?user_code=ABCD-EFGH', + expires_in: 900, + interval: 5, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await oauth2.createDeviceAuthorization( - ); + const response = await oauth2.createDeviceAuthorization(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createGrant()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'appId': '5e5ea5c16897e', - 'scopes': [], - 'resources': [], - 'authorizationDetails': '[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]', - 'prompt': 'login', - 'redirectUri': 'https://example.com/callback', - 'authTime': 1592981250, - 'expire': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c16897e', + appId: '5e5ea5c16897e', + scopes: [], + resources: [], + authorizationDetails: + '[{\\"type\\":\\"calendar\\",\\"identifier\\":\\"primary\\",\\"actions\\":[\\"read_events\\",\\"create_event\\"]}]', + prompt: 'login', + redirectUri: 'https://example.com/callback', + authTime: 1592981250, + expire: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await oauth2.createGrant( - '', - ); + const response = await oauth2.createGrant(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getGrant()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'appId': '5e5ea5c16897e', - 'scopes': [], - 'resources': [], - 'authorizationDetails': '[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]', - 'prompt': 'login', - 'redirectUri': 'https://example.com/callback', - 'authTime': 1592981250, - 'expire': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c16897e', + appId: '5e5ea5c16897e', + scopes: [], + resources: [], + authorizationDetails: + '[{\\"type\\":\\"calendar\\",\\"identifier\\":\\"primary\\",\\"actions\\":[\\"read_events\\",\\"create_event\\"]}]', + prompt: 'login', + redirectUri: 'https://example.com/callback', + authTime: 1592981250, + expire: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await oauth2.getGrant( - '', - ); + const response = await oauth2.getGrant(''); // 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, - 'organizations': [],}; + const data = { + total: 5, + organizations: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await oauth2.listOrganizations( - ); + const response = await oauth2.listOrganizations(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createPAR()', async () => { - const data = { - 'request_uri': 'urn:appwrite:oauth2:request:5e5ea5c16897e', - 'expires_in': 600,}; + const data = { + request_uri: 'urn:appwrite:oauth2:request:5e5ea5c16897e', + expires_in: 600, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await oauth2.createPAR( '', 'https://example.com', @@ -158,67 +146,56 @@ describe('Oauth2', () => { expect(response).toEqual(data); }); - test('test method listProjects()', async () => { - const data = { - 'total': 5, - 'projects': [],}; + const data = { + total: 5, + projects: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await oauth2.listProjects( - ); + const response = await oauth2.listProjects(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method reject()', async () => { - const data = { - 'redirectUrl': 'https://example.com/callback?error=access_denied&state=fghij',}; + const data = { + redirectUrl: + 'https://example.com/callback?error=access_denied&state=fghij', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await oauth2.reject( - '', - ); + const response = await oauth2.reject(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method revoke()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await oauth2.revoke( - '', - ); + const response = await oauth2.revoke(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createToken()', async () => { - const data = { - 'access_token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...', - 'token_type': 'Bearer', - 'expires_in': 3600, - 'refresh_token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...', - 'scope': 'openid email profile',}; + const data = { + access_token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...', + token_type: 'Bearer', + expires_in: 3600, + refresh_token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...', + scope: 'openid email profile', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await oauth2.createToken( - '', - ); + const response = await oauth2.createToken(''); // 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/organization.test.js b/test/services/organization.test.js index 70ae6049..d01389af 100644 --- a/test/services/organization.test.js +++ b/test/services/organization.test.js @@ -1,391 +1,345 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Organization } = require("../../dist/services/organization"); +const { Client } = require('../../dist/client'); +const { Organization } = require('../../dist/services/organization'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Organization', () => { const client = new Client(); const organization = new Organization(client); - 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', - 'name': 'VIP', - 'total': 7, - 'prefs': {}, - 'budgetAlerts': [], - 'billingPlan': 'tier-1', - 'billingPlanId': 'tier-1', - 'billingPlanDetails': {}, - 'billingEmail': 'billing@org.example', - 'billingStartDate': '2020-10-15T06:38:00.000+00:00', - 'billingCurrentInvoiceDate': '2020-10-15T06:38:00.000+00:00', - 'billingNextInvoiceDate': '2020-10-15T06:38:00.000+00:00', - 'billingTrialDays': 14, - 'billingAggregationId': 'adbc3de4rddfsd', - 'billingInvoiceId': 'adbc3de4rddfsd', - 'paymentMethodId': 'adbc3de4rddfsd', - 'status': 'active', - 'markedForDeletion': true, - 'platform': 'imagine', - 'projects': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'VIP', + total: 7, + prefs: {}, + budgetAlerts: [], + billingPlan: 'tier-1', + billingPlanId: 'tier-1', + billingPlanDetails: {}, + billingEmail: 'billing@org.example', + billingStartDate: '2020-10-15T06:38:00.000+00:00', + billingCurrentInvoiceDate: '2020-10-15T06:38:00.000+00:00', + billingNextInvoiceDate: '2020-10-15T06:38:00.000+00:00', + billingTrialDays: 14, + billingAggregationId: 'adbc3de4rddfsd', + billingInvoiceId: 'adbc3de4rddfsd', + paymentMethodId: 'adbc3de4rddfsd', + status: 'active', + markedForDeletion: true, + platform: 'imagine', + projects: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.get( - ); + const response = await organization.get(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method update()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {}, - 'budgetAlerts': [], - 'billingPlan': 'tier-1', - 'billingPlanId': 'tier-1', - 'billingPlanDetails': {}, - 'billingEmail': 'billing@org.example', - 'billingStartDate': '2020-10-15T06:38:00.000+00:00', - 'billingCurrentInvoiceDate': '2020-10-15T06:38:00.000+00:00', - 'billingNextInvoiceDate': '2020-10-15T06:38:00.000+00:00', - 'billingTrialDays': 14, - 'billingAggregationId': 'adbc3de4rddfsd', - 'billingInvoiceId': 'adbc3de4rddfsd', - 'paymentMethodId': 'adbc3de4rddfsd', - 'status': 'active', - 'markedForDeletion': true, - 'platform': 'imagine', - 'projects': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'VIP', + total: 7, + prefs: {}, + budgetAlerts: [], + billingPlan: 'tier-1', + billingPlanId: 'tier-1', + billingPlanDetails: {}, + billingEmail: 'billing@org.example', + billingStartDate: '2020-10-15T06:38:00.000+00:00', + billingCurrentInvoiceDate: '2020-10-15T06:38:00.000+00:00', + billingNextInvoiceDate: '2020-10-15T06:38:00.000+00:00', + billingTrialDays: 14, + billingAggregationId: 'adbc3de4rddfsd', + billingInvoiceId: 'adbc3de4rddfsd', + paymentMethodId: 'adbc3de4rddfsd', + status: 'active', + markedForDeletion: true, + platform: 'imagine', + projects: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.update( - '', - ); + const response = await organization.update(''); // 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: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.delete( - ); + const response = await organization.delete(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listInstallations()', async () => { - const data = { - 'total': 5, - 'installations': [],}; + const data = { + total: 5, + installations: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.listInstallations( - ); + const response = await organization.listInstallations(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createInstallation()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'teamId': '5e5ea5c16897e', - 'scopes': [], - 'authorizationDetails': {}, - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + appId: '5e5ea5c16897e', + teamId: '5e5ea5c16897e', + scopes: [], + authorizationDetails: [], + createdById: '5e5ea5c16897e', + createdByName: 'Walter White', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.createInstallation( - '', - ); + const response = await organization.createInstallation(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getInstallation()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'teamId': '5e5ea5c16897e', - 'scopes': [], - 'authorizationDetails': {}, - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + appId: '5e5ea5c16897e', + teamId: '5e5ea5c16897e', + scopes: [], + authorizationDetails: [], + createdById: '5e5ea5c16897e', + createdByName: 'Walter White', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.getInstallation( - '', - ); + const response = + await organization.getInstallation(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateInstallation()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'teamId': '5e5ea5c16897e', - 'scopes': [], - 'authorizationDetails': {}, - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + appId: '5e5ea5c16897e', + teamId: '5e5ea5c16897e', + scopes: [], + authorizationDetails: [], + createdById: '5e5ea5c16897e', + createdByName: 'Walter White', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.updateInstallation( - '', - ); + const response = + await organization.updateInstallation(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteInstallation()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.deleteInstallation( - '', - ); + const response = + await organization.deleteInstallation(''); // 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, - 'keys': [],}; + const data = { + total: 5, + keys: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.listKeys( - ); + const response = await organization.listKeys(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createKey()', 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': [],}; + 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.createKey( - '', - '', - [], - ); + const response = await organization.createKey('', '', []); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getKey()', 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': [],}; + 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.getKey( - '', - ); + const response = await organization.getKey(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateKey()', 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': [],}; + 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.updateKey( - '', - '', - [], - ); + const response = await organization.updateKey('', '', []); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteKey()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.deleteKey( - '', - ); + const response = await organization.deleteKey(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listMemberships()', async () => { - const data = { - 'total': 5, - 'memberships': [],}; + const data = { + total: 5, + memberships: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.listMemberships( - ); + const response = await organization.listMemberships(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createMembership()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c16897e', + userName: 'John Doe', + userEmail: 'john@appwrite.io', + userPhone: '+1 555 555 5555', + teamId: '5e5ea5c16897e', + teamName: 'VIP', + invited: '2020-10-15T06:38:00.000+00:00', + joined: '2020-10-15T06:38:00.000+00:00', + confirm: true, + mfa: true, + userAccessedAt: '2020-10-15T06:38:00.000+00:00', + roles: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.createMembership( - [], - ); + const response = await organization.createMembership([]); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getMembership()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c16897e', + userName: 'John Doe', + userEmail: 'john@appwrite.io', + userPhone: '+1 555 555 5555', + teamId: '5e5ea5c16897e', + teamName: 'VIP', + invited: '2020-10-15T06:38:00.000+00:00', + joined: '2020-10-15T06:38:00.000+00:00', + confirm: true, + mfa: true, + userAccessedAt: '2020-10-15T06:38:00.000+00:00', + roles: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.getMembership( - '', - ); + const response = await organization.getMembership(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateMembership()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c16897e', + userName: 'John Doe', + userEmail: 'john@appwrite.io', + userPhone: '+1 555 555 5555', + teamId: '5e5ea5c16897e', + teamName: 'VIP', + invited: '2020-10-15T06:38:00.000+00:00', + joined: '2020-10-15T06:38:00.000+00:00', + confirm: true, + mfa: true, + userAccessedAt: '2020-10-15T06:38:00.000+00:00', + roles: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await organization.updateMembership( '', [], @@ -396,70 +350,62 @@ describe('Organization', () => { expect(response).toEqual(data); }); - test('test method deleteMembership()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.deleteMembership( - '', - ); + const response = await organization.deleteMembership(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listProjects()', async () => { - const data = { - 'total': 5, - 'projects': [],}; + const data = { + total: 5, + projects: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.listProjects( - ); + const response = await organization.listProjects(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createProject()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; + 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', + devKeys: [], + 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 organization.createProject( - '', + '', '', ); @@ -468,81 +414,75 @@ describe('Organization', () => { expect(response).toEqual(data); }); - test('test method getProject()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; + 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', + devKeys: [], + 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 organization.getProject( - '', - ); + const response = await organization.getProject(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateProject()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; + 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', + devKeys: [], + 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 organization.updateProject( '', '', @@ -553,18 +493,14 @@ describe('Organization', () => { expect(response).toEqual(data); }); - test('test method deleteProject()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await organization.deleteProject( - '', - ); + const response = await organization.deleteProject(''); // 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/postgresql.test.js b/test/services/postgresql.test.js new file mode 100644 index 00000000..eb277f23 --- /dev/null +++ b/test/services/postgresql.test.js @@ -0,0 +1,1183 @@ +const { Client } = require('../../dist/client'); +const { Postgresql } = require('../../dist/services/postgresql'); + +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); + +describe('Postgresql', () => { + const client = new Client(); + const postgresql = new Postgresql(client); + + test('test method list()', async () => { + const data = { + total: 5, + databases: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.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', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.create('', ''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listSpecifications()', async () => { + const data = { + specifications: [], + total: 9, + pricing: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.listSpecifications(); + + // 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', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.get(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method update()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.update(''); + + // 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 postgresql.delete(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listBackups()', async () => { + const data = { + total: 5, + backups: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.listBackups(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBackup()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + policyId: '5e5ea5c16897e', + trigger: 'schedule', + type: 'full', + requestedType: 'incremental', + fallbackReason: + 'PostgreSQL incremental backups are not offered because they cannot be restored: archived WAL is physical and cannot replay onto a logically-restored base. A full backup was taken instead; use a point-in-time restore (targetTime) to recover to a moment between fulls.', + status: 'completed', + sizeBytes: 1073741824, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.createBackup(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listBackupPolicies()', async () => { + const data = { + total: 5, + policies: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.listBackupPolicies(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBackupPolicy()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + name: 'Hourly backups', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + services: [], + resources: [], + retention: 7, + schedule: '0 * * * *', + type: 'full', + enabled: true, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.createBackupPolicy( + '', + '', + '', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getBackupPolicy()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + name: 'Hourly backups', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + services: [], + resources: [], + retention: 7, + schedule: '0 * * * *', + type: 'full', + enabled: true, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.getBackupPolicy( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateBackupPolicy()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + name: 'Hourly backups', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + services: [], + resources: [], + retention: 7, + schedule: '0 * * * *', + type: 'full', + enabled: true, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.updateBackupPolicy( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteBackupPolicy()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.deleteBackupPolicy( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateBackupStorage()', async () => { + const data = { + provider: 's3', + bucket: 'my-backup-bucket', + region: 'us-east-1', + prefix: 'backups/', + endpoint: 'https://minio.example.com', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.updateBackupStorage( + '', + 's3', + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getBackup()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + policyId: '5e5ea5c16897e', + trigger: 'schedule', + type: 'full', + requestedType: 'incremental', + fallbackReason: + 'PostgreSQL incremental backups are not offered because they cannot be restored: archived WAL is physical and cannot replay onto a logically-restored base. A full backup was taken instead; use a point-in-time restore (targetTime) to recover to a moment between fulls.', + status: 'completed', + sizeBytes: 1073741824, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.getBackup( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteBackup()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.deleteBackup( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listBranches()', async () => { + const data = { + total: 2, + branches: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.listBranches(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBranch()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.createBranch(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteBranch()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.deleteBranch( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateCredentials()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.updateCredentials(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createExecution()', async () => { + const data = { + rows: [], + rowCount: 1, + columns: [], + durationMs: 12, + truncated: true, + bytes: 1024, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.createExecution( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listExtensions()', async () => { + const data = { + installed: [], + available: [], + metadata: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.listExtensions(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createExtension()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.createExtension( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteExtension()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.deleteExtension( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createFailover()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.createFailover(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateMaintenance()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.updateMaintenance( + '', + 'sun', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createMigration()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.createMigration( + '', + 'shared', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listOperations()', async () => { + const data = { + total: 5, + operations: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.listOperations(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPitr()', async () => { + const data = { + earliest: '2020-10-15T06:38:00.000+00:00', + latest: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.getPitr(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPooler()', async () => { + const data = { + enabled: true, + mode: 'transaction', + maxConnections: 200, + defaultPoolSize: 25, + port: 6432, + readWriteSplitting: true, + poolerCpuRequest: '100m', + poolerCpuLimit: '200m', + poolerMemoryRequest: '64Mi', + poolerMemoryLimit: '128Mi', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.getPooler(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePooler()', async () => { + const data = { + enabled: true, + mode: 'transaction', + maxConnections: 200, + defaultPoolSize: 25, + port: 6432, + readWriteSplitting: true, + poolerCpuRequest: '100m', + poolerCpuLimit: '200m', + poolerMemoryRequest: '64Mi', + poolerMemoryLimit: '128Mi', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.updatePooler(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getReplicas()', async () => { + const data = { + replicas: 2, + syncMode: 'async', + syncDegraded: true, + syncAcknowledgements: 1, + syncStandbyCount: 2, + members: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.getReplicas(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listRestorations()', async () => { + const data = { + total: 5, + restorations: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.listRestorations(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRestoration()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + sourceDatabaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + backupId: '5e5ea5c16897e', + type: 'backup', + status: 'completed', + targetTime: '2020-10-15T06:38:00.000+00:00', + startedAt: '2020-10-15T06:38:00.000+00:00', + completedAt: '2020-10-15T06:38:00.000+00:00', + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.createRestoration(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getRestoration()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + sourceDatabaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + backupId: '5e5ea5c16897e', + type: 'backup', + status: 'completed', + targetTime: '2020-10-15T06:38:00.000+00:00', + startedAt: '2020-10-15T06:38:00.000+00:00', + completedAt: '2020-10-15T06:38:00.000+00:00', + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.getRestoration( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getStatus()', async () => { + const data = { + health: 'healthy', + ready: true, + engine: 'postgresql', + version: '17', + uptime: 86400, + connections: {}, + syncMode: 'async', + syncDegraded: true, + syncAcknowledgements: 1, + syncStandbyCount: 2, + replicas: [], + volumes: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.getStatus(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createUpgrade()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.createUpgrade( + '', + '', + ); + + // 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/presences.test.js b/test/services/presences.test.js index 5f570ccb..b388216d 100644 --- a/test/services/presences.test.js +++ b/test/services/presences.test.js @@ -1,60 +1,56 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Presences } = require("../../dist/services/presences"); +const { Client } = require('../../dist/client'); +const { Presences } = require('../../dist/services/presences'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Presences', () => { const client = new Client(); const presences = new Presences(client); - test('test method list()', async () => { - const data = { - 'total': 5, - 'presences': [],}; + const data = { + total: 5, + presences: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await presences.list( - ); + const response = await presences.list(); // 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', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + userId: '674af8f3e12a5f9ac0be', + source: 'HTTP', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await presences.get( - '', - ); + const response = await presences.get(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method upsert()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + userId: '674af8f3e12a5f9ac0be', + source: 'HTTP', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await presences.upsert( '', '', @@ -66,39 +62,31 @@ describe('Presences', () => { expect(response).toEqual(data); }); - test('test method update()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + userId: '674af8f3e12a5f9ac0be', + source: 'HTTP', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await presences.update( - '', - '', - ); + const response = await presences.update('', ''); // 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: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await presences.delete( - '', - ); + const response = await presences.delete(''); // 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 44703bc7..0093f1ee 100644 --- a/test/services/project.test.js +++ b/test/services/project.test.js @@ -1,387 +1,335 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Project } = require("../../dist/services/project"); +const { Client } = require('../../dist/client'); +const { Project } = require('../../dist/services/project'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Project', () => { const client = new Client(); const project = new Project(client); - 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', - 'name': 'New Project', - 'teamId': '1592981250', - 'region': 'fra', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.get( - ); + 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', + devKeys: [], + 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.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: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.delete( - ); + const response = await project.delete(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateAuthMethod()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateAuthMethod( - 'email-password', - true, - ); + 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', + devKeys: [], + 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.updateAuthMethod('email-password', true); // 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, - 'keys': [],}; + const data = { + total: 5, + keys: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.listKeys( - ); + const response = await project.listKeys(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createEphemeralKey()', 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 project.createEphemeralKey( - [], - 1, - ); + 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 project.createEphemeralKey([], 1); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getKey()', 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 project.getKey( - '', - ); + 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 project.getKey(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateKey()', 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 project.updateKey( - '', - '', - [], - ); + 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 project.updateKey('', '', []); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteKey()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.deleteKey( - '', - ); + const response = await project.deleteKey(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateLabels()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateLabels( - [], - ); + 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', + devKeys: [], + 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.updateLabels([]); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listMockPhones()', async () => { - const data = { - 'total': 5, - 'mockNumbers': [],}; + const data = { + total: 5, + mockNumbers: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.listMockPhones( - ); + const response = await project.listMockPhones(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createMockPhone()', async () => { - const data = { - 'number': '+1612842323', - 'otp': '123456', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + number: '+1612842323', + otp: '123456', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.createMockPhone( - '+12065550100', - '', - ); + const response = await project.createMockPhone('+12065550100', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getMockPhone()', async () => { - const data = { - 'number': '+1612842323', - 'otp': '123456', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + number: '+1612842323', + otp: '123456', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.getMockPhone( - '+12065550100', - ); + const response = await project.getMockPhone('+12065550100'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateMockPhone()', async () => { - const data = { - 'number': '+1612842323', - 'otp': '123456', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + number: '+1612842323', + otp: '123456', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateMockPhone( - '+12065550100', - '', - ); + const response = await project.updateMockPhone('+12065550100', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteMockPhone()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.deleteMockPhone( - '+12065550100', - ); + const response = await project.deleteMockPhone('+12065550100'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listOAuth2Providers()', async () => { - const data = { - 'total': 5, - 'providers': [],}; + const data = { + total: 5, + providers: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.listOAuth2Providers( - ); + const response = await project.listOAuth2Providers(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Server()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; + 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', + devKeys: [], + 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.updateOAuth2Server( true, 'https://example.com', @@ -392,799 +340,745 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method updateOAuth2Amazon()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'amzn1.application-oa2-client.87400c00000000000000000000063d5b2', - 'clientSecret': '79ffe4000000000000000000000000000000000000000000000000000002de55',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: + 'amzn1.application-oa2-client.87400c00000000000000000000063d5b2', + clientSecret: + '79ffe4000000000000000000000000000000000000000000000000000002de55', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Amazon( - ); + const response = await project.updateOAuth2Amazon(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Apple()', async () => { - const data = { - '\$id': 'apple', - 'enabled': true, - 'serviceId': 'ip.appwrite.app.web', - 'keyId': 'P4000000N8', - 'teamId': 'D4000000R6', - 'p8File': '-----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY-----',}; + const data = { + '\\$id': 'apple', + enabled: true, + serviceId: 'ip.appwrite.app.web', + keyId: 'P4000000N8', + teamId: 'D4000000R6', + p8File: '-----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY-----', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Apple( - ); + const response = await project.updateOAuth2Apple(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Appwrite()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': '6a42000000000000b5a0', - 'clientSecret': 'b86afd000000000000000000000000000000000000000000000000000ced5f93',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: '6a42000000000000b5a0', + clientSecret: + 'b86afd000000000000000000000000000000000000000000000000000ced5f93', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Appwrite( - ); + const response = await project.updateOAuth2Appwrite(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Auth0()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'OaOkIA000000000000000000005KLSYq', - 'clientSecret': 'zXz0000-00000000000000000000000000000-00000000000000000000PJafnF', - 'endpoint': 'example.us.auth0.com',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: 'OaOkIA000000000000000000005KLSYq', + clientSecret: + 'zXz0000-00000000000000000000000000000-00000000000000000000PJafnF', + endpoint: 'example.us.auth0.com', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Auth0( - ); + const response = await project.updateOAuth2Auth0(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Authentik()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'dTKOPa0000000000000000000000000000e7G8hv', - 'clientSecret': 'ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK', - 'endpoint': 'example.authentik.com',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: 'dTKOPa0000000000000000000000000000e7G8hv', + clientSecret: + 'ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK', + endpoint: 'example.authentik.com', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Authentik( - ); + const response = await project.updateOAuth2Authentik(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Autodesk()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': '5zw90v00000000000000000000kVYXN7', - 'clientSecret': '7I000000000000MW',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: '5zw90v00000000000000000000kVYXN7', + clientSecret: '7I000000000000MW', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Autodesk( - ); + const response = await project.updateOAuth2Autodesk(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Bitbucket()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'key': 'Knt70000000000ByRc', - 'secret': 'NMfLZJ00000000000000000000TLQdDx',}; + const data = { + '\\$id': 'github', + enabled: true, + key: 'Knt70000000000ByRc', + secret: 'NMfLZJ00000000000000000000TLQdDx', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Bitbucket( - ); + const response = await project.updateOAuth2Bitbucket(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Bitly()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'd95151000000000000000000000000000067af9b', - 'clientSecret': 'a13e250000000000000000000000000000d73095',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: 'd95151000000000000000000000000000067af9b', + clientSecret: 'a13e250000000000000000000000000000d73095', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Bitly( - ); + const response = await project.updateOAuth2Bitly(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Box()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'deglcs00000000000000000000x2og6y', - 'clientSecret': 'OKM1f100000000000000000000eshEif',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: 'deglcs00000000000000000000x2og6y', + clientSecret: 'OKM1f100000000000000000000eshEif', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Box( - ); + const response = await project.updateOAuth2Box(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Dailymotion()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'apiKey': '07a9000000000000067f', - 'apiSecret': 'a399a90000000000000000000000000000d90639',}; + const data = { + '\\$id': 'github', + enabled: true, + apiKey: '07a9000000000000067f', + apiSecret: 'a399a90000000000000000000000000000d90639', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Dailymotion( - ); + const response = await project.updateOAuth2Dailymotion(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Discord()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': '950722000000343754', - 'clientSecret': 'YmPXnM000000000000000000002zFg5D',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: '950722000000343754', + clientSecret: 'YmPXnM000000000000000000002zFg5D', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Discord( - ); + const response = await project.updateOAuth2Discord(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Disqus()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'publicKey': 'cgegH70000000000000000000000000000000000000000000000000000Hr1nYX', - 'secretKey': 'W7Bykj00000000000000000000000000000000000000000000000000003o43w9',}; + const data = { + '\\$id': 'github', + enabled: true, + publicKey: + 'cgegH70000000000000000000000000000000000000000000000000000Hr1nYX', + secretKey: + 'W7Bykj00000000000000000000000000000000000000000000000000003o43w9', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Disqus( - ); + const response = await project.updateOAuth2Disqus(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Dropbox()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'appKey': 'jl000000000009t', - 'appSecret': 'g200000000000vw',}; + const data = { + '\\$id': 'github', + enabled: true, + appKey: 'jl000000000009t', + appSecret: 'g200000000000vw', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Dropbox( - ); + const response = await project.updateOAuth2Dropbox(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Etsy()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'keyString': 'nsgzxh0000000000008j85a2', - 'sharedSecret': 'tp000000ru',}; + const data = { + '\\$id': 'github', + enabled: true, + keyString: 'nsgzxh0000000000008j85a2', + sharedSecret: 'tp000000ru', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Etsy( - ); + const response = await project.updateOAuth2Etsy(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Facebook()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'appId': '260600000007694', - 'appSecret': '2d0b2800000000000000000000d38af4',}; + const data = { + '\\$id': 'github', + enabled: true, + appId: '260600000007694', + appSecret: '2d0b2800000000000000000000d38af4', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Facebook( - ); + const response = await project.updateOAuth2Facebook(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Figma()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'byay5H0000000000VtiI40', - 'clientSecret': 'yEpOYn0000000000000000004iIsU5',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: 'byay5H0000000000VtiI40', + clientSecret: 'yEpOYn0000000000000000004iIsU5', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Figma( - ); + const response = await project.updateOAuth2Figma(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2FusionAuth()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'b2222c00-0000-0000-0000-000000862097', - 'clientSecret': 'Jx4s0C0000000000000000000000000000000wGqLsc', - 'endpoint': 'example.fusionauth.io',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: 'b2222c00-0000-0000-0000-000000862097', + clientSecret: 'Jx4s0C0000000000000000000000000000000wGqLsc', + endpoint: 'example.fusionauth.io', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2FusionAuth( - ); + const response = await project.updateOAuth2FusionAuth(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2GitHub()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'e4d87900000000540733', - 'clientSecret': '5e07c00000000000000000000000000000198bcc',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: 'e4d87900000000540733', + clientSecret: '5e07c00000000000000000000000000000198bcc', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2GitHub( - ); + const response = await project.updateOAuth2GitHub(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Gitlab()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'applicationId': 'd41ffe0000000000000000000000000000000000000000000000000000d5e252', - 'secret': 'gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38', - 'endpoint': 'https://gitlab.com',}; + const data = { + '\\$id': 'github', + enabled: true, + applicationId: + 'd41ffe0000000000000000000000000000000000000000000000000000d5e252', + secret: 'gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38', + endpoint: 'https://gitlab.com', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Gitlab( - ); + const response = await project.updateOAuth2Gitlab(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Google()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': '120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com', - 'clientSecret': 'GOCSPX-2k8gsR0000000000000000VNahJj', - 'prompt': [],}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: + '120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com', + clientSecret: 'GOCSPX-2k8gsR0000000000000000VNahJj', + prompt: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateOAuth2Google(); - const response = await project.updateOAuth2Google( - ); + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateOAuth2HuggingFace()', async () => { + const data = { + '\\$id': 'github', + enabled: true, + clientId: '2ab9cff9-d711-40ad-a91e-b08a49c42d24', + clientSecret: 'oauth_app_secret_wcLhRtl000000000000000000000xbNdLt', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateOAuth2HuggingFace(); // 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', - 'enabled': true, - 'clientId': 'appwrite-o0000000st-app', - 'clientSecret': 'jdjrJd00000000000000000000HUsaZO', - 'endpoint': 'keycloak.example.com', - 'realmName': 'appwrite-realm',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: 'appwrite-o0000000st-app', + clientSecret: 'jdjrJd00000000000000000000HUsaZO', + endpoint: 'keycloak.example.com', + realmName: 'appwrite-realm', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Keycloak( - ); + const response = await project.updateOAuth2Keycloak(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Kick()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': '01KQ7C00000000000001MFHS32', - 'clientSecret': '34ac5600000000000000000000000000000000000000000000000000e830c8b',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: '01KQ7C00000000000001MFHS32', + clientSecret: + '34ac5600000000000000000000000000000000000000000000000000e830c8b', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Kick( - ); + const response = await project.updateOAuth2Kick(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Linkedin()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': '770000000000dv', - 'primaryClientSecret': 'WPL_AP1.2Bf0000000000000./HtlYw==',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: '770000000000dv', + primaryClientSecret: 'WPL_AP1.2Bf0000000000000./HtlYw==', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Linkedin( - ); + const response = await project.updateOAuth2Linkedin(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Microsoft()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'applicationId': '00001111-aaaa-2222-bbbb-3333cccc4444', - 'applicationSecret': 'A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u', - 'tenant': 'common',}; + const data = { + '\\$id': 'github', + enabled: true, + applicationId: '00001111-aaaa-2222-bbbb-3333cccc4444', + applicationSecret: 'A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u', + tenant: 'common', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Microsoft( - ); + const response = await project.updateOAuth2Microsoft(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Notion()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'oauthClientId': '341d8700-0000-0000-0000-000000446ee3', - 'oauthClientSecret': 'secret_dLUr4b000000000000000000000000000000lFHAa9',}; + const data = { + '\\$id': 'github', + enabled: true, + oauthClientId: '341d8700-0000-0000-0000-000000446ee3', + oauthClientSecret: + 'secret_dLUr4b000000000000000000000000000000lFHAa9', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Notion( - ); + const response = await project.updateOAuth2Notion(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Oidc()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'qibI2x0000000000000000000000000006L2YFoG', - 'clientSecret': 'Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV', - 'wellKnownURL': 'https://myoauth.com/.well-known/openid-configuration', - 'authorizationURL': 'https://myoauth.com/oauth2/authorize', - 'tokenURL': 'https://myoauth.com/oauth2/token', - 'userInfoURL': 'https://myoauth.com/oauth2/userinfo', - 'prompt': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Oidc( - ); + const data = { + '\\$id': 'github', + enabled: true, + clientId: 'qibI2x0000000000000000000000000006L2YFoG', + clientSecret: + 'Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV', + wellKnownURL: + 'https://myoauth.com/.well-known/openid-configuration', + authorizationURL: 'https://myoauth.com/oauth2/authorize', + tokenURL: 'https://myoauth.com/oauth2/token', + userInfoURL: 'https://myoauth.com/oauth2/userinfo', + prompt: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateOAuth2Oidc(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Okta()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': '0oa00000000000000698', - 'clientSecret': 'Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV', - 'domain': 'trial-6400025.okta.com', - 'authorizationServerId': 'aus000000000000000h7z',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: '0oa00000000000000698', + clientSecret: + 'Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV', + domain: 'trial-6400025.okta.com', + authorizationServerId: 'aus000000000000000h7z', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Okta( - ); + const response = await project.updateOAuth2Okta(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Paypal()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', - 'secretKey': 'EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: + 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', + secretKey: + 'EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Paypal( - ); + const response = await project.updateOAuth2Paypal(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2PaypalSandbox()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', - 'secretKey': 'EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: + 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', + secretKey: + 'EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2PaypalSandbox( - ); + const response = await project.updateOAuth2PaypalSandbox(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Podio()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'appwrite-oauth-test-app', - 'clientSecret': 'Rn247T0000000000000000000000000000000000000000000000000000W2zWTN',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: 'appwrite-oauth-test-app', + clientSecret: + 'Rn247T0000000000000000000000000000000000000000000000000000W2zWTN', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Podio( - ); + const response = await project.updateOAuth2Podio(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Salesforce()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'customerKey': '3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq', - 'customerSecret': '3w000000000000e2',}; + const data = { + '\\$id': 'github', + enabled: true, + customerKey: + '3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq', + customerSecret: '3w000000000000e2', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Salesforce( - ); + const response = await project.updateOAuth2Salesforce(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Slack()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': '23000000089.15000000000023', - 'clientSecret': '81656000000000000000000000f3d2fd',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: '23000000089.15000000000023', + clientSecret: '81656000000000000000000000f3d2fd', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Slack( - ); + const response = await project.updateOAuth2Slack(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Spotify()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': '6ec271000000000000000000009beace', - 'clientSecret': 'db068a000000000000000000008b5b9f',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: '6ec271000000000000000000009beace', + clientSecret: 'db068a000000000000000000008b5b9f', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Spotify( - ); + const response = await project.updateOAuth2Spotify(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Stripe()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'ca_UKibXX0000000000000000000006byvR', - 'apiSecretKey': 'sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: 'ca_UKibXX0000000000000000000006byvR', + apiSecretKey: + 'sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Stripe( - ); + const response = await project.updateOAuth2Stripe(); // 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', - 'enabled': true, - 'oauth2ClientId': 'appwrite-test-org.appwrite-test-app', - 'oauth2ClientSecret': '7cb52700-0000-0000-0000-000000ca5b83',}; + const data = { + '\\$id': 'github', + enabled: true, + oauth2ClientId: 'appwrite-test-org.appwrite-test-app', + oauth2ClientSecret: '7cb52700-0000-0000-0000-000000ca5b83', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Tradeshift( - ); + const response = await project.updateOAuth2Tradeshift(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2TradeshiftSandbox()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'oauth2ClientId': 'appwrite-test-org.appwrite-test-app', - 'oauth2ClientSecret': '7cb52700-0000-0000-0000-000000ca5b83',}; + const data = { + '\\$id': 'github', + enabled: true, + oauth2ClientId: 'appwrite-test-org.appwrite-test-app', + oauth2ClientSecret: '7cb52700-0000-0000-0000-000000ca5b83', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2TradeshiftSandbox( - ); + const response = await project.updateOAuth2TradeshiftSandbox(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Twitch()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'vvi0in000000000000000000ikmt9p', - 'clientSecret': 'pmapue000000000000000000zylw3v',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: 'vvi0in000000000000000000ikmt9p', + clientSecret: 'pmapue000000000000000000zylw3v', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Twitch( - ); + const response = await project.updateOAuth2Twitch(); // 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', - 'enabled': true, - 'clientId': '130005', - 'clientSecret': 'PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: '130005', + clientSecret: + 'PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2WordPress( - ); + const response = await project.updateOAuth2WordPress(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2X()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'customerKey': 'slzZV0000000000000NFLaWT', - 'secretKey': 'tkEPkp00000000000000000000000000000000000000FTxbI9',}; + const data = { + '\\$id': 'github', + enabled: true, + customerKey: 'slzZV0000000000000NFLaWT', + secretKey: 'tkEPkp00000000000000000000000000000000000000FTxbI9', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2X( - ); + const response = await project.updateOAuth2X(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Yahoo()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm', - 'clientSecret': 'cf978f0000000000000000000000000000c5e2e9',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: + 'dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm', + clientSecret: 'cf978f0000000000000000000000000000c5e2e9', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Yahoo( - ); + const response = await project.updateOAuth2Yahoo(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Yandex()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': '6a8a6a0000000000000000000091483c', - 'clientSecret': 'bbf98500000000000000000000c75a63',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: '6a8a6a0000000000000000000091483c', + clientSecret: 'bbf98500000000000000000000c75a63', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Yandex( - ); + const response = await project.updateOAuth2Yandex(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Zoho()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': '1000.83C178000000000000000000RPNX0B', - 'clientSecret': 'fb5cac000000000000000000000000000000a68f6e',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: '1000.83C178000000000000000000RPNX0B', + clientSecret: 'fb5cac000000000000000000000000000000a68f6e', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Zoho( - ); + const response = await project.updateOAuth2Zoho(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateOAuth2Zoom()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'clientId': 'QMAC00000000000000w0AQ', - 'clientSecret': 'GAWsG4000000000000000000007U01ON',}; + const data = { + '\\$id': 'github', + enabled: true, + clientId: 'QMAC00000000000000w0AQ', + clientSecret: 'GAWsG4000000000000000000007U01ON', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateOAuth2Zoom( - ); + const response = await project.updateOAuth2Zoom(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getOAuth2Provider()', async () => { - const data = { - '\$id': 'github', - 'enabled': true, - 'applicationId': '00001111-aaaa-2222-bbbb-3333cccc4444', - 'applicationSecret': 'A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u', - 'tenant': 'common',}; + const data = { + '\\$id': 'github', + enabled: true, + applicationId: '00001111-aaaa-2222-bbbb-3333cccc4444', + applicationSecret: 'A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u', + tenant: 'common', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.getOAuth2Provider( - 'amazon', - ); + const response = await project.getOAuth2Provider('amazon'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listPlatforms()', async () => { - const data = { - 'total': 5, - 'platforms': [],}; + const data = { + total: 5, + platforms: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.listPlatforms( - ); + const response = await project.listPlatforms(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createAndroidPlatform()', 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 Web App', - 'type': 'web', - 'applicationId': 'com.company.appname',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Web App', + type: 'web', + applicationId: 'com.company.appname', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.createAndroidPlatform( '', '', @@ -1196,17 +1090,16 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method updateAndroidPlatform()', 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 Web App', - 'type': 'web', - 'applicationId': 'com.company.appname',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Web App', + type: 'web', + applicationId: 'com.company.appname', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.updateAndroidPlatform( '', '', @@ -1218,17 +1111,16 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method createApplePlatform()', 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 Web App', - 'type': 'web', - 'bundleIdentifier': 'com.company.appname',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Web App', + type: 'web', + bundleIdentifier: 'com.company.appname', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.createApplePlatform( '', '', @@ -1240,17 +1132,16 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method updateApplePlatform()', 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 Web App', - 'type': 'web', - 'bundleIdentifier': 'com.company.appname',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Web App', + type: 'web', + bundleIdentifier: 'com.company.appname', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.updateApplePlatform( '', '', @@ -1262,17 +1153,16 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method createLinuxPlatform()', 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 Web App', - 'type': 'web', - 'packageName': 'com.company.appname',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Web App', + type: 'web', + packageName: 'com.company.appname', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.createLinuxPlatform( '', '', @@ -1284,17 +1174,16 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method updateLinuxPlatform()', 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 Web App', - 'type': 'web', - 'packageName': 'com.company.appname',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Web App', + type: 'web', + packageName: 'com.company.appname', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.updateLinuxPlatform( '', '', @@ -1306,17 +1195,16 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method createWebPlatform()', 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 Web App', - 'type': 'web', - 'hostname': 'app.example.com',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Web App', + type: 'web', + hostname: 'app.example.com', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.createWebPlatform( '', '', @@ -1328,17 +1216,16 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method updateWebPlatform()', 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 Web App', - 'type': 'web', - 'hostname': 'app.example.com',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Web App', + type: 'web', + hostname: 'app.example.com', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.updateWebPlatform( '', '', @@ -1350,17 +1237,16 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method createWindowsPlatform()', 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 Web App', - 'type': 'web', - 'packageIdentifierName': 'com.company.appname',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Web App', + type: 'web', + packageIdentifierName: 'com.company.appname', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.createWindowsPlatform( '', '', @@ -1372,17 +1258,16 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method updateWindowsPlatform()', 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 Web App', - 'type': 'web', - 'packageIdentifierName': 'com.company.appname',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Web App', + type: 'web', + packageIdentifierName: 'com.company.appname', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.updateWindowsPlatform( '', '', @@ -1394,904 +1279,808 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method getPlatform()', 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 Web App', - 'type': 'web', - 'packageName': 'com.company.appname',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Web App', + type: 'web', + packageName: 'com.company.appname', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.getPlatform( - '', - ); + const response = await project.getPlatform(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deletePlatform()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.deletePlatform( - '', - ); + const response = await project.deletePlatform(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listPolicies()', async () => { - const data = { - 'total': 10, - 'policies': [],}; + const data = { + total: 10, + policies: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.listPolicies( - ); + const response = await project.listPolicies(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateDenyAliasedEmailPolicy()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateDenyAliasedEmailPolicy( - true, - ); + 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', + devKeys: [], + 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.updateDenyAliasedEmailPolicy(true); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateDenyCorporateEmailPolicy()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateDenyCorporateEmailPolicy( - true, - ); + 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', + devKeys: [], + 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.updateDenyCorporateEmailPolicy(true); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateDenyDisposableEmailPolicy()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateDenyDisposableEmailPolicy( - true, - ); + 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', + devKeys: [], + 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.updateDenyDisposableEmailPolicy(true); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateDenyFreeEmailPolicy()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateDenyFreeEmailPolicy( - true, - ); + 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', + devKeys: [], + 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.updateDenyFreeEmailPolicy(true); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateMembershipPrivacyPolicy()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateMembershipPrivacyPolicy( - ); + 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', + devKeys: [], + 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.updateMembershipPrivacyPolicy(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateMFAFactorsPolicy()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateMFAFactorsPolicy( - ); + 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', + devKeys: [], + 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.updateMFAFactorsPolicy(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updatePasswordDictionaryPolicy()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updatePasswordDictionaryPolicy( - true, - ); + 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', + devKeys: [], + 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.updatePasswordDictionaryPolicy(true); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updatePasswordHistoryPolicy()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updatePasswordHistoryPolicy( - 1, - ); + 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', + devKeys: [], + 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.updatePasswordHistoryPolicy(1); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updatePasswordPersonalDataPolicy()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updatePasswordPersonalDataPolicy( - true, - ); + 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', + devKeys: [], + 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.updatePasswordPersonalDataPolicy(true); // 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', - 'min': 12, - 'uppercase': true, - 'lowercase': true, - 'number': true, - 'symbols': true,}; + const data = { + '\\$id': 'password-dictionary', + min: 12, + uppercase: true, + lowercase: true, + number: true, + symbols: true, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updatePasswordStrengthPolicy( - ); + const response = await project.updatePasswordStrengthPolicy(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateSessionAlertPolicy()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateSessionAlertPolicy( - true, - ); + 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', + devKeys: [], + 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.updateSessionAlertPolicy(true); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateSessionDurationPolicy()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateSessionDurationPolicy( - 1, - ); + 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', + devKeys: [], + 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.updateSessionDurationPolicy(1); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateSessionInvalidationPolicy()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateSessionInvalidationPolicy( - true, - ); + 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', + devKeys: [], + 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.updateSessionInvalidationPolicy(true); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateSessionLimitPolicy()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateSessionLimitPolicy( - 1, - ); + 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', + devKeys: [], + 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.updateSessionLimitPolicy(1); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateUserLimitPolicy()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateUserLimitPolicy( - 1, - ); + 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', + devKeys: [], + 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.updateUserLimitPolicy(1); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getPolicy()', async () => { - const data = { - '\$id': 'password-dictionary', - 'enabled': true,}; + const data = { + '\\$id': 'password-dictionary', + enabled: true, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.getPolicy( - 'password-dictionary', - ); + const response = await project.getPolicy('password-dictionary'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateProtocol()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateProtocol( - 'rest', - true, - ); + 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', + devKeys: [], + 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.updateProtocol('rest', true); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateService()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateService( - 'account', - true, - ); + 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', + devKeys: [], + 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.updateService('account', true); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateSMTP()', 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', - 'devKeys': [], - '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', - 'wafEnabled': true,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateSMTP( - ); + 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', + devKeys: [], + 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.updateSMTP(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createSMTPTest()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.createSMTPTest( - [], - ); + const response = await project.createSMTPTest([]); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listEmailTemplates()', async () => { - const data = { - 'total': 5, - 'templates': [],}; + const data = { + total: 5, + templates: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.listEmailTemplates( - ); + const response = await project.listEmailTemplates(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateEmailTemplate()', async () => { - const data = { - 'templateId': 'verification', - 'locale': 'en_us', - 'message': 'Click on the link to verify your account.', - 'senderName': 'My User', - 'senderEmail': 'mail@appwrite.io', - 'replyToEmail': 'emails@appwrite.io', - 'replyToName': 'Support Team', - 'subject': 'Please verify your email address',}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateEmailTemplate( - 'verification', - ); + const data = { + templateId: 'verification', + locale: 'en_us', + message: 'Click on the link to verify your account.', + senderName: 'My User', + senderEmail: 'mail@appwrite.io', + replyToEmail: 'emails@appwrite.io', + replyToName: 'Support Team', + subject: 'Please verify your email address', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateEmailTemplate('verification'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getEmailTemplate()', async () => { - const data = { - 'templateId': 'verification', - 'locale': 'en_us', - 'message': 'Click on the link to verify your account.', - 'senderName': 'My User', - 'senderEmail': 'mail@appwrite.io', - 'replyToEmail': 'emails@appwrite.io', - 'replyToName': 'Support Team', - 'subject': 'Please verify your email address',}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.getEmailTemplate( - 'verification', - ); + const data = { + templateId: 'verification', + locale: 'en_us', + message: 'Click on the link to verify your account.', + senderName: 'My User', + senderEmail: 'mail@appwrite.io', + replyToEmail: 'emails@appwrite.io', + replyToName: 'Support Team', + subject: 'Please verify your email address', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.getEmailTemplate('verification'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listVariables()', async () => { - const data = { - 'total': 5, - 'variables': [],}; + const data = { + total: 5, + variables: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.listVariables( - ); + const response = await project.listVariables(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createVariable()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'API_KEY', - 'value': 'myPa\$\$word1', - 'secret': true, - 'resourceType': 'function', - 'resourceId': 'myAwesomeFunction',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'API_KEY', + value: 'myPa\\$\\$word1', + secret: true, + resourceType: 'function', + resourceId: 'myAwesomeFunction', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.createVariable( '', '', @@ -2303,62 +2092,52 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method getVariable()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'API_KEY', - 'value': 'myPa\$\$word1', - 'secret': true, - 'resourceType': 'function', - 'resourceId': 'myAwesomeFunction',}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.getVariable( - '', - ); + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'API_KEY', + value: 'myPa\\$\\$word1', + secret: true, + resourceType: 'function', + resourceId: 'myAwesomeFunction', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.getVariable(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateVariable()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'API_KEY', - 'value': 'myPa\$\$word1', - 'secret': true, - 'resourceType': 'function', - 'resourceId': 'myAwesomeFunction',}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.updateVariable( - '', - ); + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'API_KEY', + value: 'myPa\\$\\$word1', + secret: true, + resourceType: 'function', + resourceId: 'myAwesomeFunction', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateVariable(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteVariable()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await project.deleteVariable( - '', - ); + const response = await project.deleteVariable(''); // 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/proxy.test.js b/test/services/proxy.test.js index ebe46255..bf9d288e 100644 --- a/test/services/proxy.test.js +++ b/test/services/proxy.test.js @@ -1,97 +1,89 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Proxy } = require("../../dist/services/proxy"); +const { Client } = require('../../dist/client'); +const { Proxy } = require('../../dist/services/proxy'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Proxy', () => { const client = new Client(); const proxy = new Proxy(client); - test('test method createInvalidation()', async () => { - const data = { - 'domain': 'appwrite.company.com', - 'type': 'tag', - 'reference': 'products', - 'status': 'success',}; + const data = { + domain: 'appwrite.company.com', + type: 'tag', + reference: 'products', + status: 'success', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await proxy.createInvalidation( - '', - 'tag', - ); + const response = await proxy.createInvalidation('example.com', 'tag'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listRules()', async () => { - const data = { - 'total': 5, - 'rules': [],}; + const data = { + total: 5, + rules: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await proxy.listRules( - ); + const response = await proxy.listRules(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createAPIRule()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'domain': 'appwrite.company.com', - 'type': 'deployment', - 'trigger': 'manual', - 'redirectUrl': 'https://appwrite.io/docs', - 'redirectStatusCode': 301, - 'deploymentId': 'n3u9feiwmf', - 'deploymentResourceId': 'n3u9feiwmf', - 'deploymentVcsProviderBranch': 'main', - 'status': 'verified', - 'logs': 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', - 'renewAt': 'datetime',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + domain: 'appwrite.company.com', + type: 'deployment', + trigger: 'manual', + redirectUrl: 'https://appwrite.io/docs', + redirectStatusCode: 301, + deploymentId: 'n3u9feiwmf', + deploymentResourceId: 'n3u9feiwmf', + deploymentVcsProviderBranch: 'main', + status: 'verified', + logs: 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', + renewAt: 'datetime', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await proxy.createAPIRule( - '', - ); + const response = await proxy.createAPIRule('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 createFunctionRule()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'domain': 'appwrite.company.com', - 'type': 'deployment', - 'trigger': 'manual', - 'redirectUrl': 'https://appwrite.io/docs', - 'redirectStatusCode': 301, - 'deploymentId': 'n3u9feiwmf', - 'deploymentResourceId': 'n3u9feiwmf', - 'deploymentVcsProviderBranch': 'main', - 'status': 'verified', - 'logs': 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', - 'renewAt': 'datetime',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + domain: 'appwrite.company.com', + type: 'deployment', + trigger: 'manual', + redirectUrl: 'https://appwrite.io/docs', + redirectStatusCode: 301, + deploymentId: 'n3u9feiwmf', + deploymentResourceId: 'n3u9feiwmf', + deploymentVcsProviderBranch: 'main', + status: 'verified', + logs: 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', + renewAt: 'datetime', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await proxy.createFunctionRule( - '', + 'example.com', '', ); @@ -100,27 +92,26 @@ describe('Proxy', () => { expect(response).toEqual(data); }); - test('test method createRedirectRule()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'domain': 'appwrite.company.com', - 'type': 'deployment', - 'trigger': 'manual', - 'redirectUrl': 'https://appwrite.io/docs', - 'redirectStatusCode': 301, - 'deploymentId': 'n3u9feiwmf', - 'deploymentResourceId': 'n3u9feiwmf', - 'deploymentVcsProviderBranch': 'main', - 'status': 'verified', - 'logs': 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', - 'renewAt': 'datetime',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + domain: 'appwrite.company.com', + type: 'deployment', + trigger: 'manual', + redirectUrl: 'https://appwrite.io/docs', + redirectStatusCode: 301, + deploymentId: 'n3u9feiwmf', + deploymentResourceId: 'n3u9feiwmf', + deploymentVcsProviderBranch: 'main', + status: 'verified', + logs: 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', + renewAt: 'datetime', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await proxy.createRedirectRule( - '', + 'example.com', 'https://example.com', '301', '', @@ -132,103 +123,89 @@ describe('Proxy', () => { expect(response).toEqual(data); }); - test('test method createSiteRule()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'domain': 'appwrite.company.com', - 'type': 'deployment', - 'trigger': 'manual', - 'redirectUrl': 'https://appwrite.io/docs', - 'redirectStatusCode': 301, - 'deploymentId': 'n3u9feiwmf', - 'deploymentResourceId': 'n3u9feiwmf', - 'deploymentVcsProviderBranch': 'main', - 'status': 'verified', - 'logs': 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', - 'renewAt': 'datetime',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + domain: 'appwrite.company.com', + type: 'deployment', + trigger: 'manual', + redirectUrl: 'https://appwrite.io/docs', + redirectStatusCode: 301, + deploymentId: 'n3u9feiwmf', + deploymentResourceId: 'n3u9feiwmf', + deploymentVcsProviderBranch: 'main', + status: 'verified', + logs: 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', + renewAt: 'datetime', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await proxy.createSiteRule( - '', - '', - ); + const response = await proxy.createSiteRule('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 getRule()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'domain': 'appwrite.company.com', - 'type': 'deployment', - 'trigger': 'manual', - 'redirectUrl': 'https://appwrite.io/docs', - 'redirectStatusCode': 301, - 'deploymentId': 'n3u9feiwmf', - 'deploymentResourceId': 'n3u9feiwmf', - 'deploymentVcsProviderBranch': 'main', - 'status': 'verified', - 'logs': 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', - 'renewAt': 'datetime',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + domain: 'appwrite.company.com', + type: 'deployment', + trigger: 'manual', + redirectUrl: 'https://appwrite.io/docs', + redirectStatusCode: 301, + deploymentId: 'n3u9feiwmf', + deploymentResourceId: 'n3u9feiwmf', + deploymentVcsProviderBranch: 'main', + status: 'verified', + logs: 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', + renewAt: 'datetime', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await proxy.getRule( - '', - ); + const response = await proxy.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: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await proxy.deleteRule( - '', - ); + const response = await proxy.deleteRule(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateRuleStatus()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'domain': 'appwrite.company.com', - 'type': 'deployment', - 'trigger': 'manual', - 'redirectUrl': 'https://appwrite.io/docs', - 'redirectStatusCode': 301, - 'deploymentId': 'n3u9feiwmf', - 'deploymentResourceId': 'n3u9feiwmf', - 'deploymentVcsProviderBranch': 'main', - 'status': 'verified', - 'logs': 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', - 'renewAt': 'datetime',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + domain: 'appwrite.company.com', + type: 'deployment', + trigger: 'manual', + redirectUrl: 'https://appwrite.io/docs', + redirectStatusCode: 301, + deploymentId: 'n3u9feiwmf', + deploymentResourceId: 'n3u9feiwmf', + deploymentVcsProviderBranch: 'main', + status: 'verified', + logs: 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', + renewAt: 'datetime', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await proxy.updateRuleStatus( - '', - ); + const response = await proxy.updateRuleStatus(''); // 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/sites.test.js b/test/services/sites.test.js index 402a5d5d..7b267ce8 100644 --- a/test/services/sites.test.js +++ b/test/services/sites.test.js @@ -1,68 +1,69 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Sites } = require("../../dist/services/sites"); +const { Client } = require('../../dist/client'); +const { InputFile } = require('../../dist/inputFile'); +const { Sites } = require('../../dist/services/sites'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Sites', () => { const client = new Client(); const sites = new Sites(client); - test('test method list()', async () => { - const data = { - 'total': 5, - 'sites': [],}; + const data = { + total: 5, + sites: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await sites.list( - ); + const response = await sites.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', - 'name': 'My Site', - 'enabled': true, - 'live': true, - 'logging': true, - 'framework': 'react', - 'deploymentRetention': 7, - 'deploymentId': '5e5ea5c16897e', - 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'deploymentScreenshotLight': '5e5ea5c16897e', - 'deploymentScreenshotDark': '5e5ea5c16897e', - 'latestDeploymentId': '5e5ea5c16897e', - 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'latestDeploymentStatus': 'ready', - 'vars': [], - 'timeout': 300, - 'installCommand': 'npm install', - 'buildCommand': 'npm run build', - 'startCommand': 'node custom-server.mjs', - 'outputDirectory': 'build', - 'installationId': '6m40at4ejk5h2u9s1hboo', - 'providerRepositoryId': 'appwrite', - 'providerBranch': 'main', - 'providerRootDirectory': 'sites/helloWorld', - 'providerSilentMode': true, - 'providerBranches': [], - 'providerPaths': [], - 'buildSpecification': 's-1vcpu-512mb', - 'runtimeSpecification': 's-1vcpu-512mb', - 'buildRuntime': 'node-22', - 'adapter': 'static', - 'fallbackFile': 'index.html',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Site', + enabled: true, + live: true, + logging: true, + framework: 'react', + deploymentRetention: 7, + deploymentId: '5e5ea5c16897e', + deploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + deploymentScreenshotLight: '5e5ea5c16897e', + deploymentScreenshotDark: '5e5ea5c16897e', + latestDeploymentId: '5e5ea5c16897e', + latestDeploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + latestDeploymentStatus: 'ready', + scopes: [], + vars: [], + timeout: 300, + installCommand: 'npm install', + buildCommand: 'npm run build', + startCommand: 'node custom-server.mjs', + outputDirectory: 'build', + installationId: '6m40at4ejk5h2u9s1hboo', + providerRepositoryId: 'appwrite', + providerBranch: 'main', + providerRootDirectory: 'sites/helloWorld', + providerSilentMode: true, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: 'node-22', + adapter: 'static', + fallbackFile: 'index.html', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await sites.create( '', '', @@ -75,187 +76,173 @@ describe('Sites', () => { expect(response).toEqual(data); }); - test('test method listFrameworks()', async () => { - const data = { - 'total': 5, - 'frameworks': [],}; + const data = { + total: 5, + frameworks: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await sites.listFrameworks( - ); + const response = await sites.listFrameworks(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listSpecifications()', async () => { - const data = { - 'total': 5, - 'specifications': [],}; + const data = { + total: 5, + specifications: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await sites.listSpecifications( - ); + const response = await sites.listSpecifications(); // 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', - 'name': 'My Site', - 'enabled': true, - 'live': true, - 'logging': true, - 'framework': 'react', - 'deploymentRetention': 7, - 'deploymentId': '5e5ea5c16897e', - 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'deploymentScreenshotLight': '5e5ea5c16897e', - 'deploymentScreenshotDark': '5e5ea5c16897e', - 'latestDeploymentId': '5e5ea5c16897e', - 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'latestDeploymentStatus': 'ready', - 'vars': [], - 'timeout': 300, - 'installCommand': 'npm install', - 'buildCommand': 'npm run build', - 'startCommand': 'node custom-server.mjs', - 'outputDirectory': 'build', - 'installationId': '6m40at4ejk5h2u9s1hboo', - 'providerRepositoryId': 'appwrite', - 'providerBranch': 'main', - 'providerRootDirectory': 'sites/helloWorld', - 'providerSilentMode': true, - 'providerBranches': [], - 'providerPaths': [], - 'buildSpecification': 's-1vcpu-512mb', - 'runtimeSpecification': 's-1vcpu-512mb', - 'buildRuntime': 'node-22', - 'adapter': 'static', - 'fallbackFile': 'index.html',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Site', + enabled: true, + live: true, + logging: true, + framework: 'react', + deploymentRetention: 7, + deploymentId: '5e5ea5c16897e', + deploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + deploymentScreenshotLight: '5e5ea5c16897e', + deploymentScreenshotDark: '5e5ea5c16897e', + latestDeploymentId: '5e5ea5c16897e', + latestDeploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + latestDeploymentStatus: 'ready', + scopes: [], + vars: [], + timeout: 300, + installCommand: 'npm install', + buildCommand: 'npm run build', + startCommand: 'node custom-server.mjs', + outputDirectory: 'build', + installationId: '6m40at4ejk5h2u9s1hboo', + providerRepositoryId: 'appwrite', + providerBranch: 'main', + providerRootDirectory: 'sites/helloWorld', + providerSilentMode: true, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: 'node-22', + adapter: 'static', + fallbackFile: 'index.html', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await sites.get( - '', - ); + const response = await sites.get(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method update()', 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 Site', - 'enabled': true, - 'live': true, - 'logging': true, - 'framework': 'react', - 'deploymentRetention': 7, - 'deploymentId': '5e5ea5c16897e', - 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'deploymentScreenshotLight': '5e5ea5c16897e', - 'deploymentScreenshotDark': '5e5ea5c16897e', - 'latestDeploymentId': '5e5ea5c16897e', - 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'latestDeploymentStatus': 'ready', - 'vars': [], - 'timeout': 300, - 'installCommand': 'npm install', - 'buildCommand': 'npm run build', - 'startCommand': 'node custom-server.mjs', - 'outputDirectory': 'build', - 'installationId': '6m40at4ejk5h2u9s1hboo', - 'providerRepositoryId': 'appwrite', - 'providerBranch': 'main', - 'providerRootDirectory': 'sites/helloWorld', - 'providerSilentMode': true, - 'providerBranches': [], - 'providerPaths': [], - 'buildSpecification': 's-1vcpu-512mb', - 'runtimeSpecification': 's-1vcpu-512mb', - 'buildRuntime': 'node-22', - 'adapter': 'static', - 'fallbackFile': 'index.html',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Site', + enabled: true, + live: true, + logging: true, + framework: 'react', + deploymentRetention: 7, + deploymentId: '5e5ea5c16897e', + deploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + deploymentScreenshotLight: '5e5ea5c16897e', + deploymentScreenshotDark: '5e5ea5c16897e', + latestDeploymentId: '5e5ea5c16897e', + latestDeploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + latestDeploymentStatus: 'ready', + scopes: [], + vars: [], + timeout: 300, + installCommand: 'npm install', + buildCommand: 'npm run build', + startCommand: 'node custom-server.mjs', + outputDirectory: 'build', + installationId: '6m40at4ejk5h2u9s1hboo', + providerRepositoryId: 'appwrite', + providerBranch: 'main', + providerRootDirectory: 'sites/helloWorld', + providerSilentMode: true, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: 'node-22', + adapter: 'static', + fallbackFile: 'index.html', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await sites.update( - '', - '', - 'analog', - ); + const response = await sites.update('', '', 'analog'); // 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: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await sites.delete( - '', - ); + const response = await sites.delete(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateSiteDeployment()', 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 Site', - 'enabled': true, - 'live': true, - 'logging': true, - 'framework': 'react', - 'deploymentRetention': 7, - 'deploymentId': '5e5ea5c16897e', - 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'deploymentScreenshotLight': '5e5ea5c16897e', - 'deploymentScreenshotDark': '5e5ea5c16897e', - 'latestDeploymentId': '5e5ea5c16897e', - 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', - 'latestDeploymentStatus': 'ready', - 'vars': [], - 'timeout': 300, - 'installCommand': 'npm install', - 'buildCommand': 'npm run build', - 'startCommand': 'node custom-server.mjs', - 'outputDirectory': 'build', - 'installationId': '6m40at4ejk5h2u9s1hboo', - 'providerRepositoryId': 'appwrite', - 'providerBranch': 'main', - 'providerRootDirectory': 'sites/helloWorld', - 'providerSilentMode': true, - 'providerBranches': [], - 'providerPaths': [], - 'buildSpecification': 's-1vcpu-512mb', - 'runtimeSpecification': 's-1vcpu-512mb', - 'buildRuntime': 'node-22', - 'adapter': 'static', - 'fallbackFile': 'index.html',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Site', + enabled: true, + live: true, + logging: true, + framework: 'react', + deploymentRetention: 7, + deploymentId: '5e5ea5c16897e', + deploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + deploymentScreenshotLight: '5e5ea5c16897e', + deploymentScreenshotDark: '5e5ea5c16897e', + latestDeploymentId: '5e5ea5c16897e', + latestDeploymentCreatedAt: '2020-10-15T06:38:00.000+00:00', + latestDeploymentStatus: 'ready', + scopes: [], + vars: [], + timeout: 300, + installCommand: 'npm install', + buildCommand: 'npm run build', + startCommand: 'node custom-server.mjs', + outputDirectory: 'build', + installationId: '6m40at4ejk5h2u9s1hboo', + providerRepositoryId: 'appwrite', + providerBranch: 'main', + providerRootDirectory: 'sites/helloWorld', + providerSilentMode: true, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: 'node-22', + adapter: 'static', + fallbackFile: 'index.html', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await sites.updateSiteDeployment( '', '', @@ -266,54 +253,53 @@ describe('Sites', () => { expect(response).toEqual(data); }); - test('test method listDeployments()', async () => { - const data = { - 'total': 5, - 'deployments': [],}; + const data = { + total: 5, + deployments: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await sites.listDeployments( - '', - ); + const response = await sites.listDeployments(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createDeployment()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'type': 'vcs', - 'resourceId': '5e5ea6g16897e', - 'resourceType': 'functions', - 'entrypoint': 'index.js', - 'sourceSize': 128, - 'buildSize': 128, - 'totalSize': 128, - 'buildId': '5e5ea5c16897e', - 'activate': true, - 'screenshotLight': '5e5ea5c16897e', - 'screenshotDark': '5e5ea5c16897e', - 'status': 'ready', - 'buildLogs': 'Compiling source files...', - 'buildDuration': 128, - 'providerRepositoryName': 'database', - 'providerRepositoryOwner': 'utopia', - 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', - 'providerCommitHash': '7c3f25d', - 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', - 'providerCommitAuthor': 'Khushboo Verma', - 'providerCommitMessage': 'Update index.js', - 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', - 'providerBranch': '0.7.x', - 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + type: 'vcs', + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + entrypoint: 'index.js', + sourceSize: 128, + buildSize: 128, + totalSize: 128, + buildId: '5e5ea5c16897e', + activate: true, + screenshotLight: '5e5ea5c16897e', + screenshotDark: '5e5ea5c16897e', + status: 'ready', + buildLogs: 'Compiling source files...', + buildDuration: 128, + providerRepositoryName: 'database', + providerRepositoryOwner: 'utopia', + providerRepositoryUrl: + 'https://github.com/vermakhushboo/g4-node-function', + providerCommitHash: '7c3f25d', + providerCommitAuthorUrl: 'https://github.com/vermakhushboo', + providerCommitAuthor: 'Khushboo Verma', + providerCommitMessage: 'Update index.js', + providerCommitUrl: + 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + providerBranch: '0.7.x', + providerBranchUrl: + 'https://github.com/vermakhushboo/appwrite/tree/0.7.x', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await sites.createDeployment( '', InputFile.fromBuffer(new Uint8Array(0), 'image.png'), @@ -324,38 +310,40 @@ describe('Sites', () => { expect(response).toEqual(data); }); - test('test method createDuplicateDeployment()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'type': 'vcs', - 'resourceId': '5e5ea6g16897e', - 'resourceType': 'functions', - 'entrypoint': 'index.js', - 'sourceSize': 128, - 'buildSize': 128, - 'totalSize': 128, - 'buildId': '5e5ea5c16897e', - 'activate': true, - 'screenshotLight': '5e5ea5c16897e', - 'screenshotDark': '5e5ea5c16897e', - 'status': 'ready', - 'buildLogs': 'Compiling source files...', - 'buildDuration': 128, - 'providerRepositoryName': 'database', - 'providerRepositoryOwner': 'utopia', - 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', - 'providerCommitHash': '7c3f25d', - 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', - 'providerCommitAuthor': 'Khushboo Verma', - 'providerCommitMessage': 'Update index.js', - 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', - 'providerBranch': '0.7.x', - 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + type: 'vcs', + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + entrypoint: 'index.js', + sourceSize: 128, + buildSize: 128, + totalSize: 128, + buildId: '5e5ea5c16897e', + activate: true, + screenshotLight: '5e5ea5c16897e', + screenshotDark: '5e5ea5c16897e', + status: 'ready', + buildLogs: 'Compiling source files...', + buildDuration: 128, + providerRepositoryName: 'database', + providerRepositoryOwner: 'utopia', + providerRepositoryUrl: + 'https://github.com/vermakhushboo/g4-node-function', + providerCommitHash: '7c3f25d', + providerCommitAuthorUrl: 'https://github.com/vermakhushboo', + providerCommitAuthor: 'Khushboo Verma', + providerCommitMessage: 'Update index.js', + providerCommitUrl: + 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + providerBranch: '0.7.x', + providerBranchUrl: + 'https://github.com/vermakhushboo/appwrite/tree/0.7.x', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await sites.createDuplicateDeployment( '', '', @@ -366,38 +354,40 @@ describe('Sites', () => { expect(response).toEqual(data); }); - test('test method createTemplateDeployment()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'type': 'vcs', - 'resourceId': '5e5ea6g16897e', - 'resourceType': 'functions', - 'entrypoint': 'index.js', - 'sourceSize': 128, - 'buildSize': 128, - 'totalSize': 128, - 'buildId': '5e5ea5c16897e', - 'activate': true, - 'screenshotLight': '5e5ea5c16897e', - 'screenshotDark': '5e5ea5c16897e', - 'status': 'ready', - 'buildLogs': 'Compiling source files...', - 'buildDuration': 128, - 'providerRepositoryName': 'database', - 'providerRepositoryOwner': 'utopia', - 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', - 'providerCommitHash': '7c3f25d', - 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', - 'providerCommitAuthor': 'Khushboo Verma', - 'providerCommitMessage': 'Update index.js', - 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', - 'providerBranch': '0.7.x', - 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + type: 'vcs', + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + entrypoint: 'index.js', + sourceSize: 128, + buildSize: 128, + totalSize: 128, + buildId: '5e5ea5c16897e', + activate: true, + screenshotLight: '5e5ea5c16897e', + screenshotDark: '5e5ea5c16897e', + status: 'ready', + buildLogs: 'Compiling source files...', + buildDuration: 128, + providerRepositoryName: 'database', + providerRepositoryOwner: 'utopia', + providerRepositoryUrl: + 'https://github.com/vermakhushboo/g4-node-function', + providerCommitHash: '7c3f25d', + providerCommitAuthorUrl: 'https://github.com/vermakhushboo', + providerCommitAuthor: 'Khushboo Verma', + providerCommitMessage: 'Update index.js', + providerCommitUrl: + 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + providerBranch: '0.7.x', + providerBranchUrl: + 'https://github.com/vermakhushboo/appwrite/tree/0.7.x', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await sites.createTemplateDeployment( '', '', @@ -412,38 +402,40 @@ describe('Sites', () => { expect(response).toEqual(data); }); - test('test method createVcsDeployment()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'type': 'vcs', - 'resourceId': '5e5ea6g16897e', - 'resourceType': 'functions', - 'entrypoint': 'index.js', - 'sourceSize': 128, - 'buildSize': 128, - 'totalSize': 128, - 'buildId': '5e5ea5c16897e', - 'activate': true, - 'screenshotLight': '5e5ea5c16897e', - 'screenshotDark': '5e5ea5c16897e', - 'status': 'ready', - 'buildLogs': 'Compiling source files...', - 'buildDuration': 128, - 'providerRepositoryName': 'database', - 'providerRepositoryOwner': 'utopia', - 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', - 'providerCommitHash': '7c3f25d', - 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', - 'providerCommitAuthor': 'Khushboo Verma', - 'providerCommitMessage': 'Update index.js', - 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', - 'providerBranch': '0.7.x', - 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + type: 'vcs', + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + entrypoint: 'index.js', + sourceSize: 128, + buildSize: 128, + totalSize: 128, + buildId: '5e5ea5c16897e', + activate: true, + screenshotLight: '5e5ea5c16897e', + screenshotDark: '5e5ea5c16897e', + status: 'ready', + buildLogs: 'Compiling source files...', + buildDuration: 128, + providerRepositoryName: 'database', + providerRepositoryOwner: 'utopia', + providerRepositoryUrl: + 'https://github.com/vermakhushboo/g4-node-function', + providerCommitHash: '7c3f25d', + providerCommitAuthorUrl: 'https://github.com/vermakhushboo', + providerCommitAuthor: 'Khushboo Verma', + providerCommitMessage: 'Update index.js', + providerCommitUrl: + 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + providerBranch: '0.7.x', + providerBranchUrl: + 'https://github.com/vermakhushboo/appwrite/tree/0.7.x', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await sites.createVcsDeployment( '', 'branch', @@ -455,38 +447,40 @@ describe('Sites', () => { expect(response).toEqual(data); }); - test('test method getDeployment()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'type': 'vcs', - 'resourceId': '5e5ea6g16897e', - 'resourceType': 'functions', - 'entrypoint': 'index.js', - 'sourceSize': 128, - 'buildSize': 128, - 'totalSize': 128, - 'buildId': '5e5ea5c16897e', - 'activate': true, - 'screenshotLight': '5e5ea5c16897e', - 'screenshotDark': '5e5ea5c16897e', - 'status': 'ready', - 'buildLogs': 'Compiling source files...', - 'buildDuration': 128, - 'providerRepositoryName': 'database', - 'providerRepositoryOwner': 'utopia', - 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', - 'providerCommitHash': '7c3f25d', - 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', - 'providerCommitAuthor': 'Khushboo Verma', - 'providerCommitMessage': 'Update index.js', - 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', - 'providerBranch': '0.7.x', - 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + type: 'vcs', + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + entrypoint: 'index.js', + sourceSize: 128, + buildSize: 128, + totalSize: 128, + buildId: '5e5ea5c16897e', + activate: true, + screenshotLight: '5e5ea5c16897e', + screenshotDark: '5e5ea5c16897e', + status: 'ready', + buildLogs: 'Compiling source files...', + buildDuration: 128, + providerRepositoryName: 'database', + providerRepositoryOwner: 'utopia', + providerRepositoryUrl: + 'https://github.com/vermakhushboo/g4-node-function', + providerCommitHash: '7c3f25d', + providerCommitAuthorUrl: 'https://github.com/vermakhushboo', + providerCommitAuthor: 'Khushboo Verma', + providerCommitMessage: 'Update index.js', + providerCommitUrl: + 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + providerBranch: '0.7.x', + providerBranchUrl: + 'https://github.com/vermakhushboo/appwrite/tree/0.7.x', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await sites.getDeployment( '', '', @@ -497,11 +491,9 @@ describe('Sites', () => { expect(response).toEqual(data); }); - test('test method deleteDeployment()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await sites.deleteDeployment( '', '', @@ -512,11 +504,9 @@ describe('Sites', () => { expect(response).toEqual(data); }); - test('test method getDeploymentDownload()', async () => { const data = new ArrayBuffer(0); mockedFetch.mockImplementation(() => new Response(data)); - const response = await sites.getDeploymentDownload( '', '', @@ -527,38 +517,40 @@ describe('Sites', () => { expect(response).toEqual(data); }); - test('test method updateDeploymentStatus()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'type': 'vcs', - 'resourceId': '5e5ea6g16897e', - 'resourceType': 'functions', - 'entrypoint': 'index.js', - 'sourceSize': 128, - 'buildSize': 128, - 'totalSize': 128, - 'buildId': '5e5ea5c16897e', - 'activate': true, - 'screenshotLight': '5e5ea5c16897e', - 'screenshotDark': '5e5ea5c16897e', - 'status': 'ready', - 'buildLogs': 'Compiling source files...', - 'buildDuration': 128, - 'providerRepositoryName': 'database', - 'providerRepositoryOwner': 'utopia', - 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', - 'providerCommitHash': '7c3f25d', - 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', - 'providerCommitAuthor': 'Khushboo Verma', - 'providerCommitMessage': 'Update index.js', - 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', - 'providerBranch': '0.7.x', - 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + type: 'vcs', + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + entrypoint: 'index.js', + sourceSize: 128, + buildSize: 128, + totalSize: 128, + buildId: '5e5ea5c16897e', + activate: true, + screenshotLight: '5e5ea5c16897e', + screenshotDark: '5e5ea5c16897e', + status: 'ready', + buildLogs: 'Compiling source files...', + buildDuration: 128, + providerRepositoryName: 'database', + providerRepositoryOwner: 'utopia', + providerRepositoryUrl: + 'https://github.com/vermakhushboo/g4-node-function', + providerCommitHash: '7c3f25d', + providerCommitAuthorUrl: 'https://github.com/vermakhushboo', + providerCommitAuthor: 'Khushboo Verma', + providerCommitMessage: 'Update index.js', + providerCommitUrl: + 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + providerBranch: '0.7.x', + providerBranchUrl: + 'https://github.com/vermakhushboo/appwrite/tree/0.7.x', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await sites.updateDeploymentStatus( '', '', @@ -569,98 +561,83 @@ describe('Sites', () => { expect(response).toEqual(data); }); - test('test method listLogs()', async () => { - const data = { - 'total': 5, - 'executions': [],}; + const data = { + total: 5, + executions: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await sites.listLogs( - '', - ); + const response = await sites.listLogs(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getLog()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + deploymentId: '5e5ea5c16897e', + trigger: 'http', + status: 'processing', + requestMethod: 'GET', + requestPath: '/articles?id=5', + requestHeaders: [], + responseStatusCode: 200, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0.4, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await sites.getLog( - '', - '', - ); + const response = await sites.getLog('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteLog()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await sites.deleteLog( - '', - '', - ); + const response = await sites.deleteLog('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listVariables()', async () => { - const data = { - 'total': 5, - 'variables': [],}; + const data = { + total: 5, + variables: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await sites.listVariables( - '', - ); + const response = await sites.listVariables(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createVariable()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'API_KEY', - 'value': 'myPa\$\$word1', - 'secret': true, - 'resourceType': 'function', - 'resourceId': 'myAwesomeFunction',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'API_KEY', + value: 'myPa\\$\\$word1', + secret: true, + resourceType: 'function', + resourceId: 'myAwesomeFunction', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await sites.createVariable( '', '', @@ -673,42 +650,37 @@ describe('Sites', () => { expect(response).toEqual(data); }); - test('test method getVariable()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'API_KEY', - 'value': 'myPa\$\$word1', - 'secret': true, - 'resourceType': 'function', - 'resourceId': 'myAwesomeFunction',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'API_KEY', + value: 'myPa\\$\\$word1', + secret: true, + resourceType: 'function', + resourceId: 'myAwesomeFunction', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await sites.getVariable( - '', - '', - ); + const response = await sites.getVariable('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateVariable()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'API_KEY', - 'value': 'myPa\$\$word1', - 'secret': true, - 'resourceType': 'function', - 'resourceId': 'myAwesomeFunction',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'API_KEY', + value: 'myPa\\$\\$word1', + secret: true, + resourceType: 'function', + resourceId: 'myAwesomeFunction', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await sites.updateVariable( '', '', @@ -719,11 +691,9 @@ describe('Sites', () => { expect(response).toEqual(data); }); - test('test method deleteVariable()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await sites.deleteVariable( '', '', @@ -734,4 +704,4 @@ describe('Sites', () => { expect(response).toEqual(data); }); - }) +}); diff --git a/test/services/storage.test.js b/test/services/storage.test.js index 761c156f..7f353198 100644 --- a/test/services/storage.test.js +++ b/test/services/storage.test.js @@ -1,166 +1,148 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Storage } = require("../../dist/services/storage"); +const { Client } = require('../../dist/client'); +const { InputFile } = require('../../dist/inputFile'); +const { Storage } = require('../../dist/services/storage'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Storage', () => { const client = new Client(); const storage = new Storage(client); - test('test method listBuckets()', async () => { - const data = { - 'total': 5, - 'buckets': [],}; + const data = { + total: 5, + buckets: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await storage.listBuckets( - ); + const response = await storage.listBuckets(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createBucket()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'fileSecurity': true, - 'name': 'Documents', - 'enabled': true, - 'maximumFileSize': 100, - 'allowedFileExtensions': [], - 'compression': 'gzip', - 'encryption': true, - 'antivirus': true, - 'transformations': true, - 'totalSize': 128,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + fileSecurity: true, + name: 'Documents', + enabled: true, + maximumFileSize: 100, + allowedFileExtensions: [], + compression: 'gzip', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 128, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await storage.createBucket( - '', - '', - ); + const response = await storage.createBucket('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getBucket()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'fileSecurity': true, - 'name': 'Documents', - 'enabled': true, - 'maximumFileSize': 100, - 'allowedFileExtensions': [], - 'compression': 'gzip', - 'encryption': true, - 'antivirus': true, - 'transformations': true, - 'totalSize': 128,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + fileSecurity: true, + name: 'Documents', + enabled: true, + maximumFileSize: 100, + allowedFileExtensions: [], + compression: 'gzip', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 128, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await storage.getBucket( - '', - ); + const response = await storage.getBucket(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateBucket()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'fileSecurity': true, - 'name': 'Documents', - 'enabled': true, - 'maximumFileSize': 100, - 'allowedFileExtensions': [], - 'compression': 'gzip', - 'encryption': true, - 'antivirus': true, - 'transformations': true, - 'totalSize': 128,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + fileSecurity: true, + name: 'Documents', + enabled: true, + maximumFileSize: 100, + allowedFileExtensions: [], + compression: 'gzip', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 128, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await storage.updateBucket( - '', - '', - ); + const response = await storage.updateBucket('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteBucket()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await storage.deleteBucket( - '', - ); + const response = await storage.deleteBucket(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listFiles()', async () => { - const data = { - 'total': 5, - 'files': [],}; + const data = { + total: 5, + files: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await storage.listFiles( - '', - ); + const response = await storage.listFiles(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createFile()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'folder': 'photos/2026/', - 'key': 'photos/2026/Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip',}; + const data = { + '\\$id': '5e5ea5c16897e', + bucketId: '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + name: 'Pink.png', + folder: 'photos/2026/', + key: 'photos/2026/Pink.png', + signature: '5d529fd02b544198ae075bd57c1762bb', + mimeType: 'image/png', + sizeOriginal: 17890, + sizeActual: 12345, + chunksTotal: 17890, + chunksUploaded: 17890, + encryption: true, + compression: 'gzip', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await storage.createFile( '', '', @@ -172,88 +154,73 @@ describe('Storage', () => { expect(response).toEqual(data); }); - test('test method getFile()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'folder': 'photos/2026/', - 'key': 'photos/2026/Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip',}; + const data = { + '\\$id': '5e5ea5c16897e', + bucketId: '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + name: 'Pink.png', + folder: 'photos/2026/', + key: 'photos/2026/Pink.png', + signature: '5d529fd02b544198ae075bd57c1762bb', + mimeType: 'image/png', + sizeOriginal: 17890, + sizeActual: 12345, + chunksTotal: 17890, + chunksUploaded: 17890, + encryption: true, + compression: 'gzip', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await storage.getFile( - '', - '', - ); + const response = await storage.getFile('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateFile()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'folder': 'photos/2026/', - 'key': 'photos/2026/Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip',}; + const data = { + '\\$id': '5e5ea5c16897e', + bucketId: '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + name: 'Pink.png', + folder: 'photos/2026/', + key: 'photos/2026/Pink.png', + signature: '5d529fd02b544198ae075bd57c1762bb', + mimeType: 'image/png', + sizeOriginal: 17890, + sizeActual: 12345, + chunksTotal: 17890, + chunksUploaded: 17890, + encryption: true, + compression: 'gzip', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await storage.updateFile( - '', - '', - ); + const response = await storage.updateFile('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteFile()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await storage.deleteFile( - '', - '', - ); + const response = await storage.deleteFile('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getFileDownload()', async () => { const data = new ArrayBuffer(0); mockedFetch.mockImplementation(() => new Response(data)); - const response = await storage.getFileDownload( '', '', @@ -264,11 +231,9 @@ describe('Storage', () => { expect(response).toEqual(data); }); - test('test method getFilePreview()', async () => { const data = new ArrayBuffer(0); mockedFetch.mockImplementation(() => new Response(data)); - const response = await storage.getFilePreview( '', '', @@ -279,19 +244,14 @@ describe('Storage', () => { expect(response).toEqual(data); }); - test('test method getFileView()', async () => { const data = new ArrayBuffer(0); mockedFetch.mockImplementation(() => new Response(data)); - - const response = await storage.getFileView( - '', - '', - ); + const response = await storage.getFileView('', ''); // 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/tables-d-b.test.js b/test/services/tables-d-b.test.js index c0393409..21e37190 100644 --- a/test/services/tables-d-b.test.js +++ b/test/services/tables-d-b.test.js @@ -1,325 +1,287 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { TablesDB } = require("../../dist/services/tables-db"); +const { Client } = require('../../dist/client'); +const { TablesDB } = require('../../dist/services/tables-db'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('TablesDB', () => { const client = new Client(); const tablesDB = new TablesDB(client); - test('test method list()', async () => { - const data = { - 'total': 5, - 'databases': [],}; + const data = { + total: 5, + databases: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.list( - ); + const response = await tablesDB.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', - 'name': 'My Database', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true, - 'type': 'legacy',}; + const data = { + '\\$id': '5e5ea5c16897e', + name: 'My Database', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + enabled: true, + type: 'legacy', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.create( - '', - '', - ); + const response = await tablesDB.create('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listSpecifications()', async () => { - const data = { - 'specifications': [], - 'total': 9, - 'pricing': {},}; + const data = { + specifications: [], + total: 9, + pricing: {}, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.listSpecifications( - ); + const response = await tablesDB.listSpecifications(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listTransactions()', async () => { - const data = { - 'total': 5, - 'transactions': [],}; + const data = { + total: 5, + transactions: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.listTransactions( - ); + const response = await tablesDB.listTransactions(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createTransaction()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.createTransaction( - ); + const response = await tablesDB.createTransaction(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getTransaction()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.getTransaction( - '', - ); + const response = await tablesDB.getTransaction(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateTransaction()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.updateTransaction( - '', - ); + const response = await tablesDB.updateTransaction(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteTransaction()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.deleteTransaction( - '', - ); + const response = await tablesDB.deleteTransaction(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createOperations()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.createOperations( - '', - ); + const response = await tablesDB.createOperations(''); // 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', - 'name': 'My Database', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true, - 'type': 'legacy',}; + const data = { + '\\$id': '5e5ea5c16897e', + name: 'My Database', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + enabled: true, + type: 'legacy', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.get( - '', - ); + const response = await tablesDB.get(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method update()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - 'name': 'My Database', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true, - 'type': 'legacy',}; + const data = { + '\\$id': '5e5ea5c16897e', + name: 'My Database', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + enabled: true, + type: 'legacy', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.update( - '', - ); + const response = await tablesDB.update(''); // 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: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.delete( - '', - ); + const response = await tablesDB.delete(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createFailover()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'projectId': '5e5ea5c16897e', - 'name': 'My Production Database', - 'api': 'postgresql', - 'engine': 'postgresql', - 'version': '16', - 'specification': 's-2vcpu-2gb', - 'backend': 'edge', - 'hostname': 'db-myproject-mydb.fra.appwrite.center', - 'connectionPort': 5432, - 'connectionUser': 'appwrite_user', - 'connectionPassword': '••••••••', - 'connectionString': 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', - 'ssl': true, - 'status': 'ready', - 'containerStatus': 'active', - 'lifecycleState': 'active', - 'idleTimeoutMinutes': 15, - 'cpu': 2000, - 'memory': 4096, - 'storage': 100, - 'storageClass': 'ssd', - 'storageMaxGb': 100, - 'nodePool': 'db-pool-4vcpu-8gb', - 'replicas': 2, - 'syncMode': 'async', - 'networkMaxConnections': 500, - 'networkIdleTimeoutSeconds': 900, - 'networkIPAllowlist': [], - 'backupEnabled': true, - 'pitr': true, - 'pitrRetentionDays': 14, - 'storageAutoscaling': true, - 'storageAutoscalingThresholdPercent': 85, - 'storageAutoscalingMaxGb': 500, - 'maintenanceWindowDay': 'sun', - 'maintenanceWindowHourUtc': 3, - 'metricsEnabled': true, - 'sqlApiEnabled': true, - 'sqlApiAllowedStatements': [], - 'sqlApiMaxRows': 10000, - 'sqlApiMaxBytes': 10485760, - 'sqlApiTimeoutSeconds': 30, - 'error': '',}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.createFailover( - '', - ); + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await tablesDB.createFailover(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listMigrations()', async () => { - const data = { - 'total': 5, - 'migrations': [],}; + const data = { + total: 5, + migrations: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.listMigrations( - '', - ); + const response = await tablesDB.listMigrations(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createMigration()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'projectId': '5e5ea5c16897e', - 'databaseId': '5e5ea5c16897e', - 'specification': 's-2vcpu-4gb', - 'phase': 'pending', - 'attempt': 0, - 'lastError': '', - 'lagDocuments': 0, - 'verifiedAt': '2020-10-15T06:38:00.000+00:00', - 'cutoverAt': '2020-10-15T06:38:00.000+00:00', - 'soakUntil': '2020-10-15T06:38:00.000+00:00', - 'autoCutover': true, - 'cutoverRequested': true, - 'paused': true,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + databaseId: '5e5ea5c16897e', + specification: 's-2vcpu-4gb', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '2020-10-15T06:38:00.000+00:00', + cutoverAt: '2020-10-15T06:38:00.000+00:00', + soakUntil: '2020-10-15T06:38:00.000+00:00', + autoCutover: true, + cutoverRequested: true, + paused: true, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createMigration( '', 's-1vcpu-1gb', @@ -330,27 +292,27 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method getMigration()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'projectId': '5e5ea5c16897e', - 'databaseId': '5e5ea5c16897e', - 'specification': 's-2vcpu-4gb', - 'phase': 'pending', - 'attempt': 0, - 'lastError': '', - 'lagDocuments': 0, - 'verifiedAt': '2020-10-15T06:38:00.000+00:00', - 'cutoverAt': '2020-10-15T06:38:00.000+00:00', - 'soakUntil': '2020-10-15T06:38:00.000+00:00', - 'autoCutover': true, - 'cutoverRequested': true, - 'paused': true,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + databaseId: '5e5ea5c16897e', + specification: 's-2vcpu-4gb', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '2020-10-15T06:38:00.000+00:00', + cutoverAt: '2020-10-15T06:38:00.000+00:00', + soakUntil: '2020-10-15T06:38:00.000+00:00', + autoCutover: true, + cutoverRequested: true, + paused: true, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.getMigration( '', '', @@ -361,11 +323,9 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method deleteMigration()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.deleteMigration( '', '', @@ -376,27 +336,27 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method cutoverMigration()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'projectId': '5e5ea5c16897e', - 'databaseId': '5e5ea5c16897e', - 'specification': 's-2vcpu-4gb', - 'phase': 'pending', - 'attempt': 0, - 'lastError': '', - 'lagDocuments': 0, - 'verifiedAt': '2020-10-15T06:38:00.000+00:00', - 'cutoverAt': '2020-10-15T06:38:00.000+00:00', - 'soakUntil': '2020-10-15T06:38:00.000+00:00', - 'autoCutover': true, - 'cutoverRequested': true, - 'paused': true,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + databaseId: '5e5ea5c16897e', + specification: 's-2vcpu-4gb', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '2020-10-15T06:38:00.000+00:00', + cutoverAt: '2020-10-15T06:38:00.000+00:00', + soakUntil: '2020-10-15T06:38:00.000+00:00', + autoCutover: true, + cutoverRequested: true, + paused: true, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.cutoverMigration( '', '', @@ -407,101 +367,88 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method listOperations()', async () => { - const data = { - 'total': 5, - 'operations': [],}; + const data = { + total: 5, + operations: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.listOperations( - '', - ); + const response = await tablesDB.listOperations(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getReplicas()', async () => { - const data = { - 'replicas': 2, - 'syncMode': 'async', - 'syncDegraded': true, - 'syncAcknowledgements': 1, - 'syncStandbyCount': 2, - 'members': [],}; + const data = { + replicas: 2, + syncMode: 'async', + syncDegraded: true, + syncAcknowledgements: 1, + syncStandbyCount: 2, + members: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.getReplicas( - '', - ); + const response = await tablesDB.getReplicas(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getStatus()', async () => { - const data = { - 'health': 'healthy', - 'ready': true, - 'engine': 'postgresql', - 'version': '17', - 'uptime': 86400, - 'connections': {}, - 'syncMode': 'async', - 'syncDegraded': true, - 'syncAcknowledgements': 1, - 'syncStandbyCount': 2, - 'replicas': [], - 'volumes': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.getStatus( - '', - ); + const data = { + health: 'healthy', + ready: true, + engine: 'postgresql', + version: '17', + uptime: 86400, + connections: {}, + syncMode: 'async', + syncDegraded: true, + syncAcknowledgements: 1, + syncStandbyCount: 2, + replicas: [], + volumes: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await tablesDB.getStatus(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listTables()', async () => { - const data = { - 'total': 5, - 'tables': [],}; + const data = { + total: 5, + tables: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.listTables( - '', - ); + const response = await tablesDB.listTables(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createTable()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'databaseId': '5e5ea5c16897e', - 'name': 'My Table', - 'enabled': true, - 'rowSecurity': true, - 'columns': [], - 'indexes': [], - 'bytesMax': 65535, - 'bytesUsed': 1500,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + databaseId: '5e5ea5c16897e', + name: 'My Table', + enabled: true, + rowSecurity: true, + columns: [], + indexes: [], + bytesMax: 65535, + bytesUsed: 1500, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createTable( '', '', @@ -513,50 +460,45 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method getTable()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'databaseId': '5e5ea5c16897e', - 'name': 'My Table', - 'enabled': true, - 'rowSecurity': true, - 'columns': [], - 'indexes': [], - 'bytesMax': 65535, - 'bytesUsed': 1500,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.getTable( - '', - '', - ); + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + databaseId: '5e5ea5c16897e', + name: 'My Table', + enabled: true, + rowSecurity: true, + columns: [], + indexes: [], + bytesMax: 65535, + bytesUsed: 1500, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await tablesDB.getTable('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateTable()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'databaseId': '5e5ea5c16897e', - 'name': 'My Table', - 'enabled': true, - 'rowSecurity': true, - 'columns': [], - 'indexes': [], - 'bytesMax': 65535, - 'bytesUsed': 1500,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + databaseId: '5e5ea5c16897e', + name: 'My Table', + enabled: true, + rowSecurity: true, + columns: [], + indexes: [], + bytesMax: 65535, + bytesUsed: 1500, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateTable( '', '', @@ -567,11 +509,9 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method deleteTable()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.deleteTable( '', '', @@ -582,13 +522,12 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method listColumns()', async () => { - const data = { - 'total': 5, - 'columns': [],}; + const data = { + total: 5, + columns: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.listColumns( '', '', @@ -599,22 +538,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createBigIntColumn()', async () => { - const data = { - 'key': 'count', - 'type': 'bigint', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'count', + type: 'bigint', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createBigIntColumn( '', '', - '', + '', true, ); @@ -623,22 +561,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateBigIntColumn()', async () => { - const data = { - 'key': 'count', - 'type': 'bigint', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'count', + type: 'bigint', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateBigIntColumn( '', '', - '', + '', true, 1, ); @@ -648,22 +585,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createBooleanColumn()', async () => { - const data = { - 'key': 'isEnabled', - 'type': 'boolean', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'isEnabled', + type: 'boolean', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createBooleanColumn( '', '', - '', + '', true, ); @@ -672,22 +608,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateBooleanColumn()', async () => { - const data = { - 'key': 'isEnabled', - 'type': 'boolean', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'isEnabled', + type: 'boolean', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateBooleanColumn( '', '', - '', + '', true, true, ); @@ -697,23 +632,22 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createDatetimeColumn()', async () => { - const data = { - 'key': 'birthDay', - 'type': 'datetime', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'datetime',}; + const data = { + key: 'birthDay', + type: 'datetime', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'datetime', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createDatetimeColumn( '', '', - '', + '', true, ); @@ -722,23 +656,22 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateDatetimeColumn()', async () => { - const data = { - 'key': 'birthDay', - 'type': 'datetime', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'datetime',}; + const data = { + key: 'birthDay', + type: 'datetime', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'datetime', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateDatetimeColumn( '', '', - '', + '', true, '2020-10-15T06:38:00.000+00:00', ); @@ -748,23 +681,22 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createEmailColumn()', async () => { - const data = { - 'key': 'userEmail', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'email',}; + const data = { + key: 'userEmail', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'email', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createEmailColumn( '', '', - '', + '', true, ); @@ -773,23 +705,22 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateEmailColumn()', async () => { - const data = { - 'key': 'userEmail', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'email',}; + const data = { + key: 'userEmail', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'email', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateEmailColumn( '', '', - '', + '', true, 'email@example.com', ); @@ -799,24 +730,23 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createEnumColumn()', async () => { - const data = { - 'key': 'status', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'elements': [], - 'format': 'enum',}; + const data = { + key: 'status', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + elements: [], + format: 'enum', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createEnumColumn( '', '', - '', + '', [], true, ); @@ -826,27 +756,26 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateEnumColumn()', async () => { - const data = { - 'key': 'status', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'elements': [], - 'format': 'enum',}; + const data = { + key: 'status', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + elements: [], + format: 'enum', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateEnumColumn( '', '', - '', + '', [], true, - '', + 'active', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -854,22 +783,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createFloatColumn()', async () => { - const data = { - 'key': 'percentageCompleted', - 'type': 'double', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'percentageCompleted', + type: 'double', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createFloatColumn( '', '', - '', + '', true, ); @@ -878,22 +806,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateFloatColumn()', async () => { - const data = { - 'key': 'percentageCompleted', - 'type': 'double', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'percentageCompleted', + type: 'double', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateFloatColumn( '', '', - '', + '', true, 1.0, ); @@ -903,22 +830,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createIntegerColumn()', async () => { - const data = { - 'key': 'count', - 'type': 'integer', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'count', + type: 'integer', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createIntegerColumn( '', '', - '', + '', true, ); @@ -927,22 +853,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateIntegerColumn()', async () => { - const data = { - 'key': 'count', - 'type': 'integer', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'count', + type: 'integer', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateIntegerColumn( '', '', - '', + '', true, 1, ); @@ -952,23 +877,22 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createIpColumn()', async () => { - const data = { - 'key': 'ipAddress', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'ip',}; + const data = { + key: 'ipAddress', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'ip', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createIpColumn( '', '', - '', + '', true, ); @@ -977,25 +901,24 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateIpColumn()', async () => { - const data = { - 'key': 'ipAddress', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'ip',}; + const data = { + key: 'ipAddress', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'ip', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateIpColumn( '', '', - '', + '', true, - '', + '192.0.2.0', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1003,22 +926,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createLineColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createLineColumn( '', '', - '', + '', true, ); @@ -1027,22 +949,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateLineColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateLineColumn( '', '', - '', + '', true, ); @@ -1051,22 +972,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createLongtextColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createLongtextColumn( '', '', - '', + '', true, ); @@ -1075,24 +995,23 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateLongtextColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateLongtextColumn( '', '', - '', + '', true, - '', + 'Hello World', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1100,22 +1019,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createMediumtextColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createMediumtextColumn( '', '', - '', + '', true, ); @@ -1124,24 +1042,23 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateMediumtextColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateMediumtextColumn( '', '', - '', + '', true, - '', + 'Hello World', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1149,22 +1066,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createPointColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createPointColumn( '', '', - '', + '', true, ); @@ -1173,22 +1089,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updatePointColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updatePointColumn( '', '', - '', + '', true, ); @@ -1197,22 +1112,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createPolygonColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createPolygonColumn( '', '', - '', + '', true, ); @@ -1221,22 +1135,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updatePolygonColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updatePolygonColumn( '', '', - '', + '', true, ); @@ -1245,24 +1158,23 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createRelationshipColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'relatedTable': 'table', - 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', - 'twoWay': true, - 'twoWayKey': 'string', - 'onDelete': 'restrict|cascade|setNull', - 'side': 'parent|child',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + relatedTable: 'table', + relationType: 'oneToOne|oneToMany|manyToOne|manyToMany', + twoWay: true, + twoWayKey: 'string', + onDelete: 'restrict|cascade|setNull', + side: 'parent|child', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createRelationshipColumn( '', '', @@ -1275,23 +1187,22 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createStringColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'size': 128,}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + size: 128, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createStringColumn( '', '', - '', + '', 1, true, ); @@ -1301,25 +1212,24 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateStringColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'size': 128,}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + size: 128, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateStringColumn( '', '', - '', + '', true, - '', + 'Hello World', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1327,22 +1237,21 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createTextColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createTextColumn( '', '', - '', + '', true, ); @@ -1351,24 +1260,23 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateTextColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateTextColumn( '', '', - '', + '', true, - '', + 'Hello World', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1376,23 +1284,22 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createUrlColumn()', async () => { - const data = { - 'key': 'githubUrl', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'url',}; + const data = { + key: 'githubUrl', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'url', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createUrlColumn( '', '', - '', + '', true, ); @@ -1401,23 +1308,22 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateUrlColumn()', async () => { - const data = { - 'key': 'githubUrl', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'url',}; + const data = { + key: 'githubUrl', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + format: 'url', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateUrlColumn( '', '', - '', + '', true, 'https://example.com', ); @@ -1427,23 +1333,22 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createVarcharColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'size': 128,}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + size: 128, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createVarcharColumn( '', '', - '', + '', 1, true, ); @@ -1453,25 +1358,24 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateVarcharColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'size': 128,}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + size: 128, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateVarcharColumn( '', '', - '', + '', true, - '', + 'Hello World', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1479,23 +1383,22 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method getColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'size': 128,}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + size: 128, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.getColumn( '', '', - '', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1503,15 +1406,13 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method deleteColumn()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.deleteColumn( '', '', - '', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1519,28 +1420,27 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateRelationshipColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'relatedTable': 'table', - 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', - 'twoWay': true, - 'twoWayKey': 'string', - 'onDelete': 'restrict|cascade|setNull', - 'side': 'parent|child',}; + const data = { + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + required: true, + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + relatedTable: 'table', + relationType: 'oneToOne|oneToMany|manyToOne|manyToMany', + twoWay: true, + twoWayKey: 'string', + onDelete: 'restrict|cascade|setNull', + side: 'parent|child', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateRelationshipColumn( '', '', - '', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1548,13 +1448,12 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method listIndexes()', async () => { - const data = { - 'total': 5, - 'indexes': [],}; + const data = { + total: 5, + indexes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.listIndexes( '', '', @@ -1565,24 +1464,23 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createIndex()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'index1', - 'type': 'primary', - 'status': 'available', - 'error': 'string', - 'columns': [], - 'lengths': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'index1', + type: 'primary', + status: 'available', + error: 'string', + columns: [], + lengths: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createIndex( '', '', - '', + '', 'key', [], ); @@ -1592,24 +1490,23 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method getIndex()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'index1', - 'type': 'primary', - 'status': 'available', - 'error': 'string', - 'columns': [], - 'lengths': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'index1', + type: 'primary', + status: 'available', + error: 'string', + columns: [], + lengths: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.getIndex( '', '', - '', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1617,15 +1514,13 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method deleteIndex()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.deleteIndex( '', '', - '', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1633,35 +1528,30 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method listRows()', async () => { - const data = { - 'total': 5, - 'rows': [],}; + const data = { + total: 5, + rows: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tablesDB.listRows( - '', - '', - ); + const response = await tablesDB.listRows('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createRow()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$tableId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createRow( '', '', @@ -1674,13 +1564,12 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method createRows()', async () => { - const data = { - 'total': 5, - 'rows': [],}; + const data = { + total: 5, + rows: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.createRows( '', '', @@ -1692,13 +1581,12 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method upsertRows()', async () => { - const data = { - 'total': 5, - 'rows': [],}; + const data = { + total: 5, + rows: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.upsertRows( '', '', @@ -1710,13 +1598,12 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateRows()', async () => { - const data = { - 'total': 5, - 'rows': [],}; + const data = { + total: 5, + rows: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateRows( '', '', @@ -1727,13 +1614,12 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method deleteRows()', async () => { - const data = { - 'total': 5, - 'rows': [],}; + const data = { + total: 5, + rows: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.deleteRows( '', '', @@ -1744,18 +1630,17 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method getRow()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$tableId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.getRow( '', '', @@ -1767,18 +1652,17 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method upsertRow()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$tableId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.upsertRow( '', '', @@ -1790,18 +1674,17 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method updateRow()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$tableId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.updateRow( '', '', @@ -1813,11 +1696,9 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method deleteRow()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.deleteRow( '', '', @@ -1829,23 +1710,22 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method decrementRowColumn()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$tableId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.decrementRowColumn( '', '', '', - '', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1853,23 +1733,22 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - test('test method incrementRowColumn()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$tableId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tablesDB.incrementRowColumn( '', '', '', - '', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -1877,4 +1756,4 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); - }) +}); diff --git a/test/services/teams.test.js b/test/services/teams.test.js index dfa5365b..7dcf7440 100644 --- a/test/services/teams.test.js +++ b/test/services/teams.test.js @@ -1,135 +1,116 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Teams } = require("../../dist/services/teams"); +const { Client } = require('../../dist/client'); +const { Teams } = require('../../dist/services/teams'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Teams', () => { const client = new Client(); const teams = new Teams(client); - test('test method list()', async () => { - const data = { - 'total': 5, - 'teams': [],}; + const data = { + total: 5, + teams: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await teams.list( - ); + const response = await teams.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', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'VIP', + total: 7, + prefs: {}, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await teams.create( - '', - '', - ); + const response = await teams.create('', ''); // 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', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'VIP', + total: 7, + prefs: {}, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await teams.get( - '', - ); + const response = await teams.get(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateName()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'VIP', + total: 7, + prefs: {}, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await teams.updateName( - '', - '', - ); + const response = await teams.updateName('', ''); // 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: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await teams.delete( - '', - ); + const response = await teams.delete(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listInstallations()', async () => { - const data = { - 'total': 5, - 'installations': [],}; + const data = { + total: 5, + installations: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await teams.listInstallations( - '', - ); + const response = await teams.listInstallations(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createInstallation()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'teamId': '5e5ea5c16897e', - 'scopes': [], - 'authorizationDetails': {}, - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + appId: '5e5ea5c16897e', + teamId: '5e5ea5c16897e', + scopes: [], + authorizationDetails: [], + createdById: '5e5ea5c16897e', + createdByName: 'Walter White', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await teams.createInstallation( '', '', @@ -140,20 +121,19 @@ describe('Teams', () => { expect(response).toEqual(data); }); - test('test method getInstallation()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'teamId': '5e5ea5c16897e', - 'scopes': [], - 'authorizationDetails': {}, - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + appId: '5e5ea5c16897e', + teamId: '5e5ea5c16897e', + scopes: [], + authorizationDetails: [], + createdById: '5e5ea5c16897e', + createdByName: 'Walter White', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await teams.getInstallation( '', '', @@ -164,20 +144,19 @@ describe('Teams', () => { expect(response).toEqual(data); }); - test('test method updateInstallation()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'teamId': '5e5ea5c16897e', - 'scopes': [], - 'authorizationDetails': {}, - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White',}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + appId: '5e5ea5c16897e', + teamId: '5e5ea5c16897e', + scopes: [], + authorizationDetails: [], + createdById: '5e5ea5c16897e', + createdByName: 'Walter White', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await teams.updateInstallation( '', '', @@ -188,11 +167,9 @@ describe('Teams', () => { expect(response).toEqual(data); }); - test('test method deleteInstallation()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await teams.deleteInstallation( '', '', @@ -203,72 +180,64 @@ describe('Teams', () => { expect(response).toEqual(data); }); - test('test method listMemberships()', async () => { - const data = { - 'total': 5, - 'memberships': [],}; + const data = { + total: 5, + memberships: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await teams.listMemberships( - '', - ); + const response = await teams.listMemberships(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createMembership()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c16897e', + userName: 'John Doe', + userEmail: 'john@appwrite.io', + userPhone: '+1 555 555 5555', + teamId: '5e5ea5c16897e', + teamName: 'VIP', + invited: '2020-10-15T06:38:00.000+00:00', + joined: '2020-10-15T06:38:00.000+00:00', + confirm: true, + mfa: true, + userAccessedAt: '2020-10-15T06:38:00.000+00:00', + roles: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await teams.createMembership( - '', - [], - ); + const response = await teams.createMembership('', []); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getMembership()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c16897e', + userName: 'John Doe', + userEmail: 'john@appwrite.io', + userPhone: '+1 555 555 5555', + teamId: '5e5ea5c16897e', + teamName: 'VIP', + invited: '2020-10-15T06:38:00.000+00:00', + joined: '2020-10-15T06:38:00.000+00:00', + confirm: true, + mfa: true, + userAccessedAt: '2020-10-15T06:38:00.000+00:00', + roles: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await teams.getMembership( '', '', @@ -279,26 +248,25 @@ describe('Teams', () => { expect(response).toEqual(data); }); - test('test method updateMembership()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c16897e', + userName: 'John Doe', + userEmail: 'john@appwrite.io', + userPhone: '+1 555 555 5555', + teamId: '5e5ea5c16897e', + teamName: 'VIP', + invited: '2020-10-15T06:38:00.000+00:00', + joined: '2020-10-15T06:38:00.000+00:00', + confirm: true, + mfa: true, + userAccessedAt: '2020-10-15T06:38:00.000+00:00', + roles: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await teams.updateMembership( '', '', @@ -310,11 +278,9 @@ describe('Teams', () => { expect(response).toEqual(data); }); - test('test method deleteMembership()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await teams.deleteMembership( '', '', @@ -325,26 +291,25 @@ describe('Teams', () => { expect(response).toEqual(data); }); - test('test method updateMembershipStatus()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c16897e', + userName: 'John Doe', + userEmail: 'john@appwrite.io', + userPhone: '+1 555 555 5555', + teamId: '5e5ea5c16897e', + teamName: 'VIP', + invited: '2020-10-15T06:38:00.000+00:00', + joined: '2020-10-15T06:38:00.000+00:00', + confirm: true, + mfa: true, + userAccessedAt: '2020-10-15T06:38:00.000+00:00', + roles: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await teams.updateMembershipStatus( '', '', @@ -357,33 +322,24 @@ describe('Teams', () => { expect(response).toEqual(data); }); - test('test method getPrefs()', async () => { - const data = {}; + const data = {}; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await teams.getPrefs( - '', - ); + const response = await teams.getPrefs(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updatePrefs()', async () => { - const data = {}; + const data = {}; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await teams.updatePrefs( - '', - {}, - ); + const response = await teams.updatePrefs('', {}); // 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/tokens.test.js b/test/services/tokens.test.js index 491ddbf4..323ab938 100644 --- a/test/services/tokens.test.js +++ b/test/services/tokens.test.js @@ -1,43 +1,40 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Tokens } = require("../../dist/services/tokens"); +const { Client } = require('../../dist/client'); +const { Tokens } = require('../../dist/services/tokens'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Tokens', () => { const client = new Client(); const tokens = new Tokens(client); - test('test method list()', async () => { - const data = { - 'total': 5, - 'tokens': [],}; + const data = { + total: 5, + tokens: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tokens.list( - '', - '', - ); + const response = await tokens.list('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createFileToken()', async () => { - const data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'resourceId': '5e5ea5c168bb8:5e5ea5c168bb8', - 'resourceType': 'files', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'secret': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': 'bb8ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + resourceId: '5e5ea5c168bb8:5e5ea5c168bb8', + resourceType: 'files', + expire: '2020-10-15T06:38:00.000+00:00', + secret: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await tokens.createFileToken( '', '', @@ -48,60 +45,50 @@ describe('Tokens', () => { expect(response).toEqual(data); }); - test('test method get()', async () => { - const data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'resourceId': '5e5ea5c168bb8:5e5ea5c168bb8', - 'resourceType': 'files', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'secret': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': 'bb8ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + resourceId: '5e5ea5c168bb8:5e5ea5c168bb8', + resourceType: 'files', + expire: '2020-10-15T06:38:00.000+00:00', + secret: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tokens.get( - '', - ); + const response = await tokens.get(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method update()', async () => { - const data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'resourceId': '5e5ea5c168bb8:5e5ea5c168bb8', - 'resourceType': 'files', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'secret': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + const data = { + '\\$id': 'bb8ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + resourceId: '5e5ea5c168bb8:5e5ea5c168bb8', + resourceType: 'files', + expire: '2020-10-15T06:38:00.000+00:00', + secret: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tokens.update( - '', - ); + const response = await tokens.update(''); // 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: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await tokens.delete( - '', - ); + const response = await tokens.delete(''); // 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/users.test.js b/test/services/users.test.js index 04ef4223..0e61c5f2 100644 --- a/test/services/users.test.js +++ b/test/services/users.test.js @@ -1,80 +1,76 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Users } = require("../../dist/services/users"); +const { Client } = require('../../dist/client'); +const { Users } = require('../../dist/services/users'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Users', () => { const client = new Client(); const users = new Users(client); - test('test method list()', async () => { - const data = { - 'total': 5, - 'users': [],}; + const data = { + total: 5, + users: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.list( - ); + const response = await users.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', - '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',}; + 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 users.create( - '', - ); + const response = await users.create(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createArgon2User()', 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',}; + 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 users.createArgon2User( '', 'email@example.com', @@ -86,27 +82,26 @@ describe('Users', () => { expect(response).toEqual(data); }); - test('test method createBcryptUser()', 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',}; + 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 users.createBcryptUser( '', 'email@example.com', @@ -118,56 +113,49 @@ describe('Users', () => { expect(response).toEqual(data); }); - test('test method listIdentities()', async () => { - const data = { - 'total': 5, - 'identities': [],}; + const data = { + total: 5, + identities: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.listIdentities( - ); + const response = await users.listIdentities(); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteIdentity()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.deleteIdentity( - '', - ); + const response = await users.deleteIdentity(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createMD5User()', 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',}; + 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 users.createMD5User( '', 'email@example.com', @@ -179,27 +167,26 @@ describe('Users', () => { expect(response).toEqual(data); }); - test('test method createPHPassUser()', 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',}; + 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 users.createPHPassUser( '', 'email@example.com', @@ -211,27 +198,26 @@ describe('Users', () => { expect(response).toEqual(data); }); - test('test method createScryptUser()', 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',}; + 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 users.createScryptUser( '', 'email@example.com', @@ -248,27 +234,26 @@ describe('Users', () => { expect(response).toEqual(data); }); - test('test method createScryptModifiedUser()', 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',}; + 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 users.createScryptModifiedUser( '', 'email@example.com', @@ -283,27 +268,26 @@ describe('Users', () => { expect(response).toEqual(data); }); - test('test method createSHAUser()', 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',}; + 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 users.createSHAUser( '', 'email@example.com', @@ -315,71 +299,63 @@ describe('Users', () => { 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', - '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',}; + 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 users.get( - '', - ); + const response = await users.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: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.delete( - '', - ); + const response = await users.delete(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateEmail()', 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',}; + 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 users.updateEmail( '', 'email@example.com', @@ -390,182 +366,155 @@ describe('Users', () => { expect(response).toEqual(data); }); - test('test method updateImpersonator()', 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',}; + 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 users.updateImpersonator( - '', - true, - ); + const response = await users.updateImpersonator('', true); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createJWT()', async () => { - const data = { - 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; + const data = { + jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.createJWT( - '', - ); + const response = await users.createJWT(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateLabels()', 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',}; + 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 users.updateLabels( - '', - [], - ); + const response = await users.updateLabels('', []); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listLogs()', async () => { - const data = { - 'total': 5, - 'logs': [],}; + const data = { + total: 5, + logs: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.listLogs( - '', - ); + const response = await users.listLogs(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listMemberships()', async () => { - const data = { - 'total': 5, - 'memberships': [],}; + const data = { + total: 5, + memberships: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.listMemberships( - '', - ); + const response = await users.listMemberships(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateMfa()', 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',}; + 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 users.updateMfa( - '', - true, - ); + const response = await users.updateMfa('', true); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateMFA()', 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',}; + 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 users.updateMFA( - '', - true, - ); + const response = await users.updateMFA('', true); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteMfaAuthenticator()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await users.deleteMfaAuthenticator( '', 'totp', @@ -576,11 +525,9 @@ describe('Users', () => { expect(response).toEqual(data); }); - test('test method deleteMFAAuthenticator()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await users.deleteMFAAuthenticator( '', 'totp', @@ -591,16 +538,15 @@ describe('Users', () => { expect(response).toEqual(data); }); - test('test method getMFAChallenge()', async () => { - const data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'code': '446372',}; + const data = { + '\\$id': 'bb8ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c168bb8', + expire: '2020-10-15T06:38:00.000+00:00', + code: '446372', + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await users.getMFAChallenge( '', '', @@ -611,404 +557,336 @@ describe('Users', () => { expect(response).toEqual(data); }); - test('test method listMfaFactors()', async () => { - const data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true, - 'custom': true,}; + const data = { + totp: true, + phone: true, + email: true, + recoveryCode: true, + custom: true, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.listMfaFactors( - '', - ); + const response = await users.listMfaFactors(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listMFAFactors()', async () => { - const data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true, - 'custom': true,}; + const data = { + totp: true, + phone: true, + email: true, + recoveryCode: true, + custom: true, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.listMFAFactors( - '', - ); + const response = await users.listMFAFactors(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getMfaRecoveryCodes()', async () => { - const data = { - 'recoveryCodes': [],}; + const data = { + recoveryCodes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.getMfaRecoveryCodes( - '', - ); + const response = await users.getMfaRecoveryCodes(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getMFARecoveryCodes()', async () => { - const data = { - 'recoveryCodes': [],}; + const data = { + recoveryCodes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.getMFARecoveryCodes( - '', - ); + const response = await users.getMFARecoveryCodes(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateMfaRecoveryCodes()', async () => { - const data = { - 'recoveryCodes': [],}; + const data = { + recoveryCodes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.updateMfaRecoveryCodes( - '', - ); + const response = await users.updateMfaRecoveryCodes(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateMFARecoveryCodes()', async () => { - const data = { - 'recoveryCodes': [],}; + const data = { + recoveryCodes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.updateMFARecoveryCodes( - '', - ); + const response = await users.updateMFARecoveryCodes(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createMfaRecoveryCodes()', async () => { - const data = { - 'recoveryCodes': [],}; + const data = { + recoveryCodes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.createMfaRecoveryCodes( - '', - ); + const response = await users.createMfaRecoveryCodes(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createMFARecoveryCodes()', async () => { - const data = { - 'recoveryCodes': [],}; + const data = { + recoveryCodes: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.createMFARecoveryCodes( - '', - ); + const response = await users.createMFARecoveryCodes(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateName()', 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',}; + 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 users.updateName( - '', - '', - ); + const response = await users.updateName('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updatePassword()', 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',}; + 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 users.updatePassword( - '', - 'password', - ); + const response = await users.updatePassword('', 'password'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updatePhone()', 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',}; + 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 users.updatePhone( - '', - '+12065550100', - ); + const response = await users.updatePhone('', '+12065550100'); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method getPrefs()', async () => { - const data = {}; + const data = {}; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.getPrefs( - '', - ); + const response = await users.getPrefs(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updatePrefs()', async () => { - const data = {}; + const data = {}; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.updatePrefs( - '', - {}, - ); + const response = await users.updatePrefs('', {}); // 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, - 'sessions': [],}; + const data = { + total: 5, + sessions: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.listSessions( - '', - ); + const response = await users.listSessions(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createSession()', 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 users.createSession( - '', - ); + 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 users.createSession(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteSessions()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.deleteSessions( - '', - ); + const response = await users.deleteSessions(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteSession()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.deleteSession( - '', - '', - ); + const response = await users.deleteSession('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateStatus()', 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',}; + 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 users.updateStatus( - '', - true, - ); + const response = await users.updateStatus('', true); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method listTargets()', async () => { - const data = { - 'total': 5, - 'targets': [],}; + const data = { + total: 5, + targets: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.listTargets( - '', - ); + const response = await users.listTargets(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createTarget()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true,}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'Apple iPhone 12', + userId: '259125845563242502', + providerType: 'email', + identifier: 'token', + expired: true, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await users.createTarget( '', '', @@ -1021,147 +899,123 @@ describe('Users', () => { expect(response).toEqual(data); }); - test('test method getTarget()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true,}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'Apple iPhone 12', + userId: '259125845563242502', + providerType: 'email', + identifier: 'token', + expired: true, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.getTarget( - '', - '', - ); + const response = await users.getTarget('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateTarget()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true,}; + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'Apple iPhone 12', + userId: '259125845563242502', + providerType: 'email', + identifier: 'token', + expired: true, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.updateTarget( - '', - '', - ); + const response = await users.updateTarget('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method deleteTarget()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await users.deleteTarget( - '', - '', - ); + const response = await users.deleteTarget('', ''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method createToken()', 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',}; + 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 users.createToken( - '', - ); + const response = await users.createToken(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateEmailVerification()', 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',}; + 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 users.updateEmailVerification( - '', - true, - ); + const response = await users.updateEmailVerification('', true); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updatePhoneVerification()', 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',}; + 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 users.updatePhoneVerification( - '', - true, - ); + const response = await users.updatePhoneVerification('', true); // 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/vectors-d-b.test.js b/test/services/vectors-d-b.test.js new file mode 100644 index 00000000..c36293a7 --- /dev/null +++ b/test/services/vectors-d-b.test.js @@ -0,0 +1,695 @@ +const { Client } = require('../../dist/client'); +const { VectorsDB } = require('../../dist/services/vectors-db'); + +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); + +describe('VectorsDB', () => { + const client = new Client(); + const vectorsDB = new VectorsDB(client); + + test('test method list()', async () => { + const data = { + total: 5, + databases: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.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', + name: 'My Database', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + enabled: true, + type: 'legacy', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.create('', ''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listSpecifications()', async () => { + const data = { + specifications: [], + total: 9, + pricing: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.listSpecifications(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listTransactions()', async () => { + const data = { + total: 5, + transactions: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.listTransactions(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createTransaction()', async () => { + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.createTransaction(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getTransaction()', async () => { + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.getTransaction(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateTransaction()', async () => { + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.updateTransaction(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteTransaction()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.deleteTransaction(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createOperations()', async () => { + const data = { + '\\$id': '259125845563242502', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + status: 'pending', + operations: 5, + expiresAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.createOperations(''); + + // 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', + name: 'My Database', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + enabled: true, + type: 'legacy', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.get(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method update()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + name: 'My Database', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + enabled: true, + type: 'legacy', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.update('', ''); + + // 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 vectorsDB.delete(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listCollections()', async () => { + const data = { + total: 5, + collections: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.listCollections(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createCollection()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + databaseId: '5e5ea5c16897e', + name: 'My Collection', + enabled: true, + documentSecurity: true, + attributes: [], + indexes: [], + bytesMax: 65535, + bytesUsed: 1500, + dimension: 1536, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.createCollection( + '', + '', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getCollection()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + databaseId: '5e5ea5c16897e', + name: 'My Collection', + enabled: true, + documentSecurity: true, + attributes: [], + indexes: [], + bytesMax: 65535, + bytesUsed: 1500, + dimension: 1536, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.getCollection( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateCollection()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + databaseId: '5e5ea5c16897e', + name: 'My Collection', + enabled: true, + documentSecurity: true, + attributes: [], + indexes: [], + bytesMax: 65535, + bytesUsed: 1500, + dimension: 1536, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.updateCollection( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteCollection()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.deleteCollection( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listDocuments()', async () => { + const data = { + total: 5, + documents: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.listDocuments( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createDocument()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.createDocument( + '', + '', + '', + {}, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createDocuments()', async () => { + const data = { + total: 5, + documents: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.createDocuments( + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method upsertDocuments()', async () => { + const data = { + total: 5, + documents: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.upsertDocuments( + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateDocuments()', async () => { + const data = { + total: 5, + documents: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.updateDocuments( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteDocuments()', async () => { + const data = { + total: 5, + documents: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.deleteDocuments( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createQuery()', async () => { + const data = { + total: 5, + documents: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.createQuery( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getDocument()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.getDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method upsertDocument()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.upsertDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateDocument()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$sequence': '1', + '\\$collectionId': '5e5ea5c15117e', + '\\$databaseId': '5e5ea5c15117e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\\$permissions': [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.updateDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteDocument()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.deleteDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listIndexes()', async () => { + const data = { + total: 5, + indexes: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.listIndexes( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createIndex()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'index1', + type: 'primary', + status: 'available', + error: 'string', + attributes: [], + lengths: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.createIndex( + '', + '', + '', + 'hnsw_euclidean', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getIndex()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + key: 'index1', + type: 'primary', + status: 'available', + error: 'string', + attributes: [], + lengths: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.getIndex( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteIndex()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.deleteIndex( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createFailover()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + projectId: '5e5ea5c16897e', + name: 'My Production Database', + api: 'postgresql', + engine: 'postgresql', + version: '16', + specification: 's-2vcpu-2gb', + backend: 'edge', + hostname: 'db-myproject-mydb.fra.appwrite.center', + connectionPort: 5432, + connectionUser: 'appwrite_user', + connectionPassword: '••••••••', + connectionString: + 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + ssl: true, + status: 'ready', + containerStatus: 'active', + lifecycleState: 'active', + idleTimeoutMinutes: 15, + cpu: 2000, + memory: 4096, + storage: 100, + storageClass: 'ssd', + storageMaxGb: 100, + nodePool: 'db-pool-4vcpu-8gb', + replicas: 2, + syncMode: 'async', + networkMaxConnections: 500, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 14, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 500, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: true, + sqlApiEnabled: true, + sqlApiAllowedStatements: [], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.createFailover(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listOperations()', async () => { + const data = { + total: 5, + operations: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.listOperations(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getReplicas()', async () => { + const data = { + replicas: 2, + syncMode: 'async', + syncDegraded: true, + syncAcknowledgements: 1, + syncStandbyCount: 2, + members: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.getReplicas(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getStatus()', async () => { + const data = { + health: 'healthy', + ready: true, + engine: 'postgresql', + version: '17', + uptime: 86400, + connections: {}, + syncMode: 'async', + syncDegraded: true, + syncAcknowledgements: 1, + syncStandbyCount: 2, + replicas: [], + volumes: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await vectorsDB.getStatus(''); + + // 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/webhooks.test.js b/test/services/webhooks.test.js index 46382dae..7f7e54b9 100644 --- a/test/services/webhooks.test.js +++ b/test/services/webhooks.test.js @@ -1,50 +1,49 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { Webhooks } = require("../../dist/services/webhooks"); +const { Client } = require('../../dist/client'); +const { Webhooks } = require('../../dist/services/webhooks'); -const { fetch: mockedFetch, Response } = require("undici"); -jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); describe('Webhooks', () => { const client = new Client(); const webhooks = new Webhooks(client); - test('test method list()', async () => { - const data = { - 'total': 5, - 'webhooks': [],}; + const data = { + total: 5, + webhooks: [], + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await webhooks.list( - ); + const response = await webhooks.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', - 'name': 'My Webhook', - 'url': 'https://example.com/webhook', - 'events': [], - 'tls': true, - 'authUsername': 'username', - 'authPassword': 'webhook-password', - 'secret': 'ad3d581ca230e2b7059c545e5a', - 'enabled': true, - 'logs': 'Failed to connect to remote server.', - 'attempts': 10,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Webhook', + url: 'https://example.com/webhook', + events: [], + tls: true, + authUsername: 'username', + authPassword: 'webhook-password', + secret: 'ad3d581ca230e2b7059c545e5a', + enabled: true, + logs: 'Failed to connect to remote server.', + attempts: 10, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await webhooks.create( '', - '', + 'https://example.com/webhook', '', [], ); @@ -54,55 +53,51 @@ describe('Webhooks', () => { 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', - 'name': 'My Webhook', - 'url': 'https://example.com/webhook', - 'events': [], - 'tls': true, - 'authUsername': 'username', - 'authPassword': 'webhook-password', - 'secret': 'ad3d581ca230e2b7059c545e5a', - 'enabled': true, - 'logs': 'Failed to connect to remote server.', - 'attempts': 10,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Webhook', + url: 'https://example.com/webhook', + events: [], + tls: true, + authUsername: 'username', + authPassword: 'webhook-password', + secret: 'ad3d581ca230e2b7059c545e5a', + enabled: true, + logs: 'Failed to connect to remote server.', + attempts: 10, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await webhooks.get( - '', - ); + const response = await webhooks.get(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method update()', 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 Webhook', - 'url': 'https://example.com/webhook', - 'events': [], - 'tls': true, - 'authUsername': 'username', - 'authPassword': 'webhook-password', - 'secret': 'ad3d581ca230e2b7059c545e5a', - 'enabled': true, - 'logs': 'Failed to connect to remote server.', - 'attempts': 10,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Webhook', + url: 'https://example.com/webhook', + events: [], + tls: true, + authUsername: 'username', + authPassword: 'webhook-password', + secret: 'ad3d581ca230e2b7059c545e5a', + enabled: true, + logs: 'Failed to connect to remote server.', + attempts: 10, + }; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await webhooks.update( '', '', - '', + 'https://example.com/webhook', [], ); @@ -111,45 +106,38 @@ describe('Webhooks', () => { expect(response).toEqual(data); }); - test('test method delete()', async () => { - const data = {message: ""}; + const data = { message: '' }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await webhooks.delete( - '', - ); + const response = await webhooks.delete(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - test('test method updateSecret()', 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 Webhook', - 'url': 'https://example.com/webhook', - 'events': [], - 'tls': true, - 'authUsername': 'username', - 'authPassword': 'webhook-password', - 'secret': 'ad3d581ca230e2b7059c545e5a', - 'enabled': true, - 'logs': 'Failed to connect to remote server.', - 'attempts': 10,}; + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'My Webhook', + url: 'https://example.com/webhook', + events: [], + tls: true, + authUsername: 'username', + authPassword: 'webhook-password', + secret: 'ad3d581ca230e2b7059c545e5a', + enabled: true, + logs: 'Failed to connect to remote server.', + attempts: 10, + }; mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await webhooks.updateSecret( - '', - ); + const response = await webhooks.updateSecret(''); // Remove custom toString method on the objects to allow for clean data comparison. delete response.toString; expect(response).toEqual(data); }); - }) +}); diff --git a/tsconfig.json b/tsconfig.json index 45afe7d2..a323d4f0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,4 +15,4 @@ "compileOnSave": false, "exclude": ["node_modules", "dist"], "include": ["src"] -} \ No newline at end of file +} diff --git a/tsup.config.ts b/tsup.config.ts index d39e2c54..964f1560 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,27 +1,27 @@ -import { defineConfig, type Options } from "tsup"; -import { esbuildPluginFilePathExtensions } from "esbuild-plugin-file-path-extensions"; +import { defineConfig, type Options } from 'tsup'; +import { esbuildPluginFilePathExtensions } from 'esbuild-plugin-file-path-extensions'; const commonConfig: Options = { - sourcemap: true, - clean: true, - dts: true, - treeshake: true, - target: "node16", - entry: ["src/**/*.ts"], - outDir: "dist", + sourcemap: true, + clean: true, + dts: true, + treeshake: true, + target: 'node16', + entry: ['src/**/*.ts'], + outDir: 'dist', }; export default defineConfig([ - { - ...commonConfig, - format: "esm", - esbuildPlugins: [esbuildPluginFilePathExtensions({ filter: /^\./ })], - bundle: true, - // Yes, bundle: true => https://github.com/favware/esbuild-plugin-file-path-extensions?tab=readme-ov-file#usage - }, - { - ...commonConfig, - format: "cjs", - bundle: false, - }, + { + ...commonConfig, + format: 'esm', + esbuildPlugins: [esbuildPluginFilePathExtensions({ filter: /^\./ })], + bundle: true, + // Yes, bundle: true => https://github.com/favware/esbuild-plugin-file-path-extensions?tab=readme-ov-file#usage + }, + { + ...commonConfig, + format: 'cjs', + bundle: false, + }, ]);